From patchwork Tue Jul 11 21:57:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 118729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp766125vqm; Tue, 11 Jul 2023 15:04:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlH6ff33LXpYmfg+TkG4qL9cDnq8IR13RJY1VTRI3CwuFQwQj2Krhjh6AhebzmEskKbcPuxB X-Received: by 2002:a2e:80cd:0:b0:2b6:dfef:d523 with SMTP id r13-20020a2e80cd000000b002b6dfefd523mr12674591ljg.50.1689113071607; Tue, 11 Jul 2023 15:04:31 -0700 (PDT) Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k23-20020a1709061c1700b00992cd4e0b83si2948603ejg.426.2023.07.11.15.04.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 15:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RQzVIeHM; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 426BF3850AC4 for ; Tue, 11 Jul 2023 22:02:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 426BF3850AC4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689112920; bh=wRlVaPcq0OiU0pL3k/GuNeE5PwqmwTWHrhnrHN0QXjU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=RQzVIeHMgp3pJeZz7uE1eYG7RAg4rcJQTR7Xp9iiDCb0ripk+ChLG9RazrOJOpk4+ CGPVd+ktoVL95Mukk93+gKC8iyqFXJQ+gSpnW9MU7wSbSfPvXEhsNuW2XfzUM2IsCb vG0Q9KRDpr2CqgqqCL6FBzM8szd5nstvhZFZpSSo= 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 733583857727 for ; Tue, 11 Jul 2023 21:59:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 733583857727 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 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 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 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> 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: MfvK4VcP7Dv7rBDDaX1QtA0cUbfeQSDSLrcMzbMo4IQCtQartHyPQ31mwRZy3ETCU4+nnJfVUuyxkHOEr18+t5EPV7k9y1kJGZr16nfT87ExboBeeIM7ZQLxUEx+FZMgzxb0RnCKtvSFHkWV3DNfsTECKJbYD9S5draLC/u22J42oOF9eBfCelvghQO33sQK9Ih9VIJtE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6l0uG7fBFFQeeozO3BGy9dV+Qq4n/P9VIvCJqDrofJ1OgnRiEEP7haikPhyWa/6piN8QtdnBSOVxe1hZKZcrXJ2K2Gia+DraSx26Pd2vjsyT7INau6QUl8Jp7yvt+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 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771163427983746926 X-GMAIL-MSGID: 1771163427983746926 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;