From patchwork Wed Mar 30 23:31:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1611463 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=vw5kD26V; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KTN6P6MDxz9sBy for ; Thu, 31 Mar 2022 10:33:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 91F1C3865479 for ; Wed, 30 Mar 2022 23:33:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91F1C3865479 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648683211; bh=br7AUDaFaVeqJolTbe3+QfAhSAuJrWwC2m13j9Nr5dM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vw5kD26VL8g85cSr/I6K+WrrvCdpTFaNKYE1QBiyELmhi59vTy2oJz2iRNc5+gSfr f28pOccfkBdN55yNDaCt3m+Va/B+iLdWoGiHLrKMiA0RMCmmrXLOE7cVJgb0gfX/Rd DT6z9xZDMEoc5yloc8L2bPLuEhr/usfAURi8ZYSY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 34898385800E for ; Wed, 30 Mar 2022 23:31:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 34898385800E Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22UL52wC032372 for ; Wed, 30 Mar 2022 23:31:49 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1uctu2vd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Mar 2022 23:31:49 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 22UNMbIR007313 for ; Wed, 30 Mar 2022 23:31:47 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3f1s979708-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Mar 2022 23:31:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gLzZZI2n84mzrioijD9EXsJ1KpOIo9B1kskY5TWRwkfPIXNmLn3Igl8wT7YkZNjgE+iYecX37nLvd9kYbysyTgFjVBcHa7hsPMvYBFykzbpr157DlQGWQAvpz5a0iAUMESr7/74X6ct5xfuuZ0/N8jc6kOdtVd43TiyiY+sjsxflAGfs0X0JktDST+eQ/owiIyzL/yohxtgX7ok+QV2ANzNBD8yEABzvks5LLztZbSzNXIvzAtNR8lrAK+yOe21uDKcJkWEKbU6sxBa9Ac3wzlFilc4DI1wqV9dWQOMkYJfQkbS1M6X5qfikS+EZP1X3zEhZxyrej7d5keaL3CeKnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=br7AUDaFaVeqJolTbe3+QfAhSAuJrWwC2m13j9Nr5dM=; b=kylisu8goTSrQDLZvIPdPt5B9uOhj6lMAm6T709gZaHrq8svdNRO6DW1cdGdnBzysJVan1GfT2QFMlTQ8wXE5uXtyrT+yDSItLYiB/eqrQuSvLhxu5Stdfc+Iam5EgjRhucNA0EuF1JXGmQlaZv43ng3Cdm4RB4cUou7VJXlz6nluG+VSqfZiAK8F86ppF3VTimI1/UKBxyV3eq65+jUAhUGx8tawpYtviG7cxCevHB6uo8BLu44pz/Hz0NmpdlaJzvD1UieHwJk3E62rjZZDTr9676quVUfCuGKltlmF2E226v4b3NA+Zl/zz8vOec11fqqQaiBLQRb+BPtMXiaWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5538.namprd10.prod.outlook.com (2603:10b6:303:135::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Wed, 30 Mar 2022 23:31:46 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::b1f2:a803:163b:aad5]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::b1f2:a803:163b:aad5%4]) with mapi id 15.20.5102.022; Wed, 30 Mar 2022 23:31:45 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] ctfc: get rid of the static variable in ctf_list_add_ctf_vars () Date: Wed, 30 Mar 2022 16:31:33 -0700 Message-Id: <20220330233135.1762317-2-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330233135.1762317-1-indu.bhagat@oracle.com> References: <20220330233135.1762317-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR03CA0205.namprd03.prod.outlook.com (2603:10b6:303:b8::30) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8e5ed3a-881b-4362-c7e4-08da12a57405 X-MS-TrafficTypeDiagnostic: CO6PR10MB5538:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dXjYNMioHMBGOfDWjMQjUlosfb4vx/E8dzGURALRLbSNq6k5jz2mun51fCwkhKwz/aGNsc3OUZ6v9D83HCFzTwWH7NERvNaxuYZBuoMhIGjzNc1sq4iV8wW70fpLQsfo4pZ7+S/6o/5eUt4+GAIsdavQaa28OtyhO2APCFS5iMAybdiQ6yzjqIPZd6f+BuYWeondXZaIzNXgAGkvBIXi1Jc6Ow6Fin5NI3cROIglTHFCQuxkD7lIWi8pPuyPy+JukANjVEv6bE8njRaRH9HIwwWHYZblsVUM6tus2XZW+Lxg4w2j1jWThkLT+2HjPkxAQN07rzzJrOb20m9l5tIykKcUhzbugnVPaCKZtIer6jiFgizod68VIBf+3gdaMZD8F+JTmmjrPypXjwKV70M5gLy9c7K9w9hL7+eU1rOfOpAmK7qml2zrKLda2bhOiE420btIU2e/LWf9SqIOaqQFo18EaON+YYJx8WgiieYmLFoVpFCemLCqT259QUjZLTDo05dXti8JeBETHX8TwHKZLK+vyHJQsinXPvxwDiSV5/KDNvC6miS15NoEqmCCu3PpGqVQgAFMae4fKwA6u/UT/Sfeg7CyiFndp/WkfMUZX7CRZz1DeZk6cHUi8npabGyf9KKWE/prlY+dcblVAZm6798WIaGJw/HNg1yO9uFWyx2ri3FfKVqi2L8WB+qWUbZ/FrUpgeYop/qvnyu7Al/pFOkhuL5v+m+9szGiteZ83JI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(316002)(52116002)(6506007)(186003)(1076003)(36756003)(6666004)(83380400001)(86362001)(26005)(2906002)(6916009)(38350700002)(2616005)(44832011)(508600001)(6486002)(5660300002)(66476007)(66946007)(66556008)(8676002)(38100700002)(8936002)(26583001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JDWz11i386o/nbyhOcrCAcEx6J5oxXXDA4qBTAg1jYvJAGyDrrofP6GxidASkyf8oIUA+z+/8IDH9tgiMvMl/gkFEQoZjDGSITfUnL48fUw4nhMnfeXKUGiJWFegE1n+S8yb0ycBLtW606KVlWMUjpZXpknk1dunVnKbzUYDI+XM0eAB78uDTuRfgutUR94ecjzuBU52yn/+TCQu31uv68qOHSYCvVpXRcsz6cy4gI4msFRsY2rOI0fjFFqbG7hjrNdXb4u5eRSFN5TzEPhg+Oh0PJl/sW2fKkbyR4HPt2LSvwXFxH/D3lDiwuD1h5XsVFr2w76QsVv/yznb9Skrhgj3OSn4zVLoF4AueLFjkmlly+CwymfhSv0Ak0IWndC7SU7mERh6LVPvuPVd4FXqSCQ2xFyY7bCJ002w1+Ttx3MdBO/i617dm0lE1esLi9RUmavpPVnnyWWnZnaEIjtfMB6WSJnVLs6iN+n3M6NonN/Qw+P8QAd+f3B77iN8aZu2OZk1dZXUAaHPo7s4NgK1nPLEVb+dscaNfetPXTxZcIXLrvjiGJtkWp/qSpBxg/1k+WHEvi2lq9CQ7YUzILEPCrJYyeegDfcjwtiqhNy8XWrZRSQ1izJpJKcRM/Erww/agFhBLm4YsDekq71JjLnnpRCqCdePwLJYRx+cvPOxv+bBJrHV2AExGlP+LSDNL4/AU8Epyz51mF4JEhWRTzVIC+h6U4MbkUy7Vk6zFmJsBuB9WzMU/gxoWHFuCIrITjkuoroXaBOYHB/ZkDyvDpVPU3h7qO0RxFBaWXGWs7sOAnFNQlssMGoFozp/z1b51Y3a0KrLxv1soh4vrci8uQf3VtoDPeTSSq+Czi9CUtyGjVT1g50T0TfIf8Q28WA/UkiUkCLFt298T2C7/+OIVCrT8NXDQButbs5cM7ZGZWnEd3u2b5C9ovxHckomUa/XSssoW5BCWHorH7gM6gzN4rLRxoPTYUTlccBMbis8hru5eq0JC5Q+c0+/zu5mx4YoCsFrilsJzTtRSO/p4SjolYz8HreqICXxCQ11czBjmLnvVH41sN9dFC/TTQAL3qP4c/rIlIL5VFdRDP0jSRT3eCKAiIT/BKohHKVQCrVf5hkaebD76pZI38WLAL6ayMLKe8SvhMX/GcoQY17vaRFB8QaRjrTZaMMUivPcVvA0HB66uL33RaPogmkcU4qR8fv/2H26Ri4zK8a0Owro3a0euqzo5RNTs24O5xVX/UvOmCsvYj/JoAAee3QKjTZ/isrk4Ry7XGrmhrKA8Z9IcBfRS8vdR7+QYbx7BbHCP+WnylGhdBD7yRYDMAN60lPAXrji8xK+6VouaKXituQO8b6e4WbabP+TAcVEZE4wLb0nLGxQOkJcTmp3yjsy+d9ntylgBRE5AqZcwNIkZUPUybMailErZOWZvYxtVimiVR5uP02dIjnVxWXOr+ixmKjPO8n2B6/0Gnq8nNSpZ1nVlcjn6uzaJ8xzyM51rH7On0P6YcbomrM56JZq1AXDbhwuKnw3yJ2RnhYs28P7PGuzVyaelRM/RuKa6T4S6zIyOO0wgDD4iBWvsuWcUky+t6II/3ii3Xk3G01KeyOyewLABqYSXudgktnNG9IljUxm9tdZIFBJSI2GVZGiWdzgvN0wUg1/aOUFz1RvqNgwr+9uf60pttIjosDlSqp/RhhfMDQVvnfk5G+S5Xh3jDifzI5GYXNaHungxAkerq/nMxm/fByGabL/Aw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8e5ed3a-881b-4362-c7e4-08da12a57405 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 23:31:45.7410 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H+O6jyuMnHeB63aPQAVCaE5jWNGSsVMp3i9usBVsL2XQdXbxzga+JydGss/Xcn28JZNKYSR2C4h1YG9UBNj2Ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5538 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425, 18.0.850 definitions=2022-03-30_06:2022-03-29, 2022-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300112 X-Proofpoint-ORIG-GUID: Gbct4UBajKAao2-GmjWrlgdayvOAZA5t X-Proofpoint-GUID: Gbct4UBajKAao2-GmjWrlgdayvOAZA5t X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 2022-03-28 Indu Bhagat gcc/ChangeLog: * ctfc.h (struct ctf_container): Introduce a new member. * ctfout.cc (ctf_list_add_ctf_vars): Use it instead of static variable. --- gcc/ctfc.h | 2 ++ gcc/ctfout.cc | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/ctfc.h b/gcc/ctfc.h index 18c93c802a06..4ce756c728a7 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -301,6 +301,8 @@ typedef struct GTY (()) ctf_container /* List of pre-processed CTF Variables. CTF requires that the variables appear in the sorted order of their names. */ ctf_dvdef_t ** GTY ((length ("0"))) ctfc_vars_list; + /* Count of pre-processed CTF Variables in the list. */ + uint64_t ctfc_vars_list_count; /* List of pre-processed CTF types. CTF requires that a shared type must appear before the type that uses it. For the compiler, this means types are emitted in sorted order of their type IDs. */ diff --git a/gcc/ctfout.cc b/gcc/ctfout.cc index a23d37758019..28a873b2027d 100644 --- a/gcc/ctfout.cc +++ b/gcc/ctfout.cc @@ -173,9 +173,7 @@ ctf_calc_num_vbytes (ctf_dtdef_ref ctftype) static void ctf_list_add_ctf_vars (ctf_container_ref ctfc, ctf_dvdef_ref var) { - /* FIXME - static may not fly with multiple CUs. */ - static int num_vars_added = 0; - ctfc->ctfc_vars_list[num_vars_added++] = var; + ctfc->ctfc_vars_list[ctfc->ctfc_vars_list_count++] = var; } /* Initialize the various sections and labels for CTF output. */ From patchwork Wed Mar 30 23:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1611469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ysi3g3Ph; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KTN8f4hQ9z9sBy for ; Thu, 31 Mar 2022 10:35:30 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E9D6385741A for ; Wed, 30 Mar 2022 23:35:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E9D6385741A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648683328; bh=y15jPu3R8cFM0NEXGFfaGcspH+xns4NypYDOKdTrxQU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ysi3g3Ph/sPhcnnt/k+p3XFa7cEDV2U7O1Y26RfAMgOWP2HyYqtENCaLX4RgK/pkk CWVGmPFQQjaUbBBv/7cLMoJgYCl7qfCy4uFhcrChwdl9b3VBq2BDyufeEtBn8LmPor AS6ow37Nx87s79iWmPHncukXgamcoZjMCeGxCulw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 319EE385840F for ; Wed, 30 Mar 2022 23:31:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 319EE385840F Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22UL8MIV032396 for ; Wed, 30 Mar 2022 23:31:50 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1uctu2ve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Mar 2022 23:31:49 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 22UNMbIS007313 for ; Wed, 30 Mar 2022 23:31:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3f1s979708-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Mar 2022 23:31:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWWqdkOicpIYqAYy5e10bZqilLFDwe3rKzuTFTuxpZ2z47tDzRUPPH9DoE5HaYBaKDB2ARH/0CedKV1B+XDgAax30gpkhjqgif16nrRDFvh1POOqZDsRXd/2bj+Od9P4v2P533dGopiQAhLgj7/LIAFzG83E7+7mo0cdnwWregxrfyIt1GTUEhWZP9NxMNCVFHZxuk09re5qvr1Q0d5EIa5EwTGFNbNryX5yhFy+5J1abI4UBy2wUpCGHmQ/6CP1CgMi/dS1yhpaoSkVZU+hU0zZjRNabp8UN0EOkb1cojfgAtAgkyg2xsb0r7AhrypIg8i1NA3R1EFfAK6h0cBdZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y15jPu3R8cFM0NEXGFfaGcspH+xns4NypYDOKdTrxQU=; b=kycGd+H4R+MtJ4TyZOLsn6cFcEE4hXeEZKvcAqXB08V+DePruURWqJCsi2cLPlYZ0GT1Wa2XPzZdWOpbhYg6b2lpo/F6OtxsMynfyQcf2Rs9OnOVjoYpDpFCWdipS3c2w+hpJWLEF32n8faffUWogUede3w6Ac9M4W6RRqCkw5eALBh6P033VEgOM++vDhhVLklNz7O+fwEjseNWepHgf+Ay//HIbviD1VIWKEJLspOTaEJFpjSMYauz0OQz5iiGbBqFvqEPXIu0SyCA/KFXfCP8JQOISw5RWcuO3WwvHrlc9vrybNbFs7u/EIYxOLb2s1jzbOs0rw77ialxCnShDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5538.namprd10.prod.outlook.com (2603:10b6:303:135::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Wed, 30 Mar 2022 23:31:46 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::b1f2:a803:163b:aad5]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::b1f2:a803:163b:aad5%4]) with mapi id 15.20.5102.022; Wed, 30 Mar 2022 23:31:46 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/3] CTF for extern variable fix [PR105089] Date: Wed, 30 Mar 2022 16:31:34 -0700 Message-Id: <20220330233135.1762317-3-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330233135.1762317-1-indu.bhagat@oracle.com> References: <20220330233135.1762317-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR03CA0205.namprd03.prod.outlook.com (2603:10b6:303:b8::30) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e91af83b-50d4-4552-bfb5-08da12a57481 X-MS-TrafficTypeDiagnostic: CO6PR10MB5538:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hUBw4F3gfJHOUrJPUuXv9GEJtVaNRhj9Ss2Fkp0wKH75clcI8/LckxQDq9+OS2NLgDSUlFV48q6Kxsj4NMdO0Vp5/DqZSv11pkfgOuKPBkOSxmpFZMhov5Y3AN1YewovI3AIGG54fPXWChSIoKGo2o62AE9wnZjYu9aoTjw8/E3sHHxU2QW/duW8PYlq7F0XXzK2gUdZ6THMqeA9DIjTwGzEKK5yQCJCnklhEgQPV6YEtmL49k7FeaC62LRTd1gq3P6QjJRaAIoA+LnfXWcebN4YUtmC1WWv8hAcKf5QcJKPoukU0kg/n4C7Bj13Lf52CysslFzgtcjjAax4Zc2VOKo5nD04ri3bRIP85/adZ0Y6Z32qu/2aokGOXhGfaNvPzk6eP2Gl9X1QcjWf1EcmgXUBtVJ/8OIBr5AncC5IeX17h3TcOgzor2aDUeasTfCOBK1pOWxPXrxuIYCPK+Bc9UStLVYJS8lvEpQyqiMKOaHYm2t5ep3weXAXR3dQlgq+iiPRGACqwN10LZEgFEFSIT56QezVk/SuMF1nvqE8vWCivnzW4CDHdUh9o9E8C938Z7fZDYR2t6MtSx0bHuQ1/tUfxIcDQRqUI2hVRX74RpARMtsFQbLTjht0YgLprU4HXMnFs+FFmlF/e6BJFOl/84o/OWQJWMklXlCEcVL0+XlMsBjFcabJbFjTM/NEaRzFhYfUmyWgqbLBE8AuirRBDg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(316002)(52116002)(6506007)(186003)(1076003)(36756003)(6666004)(83380400001)(86362001)(26005)(30864003)(2906002)(6916009)(38350700002)(2616005)(44832011)(508600001)(6486002)(5660300002)(66476007)(66946007)(66556008)(8676002)(38100700002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Act8Hqbpm0Y8jY87S55P0/60qTwRF1NTOPjcZZizpV6dh3PEwK4PlP0yssEAtp/u/v4lsrM+qv8GVJPt+rNwTPW4Q0XwZCeLWlRoqukSi11XAv8XtE578DIXkr2/SGViBvLTyVuCXCl4nzcfMWdng4q1tZkR1yKZ7D0sMu3NAI3TQoMOgh1NO8BHb4A+RrZZdbN9dgZzP05A3oOmJVEMXmb7G4qvMY/6hIDffI2JHys/RbTtoM88Tw/XhbPxem8PZmhykudh5zbOpmOJzz2tZkoLGoi6MUeFDpZfxWYm9hvcHwZTXD5iyLJawZ5ZzwzWAvhoooAMyAabXe1VhM5RKd1Vz+8feXdxD/MCvnSt4GORcS5LuaxbY/PKCH50Rqu7p2JMwroAQWnklfcLDdjz9jsAYwhY5t4baIu9lMTLijp5NlO4kuQWoO1g20L0n7Ld8uFCucyOqJca9tp0dO8+RIfKYWyVsZBoWp0hovZ0Y5bqn0SZ9mlrZn8h8c9NmQ2UYDStI0hkAq+0ManQhkRtJ+DBHaH7XlDXYvBHH3/5QxWxFnnKefQkwF/02w2k+SX3spgUfoiFEZIx9e/hZV25sPpQLWtVLIXyBO4TTUfSkThey9m7aQqpOFqgDN87SMP0Rs6lX7u5zxLm3UkET/kow/xXC6VMPxVjHpJX4/qB1J5mvG++WENtYPp1cui6YEpt2ZL3bDzgnAVYjEHTFVCLoDLm8Y/cu6griP81tggtYzC64mxcuysCF8/ci9+jQDE9oBd0oAcIjLElPv+9PhR9MjkWO0G8/E38fenyQebYKW7fJu5WgBbpwBK1qfQYO4K8NIkmqKz3idBFKinF+vawS6qXSvgYaXGDnIohOXYu1Y1R95UWzaWiEITzxrkj3IlqB6WmZVPQgPtI6S+sbRVljUm9RwZJcLT7lXrUZO+ip1dn9Br3bZy3mHXwsExLwyPckircZ27rTXqb28iosoLwTXacAG4NQzIeNH4aXpEoe6BHvcJnuA6y52NqWirORej88vnxgZXU+SMPoOeuDTUK8swP9CVaWqdWbzbk5AJ1+03VPKZ0BWA7NkdueOMohU9OQkxQaG7EMeyb6/daQaRn2Yv2XjyhuR+hjWDcHSKWb5ynyOB9+d4FME+Nbo2SVI/iL+yAZLT+WTY2OybOG90ROqYeodZTL/3qX2qo0/HrGOUFnuj3ihyc3FVYF4Js9H800Yek2mu21eM6oTLyOzw4t1GEMsTGXbjW8DT9efbgKLhOSPgBPCgmMIiEQzN8qms1LfIb0Kcg2HN5IIlIP5Ixl4Bx4slvWMQTVKi6JFjk6wdWt0gLVbG6zq/2iwXV2iXX7MppK/zzv0lg1QagDVoXjdcopCMnVgVlZq0tjqouEC/915hiyjejWzudbTy1iUn6jLWlYiDu/W/NAGcNJuxKGKTGC/YIPQxzTRumrjjqimMJ8qF5sKE0m+/+UDW6LyEc2Scp6jSFE7+B/t0nsmFeEoBUxfSPhvfnL2ohUuXxJO6YA2GyxZvKMdy5x6rshQ1rqwCe05Xq48t7+ajD59u4bKa6qr4OBTb+6MmQjvwNe7YcwSJYtBvP3HIzxiYzrE5hJ/z/GMI6YnXrtvMXHjXlkM7SwZG9LUVPIhD7U6ijEWk0DQWHeFMo4RL5LXtcu5sOViPbyzBVLHjO5T8wGihZUG0RjpO6+sJHGIbmNV/+Z4Vb6nwT4NNIGPJGaHPKIilEgDzq8uP4j7gBssQYaWhNZA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e91af83b-50d4-4552-bfb5-08da12a57481 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 23:31:46.1941 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sxuW1mWrOqV7l3bpiorV6/ogss4L/xdkDARJitU2HKCVuNw5oCRwS1x0J9MlVLIMotaDHXeoFz1JOFj1ezH6nQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5538 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425, 18.0.850 definitions=2022-03-30_06:2022-03-29, 2022-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300112 X-Proofpoint-ORIG-GUID: rO37bePpgCi_9cukNHDzHUZ7iAIecLZ5 X-Proofpoint-GUID: rO37bePpgCi_9cukNHDzHUZ7iAIecLZ5 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The CTF format cannot differentiate between a non-defining extern variable declaration vs. a defining variable declaration (unlike DWARF). So, the correct behaviour wrt the compiler generating CTF for such extern variables (i.e., when both the defining and non-defining decl are present in the same CU) is to simply emit the CTF variable correspoding to the defining declaration. To carry out the above, following changes are introduced via the patch: 1. The CTF container (ctfc.h) now keeps track of the non-defining declarations (by noting the DWARF attribute DW_AT_specification) in a new ctfc_ignore_vars hashtable. Such book-keeping is necessary because the CTF container should not rely on the order of DWARF DIEs presented to it at generation time. 2. At the time of ctf_add_variable (), the DW_AT_specification DIE if present is added in the ctfc_ignore_vars hashtable. The CTF variable generation for the defining declaration continues as normal. 3. If the ctf_add_variable () is asked to generate CTF variable for a DIE present in the ctfc_ignore_vars, it skips generating CTF for it. 4. Recall that CTF variables are pre-processed before emission. Till now, the only pre-processing that was being done was to sort them in order of their names. Now an additional step is added: If the CTF variable which corresponds to the non-defining declaration is indeed present in the ctfc_vars hashtable (because the corresponding DWARF DIE was encountered first by the CTF generation engine), skip that CTF variable from output. An important side effect of such a workflow above is that CTF for the C type of the non-defining decl will remain in the CTF dictionary (and will be emitted in the output section as well). This type can, however, be pruned by the link-time de-duplicator as usual, if deemed unused. 2022-03-30 Indu Bhagat gcc/ChangeLog: PR debug/105089 * ctfc.cc (ctf_dvd_ignore_insert): New function. (ctf_dvd_ignore_lookup): Likewise. (ctf_add_variable): Keep track of non-defining decl DIEs. (new_ctf_container): Initialize the new hash-table. (ctfc_delete_container): Empty hash-table. * ctfc.h (struct ctf_container): Add new hash-table. (ctf_dvd_ignore_lookup): New declaration. (ctf_add_variable): Add additional argument. * ctfout.cc (ctf_dvd_preprocess_cb): Skip adding CTF variable record for non-defining decl for which a defining decl exists in the same TU. (ctf_preprocess): Defer updating the number of global objts until here. (output_ctf_header): Use ctfc_vars_list_count as some CTF variables may not make it to the final output. (output_ctf_vars): Likewise. * dwarf2ctf.cc (gen_ctf_variable): Skip generating CTF variable if this is known to be a non-defining decl DIE. --- gcc/ctfc.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++-- gcc/ctfc.h | 6 ++++- gcc/ctfout.cc | 24 +++++++++++++------ gcc/dwarf2ctf.cc | 18 ++++++++++++-- 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/gcc/ctfc.cc b/gcc/ctfc.cc index 6fe44d2e8d49..f24e7bff9487 100644 --- a/gcc/ctfc.cc +++ b/gcc/ctfc.cc @@ -179,6 +179,40 @@ ctf_dvd_lookup (const ctf_container_ref ctfc, dw_die_ref die) return NULL; } +/* Insert a dummy CTF variable into the list of variables to be ignored. */ + +static void +ctf_dvd_ignore_insert (ctf_container_ref ctfc, ctf_dvdef_ref dvd) +{ + bool existed = false; + ctf_dvdef_ref entry = dvd; + + ctf_dvdef_ref * item = ctfc->ctfc_ignore_vars->find_slot (entry, INSERT); + if (*item == NULL) + *item = dvd; + else + existed = true; + /* Duplicate variable records not expected to be inserted. */ + gcc_assert (!existed); +} + +/* Lookup the dummy CTF variable given the DWARF die for the non-defining + decl to be ignored. */ + +bool +ctf_dvd_ignore_lookup (const ctf_container_ref ctfc, dw_die_ref die) +{ + ctf_dvdef_t entry; + entry.dvd_key = die; + + ctf_dvdef_ref * slot = ctfc->ctfc_ignore_vars->find_slot (&entry, NO_INSERT); + + if (slot) + return true; + + return false; +} + /* Append member definition to the list. Member list is a singly-linked list with list start pointing to the head. */ @@ -666,9 +700,10 @@ ctf_add_member_offset (ctf_container_ref ctfc, dw_die_ref sou, int ctf_add_variable (ctf_container_ref ctfc, const char * name, ctf_id_t ref, - dw_die_ref die, unsigned int external_vis) + dw_die_ref die, unsigned int external_vis, + dw_die_ref die_var_decl) { - ctf_dvdef_ref dvd; + ctf_dvdef_ref dvd, dvd_ignore; gcc_assert (name); @@ -680,6 +715,24 @@ ctf_add_variable (ctf_container_ref ctfc, const char * name, ctf_id_t ref, dvd->dvd_name = ctf_add_string (ctfc, name, &(dvd->dvd_name_offset)); dvd->dvd_visibility = external_vis; dvd->dvd_type = ref; + + /* If DW_AT_specification attribute exists, keep track of it as this is + the non-defining declaration corresponding to the variable. We will + skip emitting CTF variable for such incomplete, non-defining + declarations. + There could be some non-defining declarations, however, for which a + defining declaration does not show up in the same CU. For such + cases, the compiler continues to emit CTF variable record as + usual. */ + if (die_var_decl) + { + dvd_ignore = ggc_cleared_alloc (); + dvd_ignore->dvd_key = die_var_decl; + /* It's alright to leave other fields as zero. No valid CTF + variable will be added for these DW_TAG_variable DIEs. */ + ctf_dvd_ignore_insert (ctfc, dvd_ignore); + } + ctf_dvd_insert (ctfc, dvd); if (strcmp (name, "")) @@ -900,6 +953,8 @@ new_ctf_container (void) = hash_table::create_ggc (100); tu_ctfc->ctfc_vars = hash_table::create_ggc (100); + tu_ctfc->ctfc_ignore_vars + = hash_table::create_ggc (10); return tu_ctfc; } @@ -952,6 +1007,9 @@ ctfc_delete_container (ctf_container_ref ctfc) ctfc->ctfc_vars->empty (); ctfc->ctfc_types = NULL; + ctfc->ctfc_ignore_vars->empty (); + ctfc->ctfc_ignore_vars = NULL; + ctfc_delete_strtab (&ctfc->ctfc_strtable); ctfc_delete_strtab (&ctfc->ctfc_aux_strtable); if (ctfc->ctfc_vars_list) diff --git a/gcc/ctfc.h b/gcc/ctfc.h index 4ce756c728a7..001e544ef083 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -274,6 +274,8 @@ typedef struct GTY (()) ctf_container hash_table * GTY (()) ctfc_types; /* CTF variables. */ hash_table * GTY (()) ctfc_vars; + /* CTF variables to be ignored. */ + hash_table * GTY (()) ctfc_ignore_vars; /* CTF string table. */ ctf_strtable_t ctfc_strtable; @@ -394,6 +396,8 @@ extern ctf_dtdef_ref ctf_dtd_lookup (const ctf_container_ref ctfc, dw_die_ref die); extern ctf_dvdef_ref ctf_dvd_lookup (const ctf_container_ref ctfc, dw_die_ref die); +extern bool ctf_dvd_ignore_lookup (const ctf_container_ref ctfc, + dw_die_ref die); extern const char * ctf_add_string (ctf_container_ref, const char *, uint32_t *, int); @@ -430,7 +434,7 @@ extern int ctf_add_member_offset (ctf_container_ref, dw_die_ref, const char *, extern int ctf_add_function_arg (ctf_container_ref, dw_die_ref, const char *, ctf_id_t); extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t, - dw_die_ref, unsigned int); + dw_die_ref, unsigned int, dw_die_ref); extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree); extern ctf_id_t get_btf_id (ctf_id_t); diff --git a/gcc/ctfout.cc b/gcc/ctfout.cc index 28a873b2027d..3cf89b94f993 100644 --- a/gcc/ctfout.cc +++ b/gcc/ctfout.cc @@ -212,6 +212,13 @@ ctf_dvd_preprocess_cb (ctf_dvdef_ref * slot, void * arg) ctf_dvdef_ref var = (ctf_dvdef_ref) *slot; ctf_container_ref arg_ctfc = dvd_arg->dvd_arg_ctfc; + /* If the CTF variable corresponds to an extern variable declaration with + a defining declaration later on, skip it. Only CTF variable + corresponding to the defining declaration for the extern variable is + desirable. */ + if (ctf_dvd_ignore_lookup (arg_ctfc, var->dvd_key)) + return 1; + ctf_preprocess_var (arg_ctfc, var); /* Keep track of global objts. */ @@ -276,16 +283,16 @@ static void ctf_preprocess (ctf_container_ref ctfc) { size_t num_ctf_types = ctfc->ctfc_types->elements (); + size_t num_ctf_vars = ctfc_get_num_ctf_vars (ctfc); /* Initialize an array to keep track of the CTF variables at global - scope. */ - size_t num_global_objts = ctfc->ctfc_num_global_objts; + scope. At this time, size it conservatively. */ + size_t num_global_objts = num_ctf_vars; if (num_global_objts) { ctfc->ctfc_gobjts_list = ggc_vec_alloc(num_global_objts); } - size_t num_ctf_vars = ctfc_get_num_ctf_vars (ctfc); if (num_ctf_vars) { ctf_dvd_preprocess_arg_t dvd_arg; @@ -299,8 +306,11 @@ ctf_preprocess (ctf_container_ref ctfc) list for sorting. */ ctfc->ctfc_vars->traverse (&dvd_arg); /* Sort the list. */ - qsort (ctfc->ctfc_vars_list, num_ctf_vars, sizeof (ctf_dvdef_ref), - ctf_varent_compare); + qsort (ctfc->ctfc_vars_list, ctfc->ctfc_vars_list_count, + sizeof (ctf_dvdef_ref), ctf_varent_compare); + /* Update the actual number of the generated CTF variables at global + scope. */ + ctfc->ctfc_num_global_objts = dvd_arg.dvd_global_obj_idx; } /* Initialize an array to keep track of the CTF functions types for global @@ -476,7 +486,7 @@ output_ctf_header (ctf_container_ref ctfc) /* Vars appear after function index. */ varoff = funcidxoff + ctfc->ctfc_num_global_funcs * sizeof (uint32_t); /* CTF types appear after vars. */ - typeoff = varoff + ctfc_get_num_ctf_vars (ctfc) * sizeof (ctf_varent_t); + typeoff = varoff + (ctfc->ctfc_vars_list_count) * sizeof (ctf_varent_t); /* The total number of bytes for CTF types is the sum of the number of times struct ctf_type_t, struct ctf_stype_t are written, plus the amount of variable length data after each one of these. */ @@ -595,7 +605,7 @@ static void output_ctf_vars (ctf_container_ref ctfc) { size_t i; - size_t num_ctf_vars = ctfc_get_num_ctf_vars (ctfc); + unsigned int num_ctf_vars = ctfc->ctfc_vars_list_count; if (num_ctf_vars) { /* Iterate over the list of sorted vars and output the asm. */ diff --git a/gcc/dwarf2ctf.cc b/gcc/dwarf2ctf.cc index 747b2f661072..a6329ab6ee48 100644 --- a/gcc/dwarf2ctf.cc +++ b/gcc/dwarf2ctf.cc @@ -808,12 +808,26 @@ gen_ctf_variable (ctf_container_ref ctfc, dw_die_ref die) if (ctf_dvd_lookup (ctfc, die)) return; + /* Do not generate CTF variable records for non-defining incomplete + declarations. Such declarations can be known via the DWARF + DW_AT_specification attribute. */ + if (ctf_dvd_ignore_lookup (ctfc, die)) + return; + + /* The value of the DW_AT_specification attribute, if present, is a + reference to the debugging information entry representing the + non-defining declaration. */ + dw_die_ref decl = get_AT_ref (die, DW_AT_specification); + /* Add the type of the variable. */ var_type_id = gen_ctf_type (ctfc, var_type); /* Generate the new CTF variable and update global counter. */ - (void) ctf_add_variable (ctfc, var_name, var_type_id, die, external_vis); - ctfc->ctfc_num_global_objts += 1; + (void) ctf_add_variable (ctfc, var_name, var_type_id, die, external_vis, + decl); + /* Skip updating the number of global objects at this time. This is updated + later after pre-processing as some CTF variable records although + generated now, will not be emitted later. [PR105089]. */ } /* Add a CTF function record for the given input DWARF DIE. */ From patchwork Wed Mar 30 23:31:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1611465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=LUVf5I3M; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KTN7609ybz9sBy for ; Thu, 31 Mar 2022 10:34:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 173BC383E824 for ; Wed, 30 Mar 2022 23:34:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 173BC383E824 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648683248; bh=anQAncxqiji/18HtyEjtOM82O9yMT0G4Qc5Q8dDJxuE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LUVf5I3MG13lrOj6EnAa9R3ervbiRKkqCS6dOOw3jCtba9u6GDn0B8gSky3cn6iR7 VixnKWtju7CK/XCA6eW9TQHyg4dl2DgWQyxjJaQw80bmhW4a4tkqrPsRstrNOBDzGX WOMzkWNuT5v1tsTLTJ157rqkLXxXwDixX61+KgQ4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 89021385801B for ; Wed, 30 Mar 2022 23:31:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89021385801B Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22ULUDZs030420 for ; Wed, 30 Mar 2022 23:31:50 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1se0jwa5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Mar 2022 23:31:50 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 22UNMbIT007313 for ; Wed, 30 Mar 2022 23:31:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3f1s979708-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Mar 2022 23:31:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LrwglVF/b9CRseCNBLFwvFQgGrsij/ls/ApEhGkelKFJ3b7oxea0z7PYGxB7PQCVSut603de9q7cIb/Q2/nmIcYJvfzcVC3mNEB4PTRKFyJgHjAz704zWuwqQdkXA30HHkYcj8p4g6nhDxw6zqsW1oWvVdIS3SJwKXJ5ubliSH0Uym/uKFDsCFoUZVisktImkozgvBednbIcfcliiwrjlCQQBkrZV83k/F/C2wzdAIWjuygHsiS8eLWRnktCDbsZ/1qFokgrENF2B/QDKc7RNbluFI307EwmRu8WhUHlW0KON5LhJTJzpd1LJpEb5Rxv/REuSrGfif8TOVHRN8ZaOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=anQAncxqiji/18HtyEjtOM82O9yMT0G4Qc5Q8dDJxuE=; b=Lb1ymnuqb7LlOsh9BzAKGxhvlCiRFm/733VSHvXsG9jI6Ieihd9KFJ1EIy2YI45YZSkAFMfvuSj0WJtcKO12xGddBHqVaxh9Z4DKpBDBjEMcXiO+EhzG2dn5qhlNbn4Zl/BCa2LkkesI5sP1Gcrmoze+KweAs5+45tLGKFoLDnxfshk7fQQiMwDPqNXHVlSQyPrQtmewwj4bu5e06bW3GfQCV8qBkWAdkX01Sve/7J0EW+OKIwdS930U9PiUf2q9RZ1BTQVJQhgP3atxTJW+5namVyom3RtxM6R5O3NvBgUZkXLS7H+CR/GbdtSg5ejAvhqg/pH8Jj5Tct0cjGmt+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5538.namprd10.prod.outlook.com (2603:10b6:303:135::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Wed, 30 Mar 2022 23:31:46 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::b1f2:a803:163b:aad5]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::b1f2:a803:163b:aad5%4]) with mapi id 15.20.5102.022; Wed, 30 Mar 2022 23:31:46 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/3] Refactor and update CTF testcases [PR105089] Date: Wed, 30 Mar 2022 16:31:35 -0700 Message-Id: <20220330233135.1762317-4-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220330233135.1762317-1-indu.bhagat@oracle.com> References: <20220330233135.1762317-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR03CA0205.namprd03.prod.outlook.com (2603:10b6:303:b8::30) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb345de3-4b38-4d3e-803e-08da12a574c4 X-MS-TrafficTypeDiagnostic: CO6PR10MB5538:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d3uBb59hIMKf5KwtABWbHvFvbx+ijqLPBqqBPt3nBWUC7FTxB3AzAThSDRyT+JFrrwZgrny6MD1Aw3f6YekGBiWFSvEkjjRBsWB7D1ePSARjDdcDu+E+U5A7LWJyIzgIdC36zSJaWKp4fbGvr/zQJntkAsAhGX09XsgpbKwtVcxBYVW3WtSDwTgwnaYNE6CvQ1jyorGf/eJsPm6v49uud5PjjfRfCR2xAB8inMyaYVn0usBzx1bkoUD4nHpnJngY6q/ezDma2jVCpSmSOpYLs2Ia7AvZw866eigy+0k5uwO+4ahhEywpoVRRtXHiTVSodjdJx8ZcnQ/G8D9LUaaIV4hxAhTKiAUY1KnHc5rV+7QfryJLNEaPftVS9+SZ/EMLR6IokfxhRoSDSWP2WNxSagmRdLFtr6Xbf6h5ry0brxuiL0/bc1Q/vhXuV4vuuka6UP9oThMquLXbvvwVAGYIY5vfsr2PETDNYpMaQt+CCf6ThY7FKG1Ujlal8Ys1c7kKony+r8distANXvIXANZzZPUkN1kTqFArD+0IpgrvmXiHS/w3pruMx3xF/oMA/rKskEiqdBf9DrVKN5igd0GmoRXNZRh7QEpQf4IQw4I3dVZnkxaIdsM81x0SQMX+xlaKtuJI7JMO1hyC/rSKkTZ/KyTMb5Njl+2xhjJb3Y24i3y38cuyHqibcnB/6kAWA/vOPQv3OwjtlS2W9LbZsqvHUUr3vycoxAWgWOEy6KQDSqvgnjyDYoOI+yVFKld/xxVmmL3VRDL9n+fLNK1RGJtmMKXeU+c+8mTbt+qMiLG+M7Ph4MMjCOGLKOEyKMSu1+0vmIRUjxmbaTv2rmRSGuHlZg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(316002)(52116002)(6506007)(186003)(1076003)(36756003)(6666004)(83380400001)(86362001)(26005)(2906002)(6916009)(84970400001)(38350700002)(2616005)(44832011)(508600001)(6486002)(5660300002)(66476007)(66946007)(66556008)(8676002)(38100700002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MNbkcQZzDHmACrW85OCUdNYwG/jxXifLW7e3iTTaHqnF3V21bJHt9ATIMiRPZ7z3GtvVT0s/aWbJIRiF+JXI8EYJam9RIdyv6YTFy4gYHv/AThQ0/sfReG1gBpENnQzj9CSXq2tHu+0YltdHkHrJtaRkm9gyVvIaQtExCAeJM5T/0n0XgOuRf/tJPK0ZQckJ2HzKcF/o7/nbXVc2Mh99Vk3mRJUOptez2LptpByQXzkEwaGqKsPCldpjqq00GIqaAdKh5XOPetqXj3qm9vDpRMFADU1Oamzf0bUKmqpxSj6pv5dPatP1Jw9gKBV9lUAs9DiGzHfMdwkBmK3tEKuSLjxateVl+BdSANJFdYxMueadNXa4wkeTZxdP8gH7QSXyxhhGRIQTVtyFnjAgAT9jvzUU5s/93fopnfjaJOWJ945HQF28jiMQX5qsVWjCaK7K88q50x63xoNf9PxlA5gEy8eOZr/03AOb45jKK9TOrJeD3Z3ktRvKgCYh6Kbf8z3fljqwAcqdaFxk6hF5e7M7uvaCAPL84rRY6ZxZiTnxBxPY+25SbMceLEnGzGiH+qKWTvlXDS/2JCVwZpYPNwQ3grEzPxjRGXvvdhZuULtYQMnl4MntTRKoEkEttsLpbhHlcvmxa24L4aSLwatJrJgenNFVd262gB4b5UFzkZRPLtCBSSCqwc/rEBugi75JO6CAeP3EnAJScyuIdSUGsTTfydlo562NKQxnzQjK42HF3GHhst+UXM0Y94epzNkcj0FaRjz0crX04Bn1VDG4wmDSof1spI2DblAFQn5VPD49CtLDJQbTagH/upaF1WzkzhuL8YBTnj7pHv1KTdLapi6W+f6wWWPs6xPkmJcj+7lPDMY5z7+A4Wv9HSLje+nRX/iH4E0jk9Kgb2MdCQCRAwVz7yucvMdvxMIs7flAfDQE20cR60s+UumoTZN800v/n6prLkxB/i1m43sg/c17c/BP/jSqPAVUgZJBQFwpoHbzXoUjKcIXEw30lsTObFL2KaRMOb7NHFxh1m/cSIK+tCPTru0LblqjuQT2BpYCQSa/mx+l101TkU8VuU4kSWuoALrQ7jNpKZ4AYxYMIcRsg5ZjUq6kXgK+DIQEi3BS4Q/8bOZUpDMZCErS0Tsoj31AioK2KByQ9t3xSKRQxrrmQadbGoZpOLcfL4qVxDLVvf8c4LrY7rJ/z/Xe0oP/bwQ3X8ZZl/ibnxiFD34ruT8Wn4dDuXU81T0oiJOmYIJL4Pp76JfQB/hGkWcDm5jH+Lg7o7Hsir7rJKc/+MjJ8QCOg+TyViwD7S333eMa24jUX4jALSeATiXCr1QT7PO4DvYF56ET6WWbPZDPbu5BfMohi5ZuDRPxt19nBJpI+70FUtXYcmc6WEFjYGzUuHH2dzXoDNqgNIAUs5UhYpDjwIB/JfkpBt37mCiqoyuXLIOiyh968Bnd35hjBCIBHiaeZH6ywn3RBJaF2+udnbsGJEyrYiHRt7QR0FDgkmJHD9D14hUGeOX6WTTdnzKWpYZ/VGPLKvoOf5riwqqWnAv88wgb1mUPywTNn8EHZyf9H/nEHQ/8cJqh0gXYhGXLBYsXuzC1ut3a6uZfevsEHQy7oypbV9cPjnvF2A6N3Rhu1QCzn3e5jFpGLS3xa/nT3Hrplrps4oIOAOwBZb2Ynnpfn7VUgBAt8GYA5Gllg1IKUZUgnVExC8VoGiFT/+RLijKEJ12tEDeIC0Glj4/uFFYbizugCY3bDA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb345de3-4b38-4d3e-803e-08da12a574c4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 23:31:46.6160 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wxt1gAnL9KomcQtA2cBRceA+XEq31EmieL3i3/0bnck8b5IN+bE+5yIupUzcDKzN11kFLtVgq5998UhNYGWp6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5538 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425, 18.0.850 definitions=2022-03-30_06:2022-03-29, 2022-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300112 X-Proofpoint-ORIG-GUID: -dNEUhNaH5PcLf2OGO4uKy_ZNDnb5O1_ X-Proofpoint-GUID: -dNEUhNaH5PcLf2OGO4uKy_ZNDnb5O1_ X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This commit splits the ctf-array-2.c into ctf-array-5.c and ctf-variables.c with the following responsibilities: [1] ctf-array-2.c: Test CTF generation for unsized arrays. [2] ctf-array-5.c: Test CTF generation for unsized but initialized array. [3] ctf-variables-3.c: Test CTF generation for extern variable with defining decl. Earlier all three tests above were being done in ctf-array-2.c. Further, the checks around [3] were very loose in the original version of ctf-array-2.c in that the testcase was only checking that the types are as expected. The compiler was emitting two CTF variable records as follows: Variables: _CTF_NEWSTR -> 5: const const char [0] (size 0x0) -> 4: const char [0] (size 0x0) _CTF_NEWSTR -> 8: const const char [8] (size 0x8) -> 7: const char [8] (size 0x8) This is incorrect behaviour as it creates ambiguity. The testcase ctf-variables-3.c now has added checks that only one CTF variable record is expected. 2022-03-30 Indu Bhagat gcc/testsuite/ChangeLog: PR debug/105089 * gcc.dg/debug/ctf/ctf-array-2.c: Refactor testcase. Move some checks ... * gcc.dg/debug/ctf/ctf-array-5.c: ... to here. * gcc.dg/debug/ctf/ctf-variables-3.c: ... and here. Add additional checks for one CTF variable and one CTF object info record. --- gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c | 22 ++++++------------- gcc/testsuite/gcc.dg/debug/ctf/ctf-array-5.c | 17 ++++++++++++++ .../gcc.dg/debug/ctf/ctf-variables-3.c | 22 +++++++++++++++++++ 3 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-array-5.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-3.c diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c index 2a19da050fe7..4721c4fb2f97 100644 --- a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c +++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c @@ -5,34 +5,26 @@ TBD_CTF_FORMAT_OPEN_ISSUES (1) - This testcase makes a note of the case of a probable misrepresentation. - See Note 1 and Note 2 below. + See Note 1 below. In the CTF section, these types are encoded as : Variables: - _CTF_NEWSTR -> 7: const char [0] (size 0x0) - _CTF_SECTION -> 6: const char [5] (size 0x5) - b1 -> 2: int [0] (size 0x0) - b2 -> 3: int [0] (size 0x0) + b1 -> 3: int [0] (size 0x0) + b2 -> 5: int [0] (size 0x0) Note 1 : There is misrepresentation in that b1 and b2 are specified differently by the user. - Note 2 : It is arguable though whether the representation for - _CTF_NEWSTR is incorrect. */ + + In this testcase, two CTF array records each of type int [0] is expected. */ /* { dg-do compile ) */ /* { dg-options "-O0 -gctf -dA" } */ -/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 5 } } */ +/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 3 } } */ -/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cta_nelems" 1 } } */ +/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 2 } } */ static int b1[] = {}; int b2[0]; - -const char _CTF_SECTION[] = ".ctf"; - -extern const char _CTF_NEWSTR[]; -const char _CTF_NEWSTR[] = "ctfinfo"; diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-5.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-5.c new file mode 100644 index 000000000000..ec504412ef56 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-5.c @@ -0,0 +1,17 @@ +/* CTF generation for unsized (but initialized) arrays + + In this testcase, one CTF array type record of size 5 is expected. + + Variables: + _CTF_SECTION -> 5: const const char [5] (size 0x5) -> 4: const char [5] (size 0x5) + +*/ + +/* { dg-do compile ) */ +/* { dg-options "-O0 -gctf -dA" } */ + +/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 1 } } */ + +/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cta_nelems" 1 } } */ + +const char _CTF_SECTION[] = ".ctf"; diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-3.c new file mode 100644 index 000000000000..8aea1e82749e --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-3.c @@ -0,0 +1,22 @@ +/* CTF generation for extern variable with defining and non-defining decl + in the same CU. + + This testcase checks the case when a non-defining decl is followed by + a defining decl for the same variable. See PR debug/105089. + + In this testcase, although two CTF array types are generated, only a + single CTF variable and a single entry in the CTF object info section + are expected. */ + +/* { dg-do compile ) */ +/* { dg-options "-O0 -gctf -dA" } */ + +/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */ + +/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 1 } } */ +/* { dg-final { scan-assembler-times "\[\t \]0x8\[\t \]+\[^\n\]*cta_nelems" 1 } } */ +/* { dg-final { scan-assembler-times "ctv_name" 1 } } */ +/* { dg-final { scan-assembler-times "objtinfo_var_type" 1 } } */ + +extern const char _CTF_NEWSTR[]; +const char _CTF_NEWSTR[] = "ctfinfo";