From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 4C90339518B4 for ; Mon, 16 Aug 2021 17:39:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C90339518B4 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17GHWC0j027643; Mon, 16 Aug 2021 17:39:37 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3afgmb9s7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Aug 2021 17:39:37 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17GHUjPV108890; Mon, 16 Aug 2021 17:39:35 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by aserp3020.oracle.com with ESMTP id 3ae5n6377y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Aug 2021 17:39:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXAnB+eVyF8pvza1rfs3ky5g3A7qrSXDnl8F/lUZtGpTXr6jl+rohY9slK1HHm1TxuRFMyebIBMJM0RlXWJJG8oIgsw1WbC3vvdSLdBYMjwry41k3dRHtOQxw062RVg78gpXEUvp1ZGeNPGxIEm4heO/JiknYuXJ2LLj6nB4CXytkJWJB9xpXfxwiExFNhC+HQ3lmXiz51RmUuI66tco7dnXItFJb9uklNer7aXmugo9a1tziDRvf30QkqkaDAbbQbA8CY9YqictRs+EOtoN0kW97I6cTaesrJLMmES4x2wzy4jfpCYR5hWkimXcPBgevQm0hJDcXs4KXGusEB+gSQ== 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-SenderADCheck; bh=JPRzQ0vFpWwhEdm7euOxZ19Hj13AERwj2PVyItnwCSI=; b=lKtB2ESP4dPNby+oFo3Tmxbrvv+xgVvePG3OBR4X/gFjRg8oQc7L+Ykink1HZ8mrvaC+Bn8EOZoOD9XdJpAD0gw/aExG7nf3goHG+UHjHtqkzfK3OG1OidofFdeyTemfrXM3i3knXU4Libl7YtM5SV43hg9oPzbZnf2I3sPWfynYvcKbrTYw4z7pxBma+Eidc9ipQNd4yk8nkvIUQKBHU/7s+fqAmLgk64J05wjrUNtrTjZwOlruTCyAynR8H6s2gaAB7kFOFbgLfR87VC4isteZ2MPLqkMRhHuCLX+EugqyTg7PX2lTRo6BpIOfUpl0dtDhHybUb2w3SPORb3xfmg== 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 CO1PR10MB4641.namprd10.prod.outlook.com (2603:10b6:303:6d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.15; Mon, 16 Aug 2021 17:39:32 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4415.023; Mon, 16 Aug 2021 17:39:32 +0000 Subject: Re: [PATCH, V2 2/3] targhooks: New target hook for CTF/BTF debug info emission To: Richard Biener Cc: GCC Patches References: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> <1628124628-28706-3-git-send-email-indu.bhagat@oracle.com> From: Indu Bhagat Message-ID: <85d5d4ff-a65d-03ab-d888-493fbd7f451b@oracle.com> Date: Mon, 16 Aug 2021 10:39:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA0PR11CA0063.namprd11.prod.outlook.com (2603:10b6:806:d2::8) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2606:b400:2001:93:8000::e37] (2606:b400:8004:44::11) by SA0PR11CA0063.namprd11.prod.outlook.com (2603:10b6:806:d2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13 via Frontend Transport; Mon, 16 Aug 2021 17:39:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e78fa4c-fd74-49e0-464e-08d960dcce47 X-MS-TrafficTypeDiagnostic: CO1PR10MB4641: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TYhluoUSLUQeYva86UsglcE0T2UWQbloIpx8UaRcUzsaBfho7B9BX738qmCdx5hE3ZXg8SWis5qVUd1wNMM7wkLw382FHsfQRmTdK+PRReVqsTbRucieQpxQr1OOg6VslPhubmXwsyvl8+j9vvoIB+630Ft9Wk+UR1A5c+WLxNS0bvE+wNQkg3nACG465iTF2JBp0wRIt6a6kxV5VTJkJDvHGRe3R3Zljpr5840s7lP4gLDnD9C9GfUgUygL12RkIJDzWN4xg/x4TvW9H4TCfDEglH9xUUhAoW4oleCAMwiapDcDGehCF+MLBikI/fSpk3OQTFWWHR2RN3KNkIon+RA6LdcMqFj75YdvBpfgdtQTVyFP9a6JJayQtisRp7TmVZb34Y0oS5WwfdGk0PNKr0Kr+FQw/JVX9mVxVYmn6sUYcSYVcIX/zrK6+CbeBeTQvdOzEpm7CU5jRyxmbWLTmLC73t5/UekhRJVWJYupJK6oJvfXoEHx3XfQp1eYkMe++rG4IYs9iLSviMMMZd/upBns4dkKEaZxRnAaAQ7EPd/FJliP5CzAn+2aeWIMDi5HhKu0rPO5Di9o1nQ4dgevApeC3YF+Pypt1eA0V7gXz8LkPMmVWN9O85n1YEVwZVLsuWlDiTVoa76T235r5hrfTL3ABOjYHtXWl1lhVc4Nue6NkX7uwEXxdVFu7NKFEmx8W7ACvOBze0D5qQozk8R00AbsrpnRuox2tmdkwufQGEg= 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:(376002)(366004)(346002)(136003)(396003)(39860400002)(6666004)(8936002)(2616005)(5660300002)(44832011)(36756003)(53546011)(83380400001)(316002)(6916009)(66476007)(8676002)(478600001)(86362001)(6486002)(186003)(2906002)(66946007)(66556008)(4326008)(38100700002)(31686004)(31696002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YWxhZUtLM2hOQmQxZk1xRHY1Mk5CZ0dCRjVFOHgyVnBvZ3JNbGlSSDNocnVn?= =?utf-8?B?SnNrd09zOUhNVGM0UTJzak5HWGlRVGNyUFF1dlkvbDBZdUI3bE0xOTF2RjVk?= =?utf-8?B?Qno5d252YzVZMUdmeDZMNWl4emF4YklBbFhXYlZXcC91VUtaclV4bytTZXg4?= =?utf-8?B?S2o0R01WRjhOOUVtRm5YV1BMMnJ2aGlBKzRr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VcWk3U3pzckh6cmtUVm4vTWtBdTR6TmMxSHkyQmxV?= =?utf-8?B?ekJnSGVIaWk2aGN2WGVJMFZIWXh1dmFCZ2pMOUVTOVJxS3JDSk5ZWmtBeHo4?= =?utf-8?B?RUNBaDJvQkJDTGoyamRIblNXRTFkdzRyQjRRK05CUnpqRHZvdzZIa0pxSmNS?= =?utf-8?B?cVBJazZtNUg5eTUvSTN5VktUamJzU1Fza0M0WmdoVFdCd3VESUV6Yk5rRUw2?= =?utf-8?B?OUJKMHZ3ZGNWZm9zYVowRlExZTFaUElCV1ZOdXFrNUtITjRybUZmSFNKcC8y?= =?utf-8?B?ZnV3QzFzK1FJSVNWZDVrbExQMTZ6b0JCMFE3ZXhJb3hHUFY2UWkvcVREN3ky?= =?utf-8?B?R2w2SEVtMisvSG5QN3FDclB2UmR6ZDFaUnJSdUlMdEw2akZEenRqRVhpSW5P?= =?utf-8?B?cUZCcE1HTkNWdVI3Y3VGVngzODlaUWR4eDFxOHhWYlBaT1dBWllzVHh1ZzFh?= =?utf-8?B?aHV4TjhQZHJKd09qYjlrU2V5Y0ZFY0ttSFBqU3VsM0w4cUFIWHlLWXk3NkJj?= =?utf-8?B?cVpVOFA4QTZ2dWdwb1VhVkx5MDVONm9wZDA0cmN3MHpEL3Y2RTZHbHJHQ3Jr?= =?utf-8?B?M2hNVi9idGw1MmZtY3VWekttcGQ1c3lMbGF1NHIydy96Njk4MEgzOTZpelJj?= =?utf-8?B?MStCOUlvN1NoYVg0Ny8yeDUzYU5XVWlhaXpoclA0SHA4aXhMeHdMZ21HSjNF?= =?utf-8?B?emdBU053elBhUndjd3VBUT09?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e78fa4c-fd74-49e0-464e-08d960dcce47 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2021 17:39:32.1733 (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: tCzQ9Mj6UaQ5+5gKCbIDytRh97qmjQL6Cbai51kkL4Iu+elBbxeivuKlSAmjgOlm8ZiO7T3pxy1T1apPDMT0hQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4641 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10078 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108160111 X-Proofpoint-ORIG-GUID: tmLRxQUa7jUxM_ZN197KXQn2VaV4BRRl X-Proofpoint-GUID: tmLRxQUa7jUxM_ZN197KXQn2VaV4BRRl X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_NONE, SPF_NONE, TXREP 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-List-Received-Date: Mon, 16 Aug 2021 17:39:49 -0000 On 8/10/21 4:54 AM, Richard Biener wrote: > On Thu, Aug 5, 2021 at 2:52 AM Indu Bhagat via Gcc-patches > wrote: >> >> This patch adds a new target hook to detect if the CTF container can allow the >> emission of CTF/BTF debug info at DWARF debug info early finish time. Some >> backends, e.g., BPF when generating code for CO-RE usecase, may need to emit >> the CTF/BTF debug info sections around the time when late DWARF debug is >> finalized (dwarf2out_finish). > > Without looking at the dwarf2out.c usage in the next patch - I think > the CTF part > should be always emitted from dwarf2out_early_finish, the "hooks" should somehow > arrange for the alternate output specific data to be preserved until > dwarf2out_finish > time so the late BTF data can be emitted from there. > > Lumping everything together now just makes it harder to see what info > is required > to persist and thus make LTO support more intrusive than necessary. In principle, I agree the approach to split generate/emit CTF/BTF like you mention is ideal. But, the BTF CO-RE relocations format is such that the .BTF section cannot be finalized until .BTF.ext contents are all fully known (David Faust summarizes this issue in the other thread "[PATCH, V2 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase".) In summary, the .BTF.ext section refers to strings in the .BTF section. These strings are added at the time the CO-RE relocations are added. Recall that the .BTF section's header has information about the .BTF string table start offset and length. So, this means the "CTF part" (or the .BTF section) cannot simply be emitted in the dwarf2out_early_finish because it's not ready yet. If it is still unclear, please let me know. My judgement here is that the BTF format itself is not amenable to split early/late emission like DWARF. BTF has no linker support yet either. > >> gcc/ChangeLog: >> >> * config/bpf/bpf.c (ctfc_debuginfo_early_finish_p): New definition. >> (TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P): Undefine and override. >> * doc/tm.texi: Regenerated. >> * doc/tm.texi.in: Document the new hook. >> * target.def: Add a new hook. >> * targhooks.c (default_ctfc_debuginfo_early_finish_p): Likewise. >> * targhooks.h (default_ctfc_debuginfo_early_finish_p): Likewise. >> --- >> gcc/config/bpf/bpf.c | 14 ++++++++++++++ >> gcc/doc/tm.texi | 6 ++++++ >> gcc/doc/tm.texi.in | 2 ++ >> gcc/target.def | 10 ++++++++++ >> gcc/targhooks.c | 6 ++++++ >> gcc/targhooks.h | 2 ++ >> 6 files changed, 40 insertions(+) >> >> diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c >> index 028013e..85f6b76 100644 >> --- a/gcc/config/bpf/bpf.c >> +++ b/gcc/config/bpf/bpf.c >> @@ -178,6 +178,20 @@ bpf_option_override (void) >> #undef TARGET_OPTION_OVERRIDE >> #define TARGET_OPTION_OVERRIDE bpf_option_override >> >> +/* Return FALSE iff -mcore has been specified. */ >> + >> +static bool >> +ctfc_debuginfo_early_finish_p (void) >> +{ >> + if (TARGET_BPF_CORE) >> + return false; >> + else >> + return true; >> +} >> + >> +#undef TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P >> +#define TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P ctfc_debuginfo_early_finish_p >> + >> /* Define target-specific CPP macros. This function in used in the >> definition of TARGET_CPU_CPP_BUILTINS in bpf.h */ >> >> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi >> index cb01528..2d5ff05 100644 >> --- a/gcc/doc/tm.texi >> +++ b/gcc/doc/tm.texi >> @@ -10400,6 +10400,12 @@ Define this macro if GCC should produce debugging output in BTF debug >> format in response to the @option{-gbtf} option. >> @end defmac >> >> +@deftypefn {Target Hook} bool TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P (void) >> +This target hook returns nonzero if the CTF Container can allow the >> + emission of the CTF/BTF debug info at the DWARF debuginfo early finish >> + time. >> +@end deftypefn >> + >> @node Floating Point >> @section Cross Compilation and Floating Point >> @cindex cross compilation and floating point >> diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in >> index 4a522ae..05b3c2c 100644 >> --- a/gcc/doc/tm.texi.in >> +++ b/gcc/doc/tm.texi.in >> @@ -7020,6 +7020,8 @@ Define this macro if GCC should produce debugging output in BTF debug >> format in response to the @option{-gbtf} option. >> @end defmac >> >> +@hook TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P >> + >> @node Floating Point >> @section Cross Compilation and Floating Point >> @cindex cross compilation and floating point >> diff --git a/gcc/target.def b/gcc/target.def >> index 68a46aa..44e2251 100644 >> --- a/gcc/target.def >> +++ b/gcc/target.def >> @@ -4016,6 +4016,16 @@ clobbered parts of a register altering the frame register size", >> machine_mode, (int regno), >> default_dwarf_frame_reg_mode) >> >> +/* Return nonzero if CTF Container can finalize the CTF/BTF emission >> + at DWARF debuginfo early finish time. */ >> +DEFHOOK >> +(ctfc_debuginfo_early_finish_p, >> + "This target hook returns nonzero if the CTF Container can allow the\n\ >> + emission of the CTF/BTF debug info at the DWARF debuginfo early finish\n\ >> + time.", >> + bool, (void), >> + default_ctfc_debuginfo_early_finish_p) >> + >> /* If expand_builtin_init_dwarf_reg_sizes needs to fill in table >> entries not corresponding directly to registers below >> FIRST_PSEUDO_REGISTER, this hook should generate the necessary >> diff --git a/gcc/targhooks.c b/gcc/targhooks.c >> index eb51909..e38566c 100644 >> --- a/gcc/targhooks.c >> +++ b/gcc/targhooks.c >> @@ -2112,6 +2112,12 @@ default_dwarf_frame_reg_mode (int regno) >> return save_mode; >> } >> >> +bool >> +default_ctfc_debuginfo_early_finish_p (void) >> +{ >> + return true; >> +} >> + >> /* To be used by targets where reg_raw_mode doesn't return the right >> mode for registers used in apply_builtin_return and apply_builtin_arg. */ >> >> diff --git a/gcc/targhooks.h b/gcc/targhooks.h >> index f92e102..55dc443 100644 >> --- a/gcc/targhooks.h >> +++ b/gcc/targhooks.h >> @@ -255,6 +255,8 @@ extern unsigned int default_dwarf_poly_indeterminate_value (unsigned int, >> unsigned int *, >> int *); >> extern machine_mode default_dwarf_frame_reg_mode (int); >> +extern bool default_ctfc_debuginfo_early_finish_p (void); >> + >> extern fixed_size_mode default_get_reg_raw_mode (int); >> extern bool default_keep_leaf_when_profiled (); >> >> -- >> 1.8.3.1 >>