From patchwork Tue Jun 11 19:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1946489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=CaJE72O8; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=fdGktgor; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzJ3l6mBCz20Pb for ; Wed, 12 Jun 2024 05:03:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16FDC385DDE3 for ; Tue, 11 Jun 2024 19:03:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 7FD21385DC1E for ; Tue, 11 Jun 2024 19:02:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FD21385DC1E Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7FD21385DC1E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718132577; cv=pass; b=ZS7t5s72dmCDgztPhcu2uqF7CJ+Kq/Q+40MRVdTjiypIZ8yeKiAxXX66oy5H/N6P8bNQaA+uT1oK55tlAzn30//ZsKwVtn21eQuK/B2sUQ7+qJCNikh4Ih40/SiQl1lK9dczZ/NQL5+f6Zq3wjEuG6Q1Dp4i14qaeY/bF2qhY4w= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718132577; c=relaxed/simple; bh=YSXDzSnwK/AgrZ70wnrmq8weelY4MNxWqNct+gakgtw=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=t5PK1jNYVwAOcLGgEBFqAvJ8PWMeMpkQtizLSu5bblIVw6bMWdPFN6726jSU9Voi+iVHe9t6CyputjVkY2o4em59wVpjuwq84z+NZyv78CfaRXEgicWy0XgI7J3HbkBoyAmmGIb5/4CIgNO0KltrtZZi4EqqL+wSZjhL0Xi9riA= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45BFp4MG008957 for ; Tue, 11 Jun 2024 19:02:54 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-11-20; bh=p5hi/kO5QjsAHuBeyqODFPrDrcCMw0DPUi/BnHrCsMk=; b= CaJE72O8lmWHbnvVdyxwDXqImWV3ooaqA6UcbxKaKvZI3ZatZptF6SzqpLHYfU99 etV/88HoQpKjxeQsInIdLhJXa6c7GWjCCtKcBdSuwZOoMLQqUIjkbRxgGP2/veio SH8LvNMFSPjDwHjcDt/Khhz2Z32X8/nnGwzpain5Iko37ZZeG/QMLSJkEk1gLxqs 34B88a//DUi9ufMbtGoGcQeP3ok0QOmjtnhHYmBYcoCX/NWEdOTB9+xe0E+XyS/Y Ge8rkWrRbCAEz45c1odHdFwLV9o3NmzQjfCZV/ZJ2gz41C0LCpsFCpqXFIQMzOi3 McNiuPBzjxEJ1rn6szaR4Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ymh195jgf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 11 Jun 2024 19:02:53 +0000 (GMT) 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 45BIFLA5021545 for ; Tue, 11 Jun 2024 19:02:53 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3yncauxd38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 11 Jun 2024 19:02:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ov4cOo7ns9xd7M9hKfTLgxIdtjxo1CuhBK23Gc3jN3568UfKkQoUd6I8Atp+QZzKd47+j6DBmtDrLB02YyVL83m7160tY9hY8vfqKzxtobcmibzey102ur25W/waKyYLJV8D1UTQok4JBvnQHVeliXETw6WGRsMq+psySAGZxR+9Rz5I0M1Xr+yE5kvJlOAQGjNWAc6bt5E685N6Y+nVvLJhQrLmhWa+bT4V06spd1gLphJIwFedP0xG9qLrULUqJubw4tZkc9LauYgmPyEXTO+H+cbdW3Uas3ah6d1EfCNVrQDixJYfMfUJnWNKqzAJAbB+1DsjvwzKoqup1eLvyw== 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=p5hi/kO5QjsAHuBeyqODFPrDrcCMw0DPUi/BnHrCsMk=; b=BWGKP92vW2FrD19v2Tw6fVW2+DZKp2K1rjjpQmmbiZIrKBisqDLLyHILBBYFxIRmmyrqREXcyD+/91tqrA2bKfgbdeSDjoCFy3eBXX9dzuqe9ffJIlOspfZoiIQJxl4dgnLHC1thwgb3RHKxMGuKyk60Xg28Eysp/7Dh7XS9mr5CpQ0n3f+b0ewCZutcQUI+ujvvLNq/b5AJ1xQDL8KRdQadfpYCsw00cUuhKb1CMl/6XH2RnBhbXaOMsSV0Ls51JgPU7AwfZP01xRezJjpEHhiRJ25SJY+Yf35QF15T8TrURI/6HvOzoh4eDW+NpB1Tg68NLK3UaNCLypxxPAgPGA== 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=p5hi/kO5QjsAHuBeyqODFPrDrcCMw0DPUi/BnHrCsMk=; b=fdGktgorUIpagBrbTF90tSgZnwIyGLQuLknd8AOmTL7clbMa5pD+R7zDDZvZ+tVoFPOHrZxlFehoQ8lVxD1xF8RKhh/S2vyolX0yRqY+dVzpZyL+30mg5Ry941p/oc7zoKJEo2pMRk0HHx82d9XvksiT++55lKtKPwTabIFRSsk= Received: from DS0PR10MB7953.namprd10.prod.outlook.com (2603:10b6:8:1a1::22) by CH2PR10MB4134.namprd10.prod.outlook.com (2603:10b6:610:a7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.39; Tue, 11 Jun 2024 19:02:51 +0000 Received: from DS0PR10MB7953.namprd10.prod.outlook.com ([fe80::5b2d:d28c:8773:c84]) by DS0PR10MB7953.namprd10.prod.outlook.com ([fe80::5b2d:d28c:8773:c84%5]) with mapi id 15.20.7633.036; Tue, 11 Jun 2024 19:02:51 +0000 From: David Faust To: gcc-patches@gcc.gnu.org Cc: indu.bhagat@oracle.com, jose.marchesi@oracle.com, cupertino.miranda@oracle.com Subject: [PATCH v4 1/6] ctf, btf: restructure CTF/BTF emission Date: Tue, 11 Jun 2024 12:01:40 -0700 Message-ID: <20240611190145.115887-2-david.faust@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611190145.115887-1-david.faust@oracle.com> References: <20240611190145.115887-1-david.faust@oracle.com> X-ClientProxiedBy: MW4PR04CA0382.namprd04.prod.outlook.com (2603:10b6:303:81::27) To DS0PR10MB7953.namprd10.prod.outlook.com (2603:10b6:8:1a1::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7953:EE_|CH2PR10MB4134:EE_ X-MS-Office365-Filtering-Correlation-Id: d5519c2e-ed31-43e8-83d1-08dc8a491777 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|1800799016|366008|376006; X-Microsoft-Antispam-Message-Info: LvFH91G5zc8KQsHyAWA5lQ55nSamOCHYB+DCm2qFJ8Rf2+Ub0WIXloF5EJvyEMmOkceaN2E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mC3uc9iNT37VP+Ib6wY9rbh07Qm9FWbR0eTDNpeqwKBuDRBYa411ORqzOU5IlmaxeXOe/0zsJAZWDjl26m1EIb3Av5vmWqFzLN7gGO/JRyATh/OxLHQPbLlYM23Q9aPUaEo4LpkPEjF4fGaOKlJDdavlJR1E7VVgZAa4gYk46C8odXaDUN+IUCLVj/wDukBs8yAE8R7zv+Y X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR10MB7953.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230032)(1800799016)(366008)(376006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QQlLl7V6fGUujSSlUA/axET/hd52dgKe9hhpH2VLkoANU/VjF6tNXFri+AHxBDrJ460CBs6S6RaY0LiWDKuCNHm775Vt4hZyYLgqtYCmPHoAlakb/oTJLssLAeOe6NaHvLLBRfSX64qTIYMW1AI4GjpM0IFEh6zYPvlK/U1vFlnsj828tAThuSeE9YSe10RezszT0jchykD9619vmAP1bxKNANVd9EOv0zuNxcxIy8tiNdN9f5MsbyUwbCX4r8nxpmQOQbYJe+DlG6mK0eE15ZlwnJ/la8XBj55bJ3V1H47EteJgoAeX/KuV3VN369EQVNPOGpgDoJolYJxCocy/GgXdS+w6QnrSYGrxSTbfBjfburjS81ToG/vn07PgexHlvFWIAQUC2fj0aQpuvkT7+I+cnZYbz2IL9HbA68OcMRIY+9j0w8JpItSFXob24HE2lONRkmsYwyEvQtTUaRwL9/r582/gP37/mNn2ST1bGqvuPT71wk4AQbdzGxDAQYQyo360lxTLssmYTjGaAqdF/b02j6D/yskiU2omTRH4SZxcrttYJT5k2FpuQbwy8ZrqalhiMZLNEh7oEcm7X1wBgq8Pf8V8i/UP2DtSts1KuSNppbk+juhZ+mZ18szLTtrTEsULmMyOr6RnRXgzi9XzKdma3Oc0bHPU5gp3JVp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b8LevuKbecCJQERXpoqO+TWT1BRNurPsC8x2vxgAOwBGKNvfiiHhsk3lA/ACiOpW+wAc9fBHnGmCoMl3q7iYl6nUZf8s/AsU4tUYuOeSDO4HB166QQ6YwWZ68thR7b6Ndc8jya5s9GKu5PyB1jAMo4ZeSLxLrYUy1R2mjD0WsK8JKs6dbHdfn7DbP7AeFoLovm+isQYJt1OM0Dg3kS3kvxK0L27Oqt05p7+za8svAJwRAPul6mVkDJh+UR0gJIlAhMirrRUFRapCy3zOqRaL7T/SzIZk36P/WmoYJPwsa0nPFBg0UcmoIK4eR0IYV3tOB2MHHRdxvFzSbbO+W9YhabaUpbU0rKuuIfcLJLoKV8jw2dQN6tPiMPpG/4uesRZynt5ykcxmo0MtBFx1AYO5TyEOYBO3YbG2UUKt4WxG5F6uN3oz4wknqUQrE0XsBP9mNaKPfl0G2MOI/wxhN7MIbAx03HEtzlL9RMI0T3OnMaASPO4KRu2UmpRgHA54tgOVBixbbVCVloGfBb8ZgAq2haoMrWQ+bL8Hf/JUStDLvWvFDgwKkH8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5519c2e-ed31-43e8-83d1-08dc8a491777 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7953.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 19:02:51.1908 (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: BSdi5W8wDEg+CEFG87eCoiwnb4gCKPsS+UoEZld+83iULKBS6OLVfj86NB418Levbr3a76yHhPMUlTiOv+We+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4134 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-11_09,2024-06-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406110130 X-Proofpoint-GUID: gbZW-RZDJ4wqPYGSrzuH5VVM0CBdbVfw X-Proofpoint-ORIG-GUID: gbZW-RZDJ4wqPYGSrzuH5VVM0CBdbVfw 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_H4, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irreversibly, the shared in-memory representation used by the two formats without issue. b) BTF generation has fewer entry points, and is cleanly divided into early_finish and finish. c) BTF is now always emitted at finish (called from dwarf2out_finish), for all targets in non-LTO builds, rather than being emitted at early_finish for targets other than BPF CO-RE. In LTO builds, BTF is emitted at early_finish as before. Note that this change alone does not alter the contents of BTF at all, regardless of whether it would have previously been emitted at early_finish or finish, because the calculation of the BTF to be emitted is not moved by this patch, only the write-out. The changes are transparent to both CTF and BTF emission. gcc/ * btfout.cc (btf_init_postprocess): Rename to... (btf_early_finish): ...this. (btf_output): Rename to... (btf_finish): ...this. * ctfc.h: Analogous changes. * dwarf2ctf.cc (ctf_debug_early_finish): Conditionally call btf_early_finish, or ctf_finalize as appropriate. Emit BTF here for LTO builds. (ctf_debug_finish): Always call btf_finish here if generating BTF info in non-LTO builds. (ctf_debug_finalize, ctf_debug_init_postprocess): Delete. * dwarf2out.cc (dwarf2out_early_finish): Remove call to ctf_debug_init_postprocess. --- gcc/btfout.cc | 28 +++++++++++++++++++++ gcc/ctfc.h | 4 +-- gcc/dwarf2ctf.cc | 65 +++++++++++++++--------------------------------- gcc/dwarf2out.cc | 2 -- 4 files changed, 50 insertions(+), 49 deletions(-) diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 07f066a47068..d5e9f3bd43d3 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -1491,6 +1491,34 @@ btf_finalize (void) tu_ctfc = NULL; } +/* Initial entry point of BTF generation, called at early_finish () after + CTF information has possibly been output. Translate all CTF information + to BTF, and do any processing that must be done early, such as creating + BTF_KIND_FUNC records. */ + +void +btf_early_finish (void) +{ + btf_init_postprocess (); +} + +/* Late entry point for BTF generation, called from dwarf2out_finish (). + Complete and emit BTF information. */ + +void +btf_finish (const char * filename) +{ + btf_output (filename); + + /* If compiling for BPF with CO-RE info, we cannot deallocate until after the + contents of the .BTF.ext section are finalized, which happens very late in + BPF backend. Therefore, the deallocation (i.e. btf_finalize ()) is delayed + until TARGET_ASM_FILE_END for BPF CO-RE. */ + if (!btf_with_core_debuginfo_p ()) + btf_finalize (); +} + + /* Traversal function for all BTF_KIND_FUNC type records. */ bool diff --git a/gcc/ctfc.h b/gcc/ctfc.h index fa188bf2f5a4..e7bd93901cfa 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -384,8 +384,8 @@ extern void ctf_init (void); extern void ctf_output (const char * filename); extern void ctf_finalize (void); -extern void btf_output (const char * filename); -extern void btf_init_postprocess (void); +extern void btf_early_finish (void); +extern void btf_finish (const char * filename); extern void btf_finalize (void); extern ctf_container_ref ctf_get_tu_ctfc (void); diff --git a/gcc/dwarf2ctf.cc b/gcc/dwarf2ctf.cc index dc59569fe560..8f9e2fada9e3 100644 --- a/gcc/dwarf2ctf.cc +++ b/gcc/dwarf2ctf.cc @@ -933,30 +933,6 @@ gen_ctf_type (ctf_container_ref ctfc, dw_die_ref die) return type_id; } -/* Prepare for output and write out the CTF debug information. */ - -static void -ctf_debug_finalize (const char *filename, bool btf) -{ - if (btf) - { - btf_output (filename); - /* btf_finalize when compiling BPF applciations gets deallocated by the - BPF target in bpf_file_end. */ - if (btf_debuginfo_p () && !btf_with_core_debuginfo_p ()) - btf_finalize (); - } - - else - { - /* Emit the collected CTF information. */ - ctf_output (filename); - - /* Reset the CTF state. */ - ctf_finalize (); - } -} - bool ctf_do_die (dw_die_ref die) { @@ -996,27 +972,27 @@ ctf_debug_init (void) add_name_attribute (ctf_unknown_die, "unknown"); } -/* Preprocess the CTF debug information after initialization. */ - -void -ctf_debug_init_postprocess (bool btf) -{ - /* Only BTF requires postprocessing right after init. */ - if (btf) - btf_init_postprocess (); -} - /* Early finish CTF/BTF debug info. */ void ctf_debug_early_finish (const char * filename) { - /* Emit CTF debug info early always. */ - if (ctf_debug_info_level > CTFINFO_LEVEL_NONE - /* Emit BTF debug info early if CO-RE relocations are not - required. */ - || (btf_debuginfo_p () && !btf_with_core_debuginfo_p ())) - ctf_debug_finalize (filename, btf_debuginfo_p ()); + /* Emit the collected CTF information. */ + if (ctf_debug_info_level > CTFINFO_LEVEL_NONE) + ctf_output (filename); + + /* If emitting BTF, start translation to BTF. */ + if (btf_debuginfo_p ()) + { + btf_early_finish (); + + /* For LTO builds, also emit BTF now. */ + if (flag_lto && !in_lto_p) + btf_finish (filename); + } + else + /* Otherwise, done with the CTF container. */ + ctf_finalize (); } /* Finish CTF/BTF debug info emission. */ @@ -1024,11 +1000,10 @@ ctf_debug_early_finish (const char * filename) void ctf_debug_finish (const char * filename) { - /* Emit BTF debug info here when CO-RE relocations need to be generated. - BTF with CO-RE relocations needs to be generated when CO-RE is in effect - for the BPF target. */ - if (btf_debuginfo_p () && btf_with_core_debuginfo_p ()) - ctf_debug_finalize (filename, btf_debuginfo_p ()); + /* Emit BTF late, unless this is an LTO build in which case it was + already done early. */ + if (btf_debuginfo_p () && !flag_lto) + btf_finish (filename); } #include "gt-dwarf2ctf.h" diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index f90f7b1cfef2..e00735a37895 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -33242,8 +33242,6 @@ dwarf2out_early_finish (const char *filename) ctf_debug_do_cu (comp_unit_die ()); for (limbo_die_node *node = limbo_die_list; node; node = node->next) ctf_debug_do_cu (node->die); - /* Post process the debug data in the CTF container if necessary. */ - ctf_debug_init_postprocess (btf_debuginfo_p ()); ctf_debug_early_finish (filename); }