From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 733583857727 for ; Tue, 11 Jul 2023 21:59:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 733583857727 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BICxqA019634; Tue, 11 Jul 2023 21:59:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=wRlVaPcq0OiU0pL3k/GuNeE5PwqmwTWHrhnrHN0QXjU=; b=LZA5buQGrqKaiJ+/8+HrmCW5YaiFkDDJHtjWEMC8TRlHAClo7Iw1JLDMZ9B9JhQVugR2 Az7Oa1ryUy/zGobqMtAcG9V1NphTFF9WA4vnZ/JW+L4KRYuODv8Qk0b5JfnJ42gNL9f1 bxXTN8einhTkorU+2t2qZ8oWlJqFgIMyKjWPCDTNXVurKiDwZuaRt/aOnJ5RJSXkg+QH wNK4EZQYgFeDi1M7pwZYmsUy/lGK7zJHlZVZikkiQbqojO5HvymF/LZ1YgsdeCichEXf x5sgKUP34AtPDWdfANdHfB8Wj3+00PDMRwFiLY/RZxvW8uezFhjWulSdik+81oZMOVI4 5Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rrgn7ut7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 21:59:08 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36BLngoU000704; Tue, 11 Jul 2023 21:58:56 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rqd29sx51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 21:58:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cU2ChDX3AmUeSwFzu7vIHq5fSLcdxpl/lgP5oQ8cwEBc0M8uNaFzxgPoHJOGDJUnMzlOvLsfv7FTNC3XIiwmZ46QW4/dxLD6ku4hPcYfG1pKLcss/BCiQhjv2fu9Cz5YUiep4oQmwH2MDekAR0kv0Wfpma/3Lo+jQ+TrzZelcm9GfwKsYUfzLhZI9hF6Q4FBzoZ4QDiVo2U1krZpiK7uwqOJlne0KUHCi6GGF4UqlTBaQGcffbMh2UEUDCu/ehKDuaETMKYZdQ4d+uceMP/vBkvyk9jLiCmljGG3GKG2yI0GmgM7dZl4FxwaZEMuNMOlK05wZInT9gvnWd8mqeumxQ== 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=wRlVaPcq0OiU0pL3k/GuNeE5PwqmwTWHrhnrHN0QXjU=; b=FhFEemDHwu0lpyTCt26U8Avs4Po11jksHdpHCoUuOfsO9LEhRSkm09IZcj6ozEpVcUIcxNEglK24I1CRZVN9DeyZsxgmkY0YaP+56G4j9c/PBvqPod+KB5Q7J8ADbHwH7Si6rN5fKMMMzxJ5mtzXqKPyx3Oz71o7wvagsJpz++6M56B4ADhYZRk2dqCygLIPaT2YmOlO/vIAQ5XmCmih2zuSay/v4amZ9gOFpArsv5JI2tUK+tsW1dqWZoIjTePDuNhHrHFIKsb3XGvV4+rIHgCL1pj4uKsXkG4hQeeb+qaLqBF36AC5IqQxovCp+ECbOhle6OzRzF9bmIZSJolNMw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wRlVaPcq0OiU0pL3k/GuNeE5PwqmwTWHrhnrHN0QXjU=; b=xh2QZWMjAGG8jWvTlspzuXkP+sVh0oypxUrdm40FVq8vgmQNDsYQ/K5+q83FjcaAiaNP3SjVPkDLOlIHt4ku0Oqp7JvbsUyLJ+Q1dzFR72SKY8JMNTL5Y7mnbDU3D3qjKJ8dThUsB25+8rxTce6iXp010spMrj2Hl6rtAovfKjg= Received: from MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) by CO6PR10MB5650.namprd10.prod.outlook.com (2603:10b6:303:14f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 21:58:54 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::1797:59c3:a40e:f8ab]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::1797:59c3:a40e:f8ab%4]) with mapi id 15.20.6565.028; Tue, 11 Jul 2023 21:58:54 +0000 From: David Faust To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com, yhs@meta.com Subject: [PATCH 7/9] btf: create and output BTF_KIND_DECL_TAG types Date: Tue, 11 Jul 2023 14:57:14 -0700 Message-Id: <20230711215716.12980-8-david.faust@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230711215716.12980-1-david.faust@oracle.com> References: <20230711215716.12980-1-david.faust@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA1PR02CA0008.namprd02.prod.outlook.com (2603:10b6:806:2cf::13) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3213:EE_|CO6PR10MB5650:EE_ X-MS-Office365-Filtering-Correlation-Id: d0d50cf3-8031-43b3-3597-08db825a04b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vHKHrwMKZMoJ5y5rGaNll7cmLn24zyA8kIM1DWYxOLhAKmDDxTdARLlpSS+u8DkWDG0rW5VS5wSKZtd1HHHf15VRQSxEb4ysksWqIDVlNtcGpkVzMgZMJXGSNx0LtZjec517sPmewJfrdFTLdCV6qNrcFOSLnxl4dntzZtlj6JOzwWBgqXJXJxrLeuMHwkE9klbG4+0xxw9yOs7W3OBrJktmD3bWle7+/jKlX8zZoTGhEjjMTVAX+6nj8ZpREB+f33eYkioodulCCgeqx71TclFjxhe0zkY7aFYrsuk9nxGIFLhf+Euj+x6r575Dfs3QsLG59fkaarUGZo/15w1KOudDgkt7KXOxIQfll/gSoWqaVLOKpJZChgWxBB2S/pQcKv/ObeocFoBnbN2CgEzKt33acJdq20BuLuoZ78xeQIXTGS2rK4XqLkCYOxMawV9nYi7eHAHdemfZ9NY3IzU/y5yHjpT1NJ+TErEBtDUfacdUy7KAImyVLC9KqInU+14QjYyPaGgJuu8xsVlPL9IaUYnZ/0e6mvj7RJlXGSC4Nx65fBohO4L5WdHleLnsq311 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB3213.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(136003)(376002)(396003)(366004)(451199021)(86362001)(38100700002)(36756003)(6486002)(6666004)(6506007)(26005)(186003)(1076003)(6512007)(2616005)(5660300002)(2906002)(316002)(66556008)(66946007)(66476007)(8676002)(44832011)(8936002)(83380400001)(4326008)(478600001)(6916009)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MfvK4VcP7Dv7rBDDaX1QtA0cUbfeQSDSLrcMzbMo4IQCtQartHyPQ31mwRZy?= =?us-ascii?Q?3ETCU4+nnJfVUuyxkHOEr18+t5EPV7k9y1kJGZr16nfT87ExboBeeIM7ZQLx?= =?us-ascii?Q?UEx+FZMgzxb0RnCKtvSFHkWV3DNfsTECKJbYD9S5draLC/u22J42oOF9eBfC?= =?us-ascii?Q?elvghQO33sQK9Ih9VIJtEub9SVx+2+zRSpiZvOvRgR7fkITSkBwJQvjNvyx2?= =?us-ascii?Q?uogLQ+u7pIvcz6/p76Nef/gnfX1F6dPTWtFvTgs/iaElMY82A11+olkMgQ4r?= =?us-ascii?Q?NnWoABEOrPwwtV5V/uvSc511hyQU1i0nI0ScRzJUCOnbWuhqio+JnEyTOpWC?= =?us-ascii?Q?WY/ZGhfXx+qIE6qBcuUQN8VQXAVP5jA3VVBOdmNHgiMntKmhpVLbedtakQ6I?= =?us-ascii?Q?Q5BVWw6B6rOUA6ekfp0EX4gi4cQrYRHEOyJ9mV/cpVj5jKOIQZ+sBI5sPcFP?= =?us-ascii?Q?BwV8Hu3Cy+iTd9V1GfwmVbz/iEbduyqc7JWbn/YFx3EeIAOninBJZ754wXSZ?= =?us-ascii?Q?xOQGfwb7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8Jp7yvt+dR5pg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0d50cf3-8031-43b3-3597-08db825a04b8 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 21:58:54.2442 (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: RenuKLvNoHKpXrKg0f7IjWwYUutAcssjndZ2mYY9+tlmUFu3tgwq7CKmMM7kYy4DqeUqlk9hMFtPecXplsu4Rw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5650 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_12,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110200 X-Proofpoint-ORIG-GUID: ic95DBfJJAqfUb5mmBKr4Y2U3qXaNpds X-Proofpoint-GUID: ic95DBfJJAqfUb5mmBKr4Y2U3qXaNpds X-Spam-Status: No, score=-13.4 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This patch updates btfout.cc to be aware of BTF_KIND_DECL_TAG types and output them appropriately. gcc/ * btfout.cc (funcs_map): New hash map. (btf_emit_preprocess): ... Initialize it here... (btf_collect_datasec): ... Populate it here... (btf_finalize): ... And free it here. (get_btf_kind): Handle BTF_KIND_DECL_TAG. (calc_num_vbytes): Likewise. (btf_asm_type): Likewise. (output_asm_btf_vlen_bytes): Likewise. (btf_asm_type_ref): Update comment. --- gcc/btfout.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/gcc/btfout.cc b/gcc/btfout.cc index e6acf4e51a5..087d0b40e0a 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -104,6 +104,9 @@ static vec voids; created. This vector holds them. */ static GTY (()) vec *funcs; +/* Maps FUNC_PROTO types to the IDs of the corresponding FUNC types. */ +static GTY (()) hash_map *funcs_map; + /* The number of BTF variables added to the TU CTF container. */ static unsigned int num_vars_added = 0; @@ -153,6 +156,7 @@ get_btf_kind (uint32_t ctf_kind) case CTF_K_VOLATILE: return BTF_KIND_VOLATILE; case CTF_K_CONST: return BTF_KIND_CONST; case CTF_K_RESTRICT: return BTF_KIND_RESTRICT; + case CTFC_INT_K_DECL_TAG: return BTF_KIND_DECL_TAG; default:; } return BTF_KIND_UNKN; @@ -316,6 +320,10 @@ btf_calc_num_vbytes (ctf_dtdef_ref dtd) vlen_bytes += vlen * sizeof (struct btf_var_secinfo); break; + case BTF_KIND_DECL_TAG: + vlen_bytes += sizeof (struct btf_decl_tag); + break; + default: break; } @@ -425,13 +433,15 @@ btf_collect_datasec (ctf_container_ref ctfc) func_dtd->dtd_data = dtd->dtd_data; func_dtd->dtd_data.ctti_type = dtd->dtd_type; func_dtd->linkage = dtd->linkage; - func_dtd->dtd_type = num_types_added + num_types_created; + /* +1 for the sentinel type not in the types map. */ + func_dtd->dtd_type = num_types_added + num_types_created + 1; /* Only the BTF_KIND_FUNC type actually references the name. The BTF_KIND_FUNC_PROTO is always anonymous. */ dtd->dtd_data.ctti_name = 0; vec_safe_push (funcs, func_dtd); + funcs_map->put (dtd, func_dtd->dtd_type); num_types_created++; /* Mark any 'extern' funcs and add DATASEC entries for them. */ @@ -449,7 +459,7 @@ btf_collect_datasec (ctf_container_ref ctfc) struct btf_var_secinfo info; /* +1 for the sentinel type not in the types map. */ - info.type = func_dtd->dtd_type + 1; + info.type = func_dtd->dtd_type; /* Both zero at compile time. */ info.size = 0; @@ -653,6 +663,7 @@ btf_emit_preprocess (ctf_container_ref ctfc) } btf_var_ids = hash_map::create_ggc (100); + funcs_map = hash_map::create_ggc (100); if (num_ctf_vars) { @@ -709,7 +720,8 @@ btf_asm_type_ref (const char *prefix, ctf_container_ref ctfc, ctf_id_t ref_id) else if (ref_id >= num_types_added + 1 && ref_id < num_types_added + num_vars_added + 1) { - /* Ref to a variable. Should only appear in DATASEC entries. */ + /* Ref to a variable. + Should only appear in DATASEC entries or DECL_TAGs. */ ctf_id_t var_id = btf_relative_var_id (ref_id); ctf_dvdef_ref dvd = ctfc->ctfc_vars_list[var_id]; dw2_asm_output_data (4, ref_id, "%s: (BTF_KIND_VAR '%s')", @@ -831,6 +843,59 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) and should write 0. */ dw2_asm_output_data (4, 0, "(unused)"); return; + case BTF_KIND_DECL_TAG: + { + /* A decl tag might refer to (be the child DIE of) a variable. Try to + lookup the parent DIE's CTF variable, and if it exists point to the + corresponding BTF variable. This is an odd construction - we have a + 'type' which refers to a variable, rather than the reverse. */ + dw_die_ref parent = get_die_parent (dtd->dtd_key); + ctf_dvdef_ref ref_dvd = ctf_dvd_lookup (ctfc, parent); + ctf_dtdef_ref ref_dtd = ctf_dtd_lookup (ctfc, parent); + if (ref_dvd) + { + /* The decl tag is on a variable. */ + unsigned int *var_id = btf_var_ids->get (ref_dvd); + gcc_assert (var_id); + btf_asm_type_ref ("btt_type", ctfc, + btf_absolute_var_id (*var_id)); + return; + } + else if (ref_dtd) + { + /* Decl tags on functions refer to the FUNC_PROTO record as a + result of how they are created. But we want them in the output + to refer to the synthesized FUNC record instead. */ + unsigned int *func_id = funcs_map->get (ref_dtd); + gcc_assert (func_id); + btf_asm_type_ref ("btt_type", ctfc, *func_id); + return; + } + else if (parent && dw_get_die_tag (parent) == DW_TAG_formal_parameter) + { + /* The decl tag is on a function argument. In this case we refer + to the FUNC record, and component_index indicates to which + parameter the tag applies. */ + ref_dtd = ctf_dtd_lookup (ctfc, get_die_parent (parent)); + unsigned int *func_id = funcs_map->get (ref_dtd); + gcc_assert (func_id); + btf_asm_type_ref ("btt_type", ctfc, *func_id); + return; + } + else if (parent && dw_get_die_tag (parent) == DW_TAG_member) + { + /* The decl tag is on a struct/union member. In this case we refer + to the struct/union record, and component_index indicates to + which member the tag applies. */ + ref_dtd = ctf_dtd_lookup (ctfc, get_die_parent (parent)); + ctf_id_t ref_id = get_btf_id (ref_dtd->dtd_type); + btf_asm_type_ref ("btt_type", ctfc, ref_id); + return; + } + + /* There are no other valid places for decl tag to appear. */ + gcc_unreachable (); + } default: break; } @@ -1177,6 +1242,11 @@ output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd) at this point. */ gcc_unreachable (); + case BTF_KIND_DECL_TAG: + dw2_asm_output_data (4, dtd->dtd_u.dtu_btfnote.component_idx, + "decltag_compidx"); + break; + default: /* All other BTF type kinds have no variable length data. */ break; @@ -1384,6 +1454,9 @@ btf_finalize (void) btf_var_ids->empty (); btf_var_ids = NULL; + funcs_map->empty (); + funcs_map = NULL; + free (btf_id_map); btf_id_map = NULL; -- 2.40.1