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 B84753858C60 for ; Thu, 30 May 2024 21:32:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B84753858C60 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 B84753858C60 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1717104782; cv=pass; b=c0T90duK8orgkQw4YkMLQuPnwHGL6SqEFedOShafIiWTOnECwy7Ffj21SttRjjsCrYljen6pENevq3LXrwJ9IYaVux0ZgP4cQ00hhianJRNup83MjPhWkGQF1lghwZPdYCG6y1KLTbHobopOHcYGgo2odAtf+nCQByuKyR+6whw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1717104782; c=relaxed/simple; bh=JeaR6SiGLRVZB5SD1qbXnueKliVNJiHyV0celF26QHg=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=DX1lg8ZghJigTS7EbaScvexqvLhwYSeVsp9ttP0nz+z1XH+XAq70IN5vOhcctzfwbHGOSROacBk5S74UwSecn0eaUDzSelMWXz+A6VHKNxU2thY1FyJ2nFnJHF9f/dMv/XltBqjYHAV6okwLnSx0DA8rqvDrgrQflWa9osMJwWg= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44UF5UnR006377 for ; Thu, 30 May 2024 21:32:58 GMT DKIM-Signature: =?UTF-8?Q?v=3D1;_a=3Drsa-sha256;_c=3Drelaxed/relaxed;_d=3Doracle.com;_h?= =?UTF-8?Q?=3Dcc:content-transfer-encoding:content-type:date:from:in-reply?= =?UTF-8?Q?-to:message-id:mime-version:references:subject:to;_s=3Dcorp-202?= =?UTF-8?Q?3-11-20;_bh=3DGVB7GNGZnK7QSH/CK4sNpGVyYOiW4fF6rlDYADO3biE=3D;_b?= =?UTF-8?Q?=3DJNA88b89AWmQTjUh1Jw0q7CQLvqQbYKiuCoRs69c9g6CvwExAIhgRuCIUjYf?= =?UTF-8?Q?P2gqu2RA_FO+2n1GwAaqE7AzwN09QsYiD4Mn6Db6vsjbrDz7mmaTCgn7tZLt58N?= =?UTF-8?Q?SMLZaq14VNjcVU_1YKY3M17ZhWhLN7rSKBCznrguuQMUMRmgZcLPATDmYBHakyH?= =?UTF-8?Q?VVllYcxy9CyPTkb9Fdqb_CPUsjvfcUKLW2QsqmXWYt4slUYu2Ma8UhCGTIioOwf?= =?UTF-8?Q?OlEedPfZqjtyntqesbukaEoiRB_WfgzwmKFi1NARhsbXoOUeCPdZDqEWHcJO5TN?= =?UTF-8?Q?lW7rwOme6wptfIM3ZBJiNZc1wFlmewmx_Dw=3D=3D_?= Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3yb8p7svyq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 May 2024 21:32:58 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44UJeLgW026564 for ; Thu, 30 May 2024 21:32:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3yc50945rh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 May 2024 21:32:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WaKiFnpZk1Lbv+NpXgha41NeTw1K1Isz/1nCV16OImOTycfZOyITEuyntYRJswtr7iAoiDaB1pjj+wU47k+F3KP4lws4HFf+xK+Kbnn+u/m8f0hezj3T4RcHzmkpfqzOMZ59tBykvXU2btXQiayqOmumyZSYH6Z5M/Oa9+86ddo+WkkMVMS48pkFKrkkCUU37ij4VpWbH9WDih7M0QdMvCVUciPOQkp+Vt3pY05JNIzF4HCNxh2BzOVtGXrd41RNetg55QYbaCfSl56Sy3Ujz5qZeqYcWfv/M3BDJan4t3+wmi/btJbPPCqRUr1CW9nXjk4FOmUCd+D3FIO8VUCx3w== 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=GVB7GNGZnK7QSH/CK4sNpGVyYOiW4fF6rlDYADO3biE=; b=iqCm7KAuiySivH8aCK4HPlmYDJFtnbIZDrKCbhjBTPRbGdN5DAN3bUQDkOKRUmg4VNdVi5NxpKufBViLqTgaDLSvxosleuqcxOL1i28/DVN7rcAfZVbdQVFniB6F5ZMsh+1ZQE5B3kE61QfTpkj1Nha1lC7M6y6vnhV7cp9UXNNKlDuMmC90yTSoV1t71g/tRaQQ+pENxohORPbi33OtfLVyOcc2u8ca1a2vtl8Ik9TXXUsNSTgIx6+gyZ34yrICWrTh4/+SXmNxpyWp1wYDJe6iK8eI9I5uDLX/NloOOIBN/4t+J9Lq+oD5p90R4Z1vHIWMu8R1x3shtVfVhYL/HA== 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=GVB7GNGZnK7QSH/CK4sNpGVyYOiW4fF6rlDYADO3biE=; b=FyzqbzAsO1Sxq5wGJ4nDpqNWaDJbXfUkm33rbgQo0efvKi/lBDB9rKLicGjnufV5KLf/wjRhGUhKBPA20nALY7iwkD7affDRX0T410iuZT7YHiSxVzgKtA1S4jzc0AHkhZlB7bs+HQmHD/Yw7R7toFXF/Oxl36vGRtbOgL7ijSA= Received: from CH3PR10MB7958.namprd10.prod.outlook.com (2603:10b6:610:1c9::10) by IA0PR10MB6745.namprd10.prod.outlook.com (2603:10b6:208:43f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.35; Thu, 30 May 2024 21:32:55 +0000 Received: from CH3PR10MB7958.namprd10.prod.outlook.com ([fe80::dbde:7e3c:e5de:811e]) by CH3PR10MB7958.namprd10.prod.outlook.com ([fe80::dbde:7e3c:e5de:811e%4]) with mapi id 15.20.7611.030; Thu, 30 May 2024 21:32:55 +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 v3 1/6] ctf, btf: restructure CTF/BTF emission Date: Thu, 30 May 2024 14:32:16 -0700 Message-ID: <20240530213222.440435-2-david.faust@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240530213222.440435-1-david.faust@oracle.com> References: <20240530213222.440435-1-david.faust@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0252.namprd03.prod.outlook.com (2603:10b6:303:b4::17) To CH3PR10MB7958.namprd10.prod.outlook.com (2603:10b6:610:1c9::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7958:EE_|IA0PR10MB6745:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bd86497-8c74-4db6-d8d6-08dc80f01155 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rB0OdKnyQgrf9JMJ9Y5B4pu/1qFSRJtJHSDRmOOVrLPvXSo641vi2TA3ZERJ?= =?us-ascii?Q?2Hwk834J1Lvl0c2Gv/+PbdLUeBYkF9nhmMrL6UuXbLZ47W7G9MvYpqiPtElm?= =?us-ascii?Q?ucrNB9agkdugDJQS9qfYxnv9Z+PXSqQqQLmUjLbEmIsaFFebLzqq6Wc5cJrc?= =?us-ascii?Q?QYQlIoGpNFouL+ci1VJaXB/bl9KS6rpycQSwGwDRtqSeSrE4c23hMc6qYGnG?= =?us-ascii?Q?Ybai3H2Pju7GnoK++2IoeVAqGeffMKK+mbivV1DKpcbw0K2fiQceudDIfL/0?= =?us-ascii?Q?8qoMru2xjncXELzWPt9v77jt+PCTCcZ1pMd/B3awLvsSmxPV495oh2BYUQBJ?= =?us-ascii?Q?MCBV3LYq7BhE3GiUTYVQlZjH5/r5cQaYKH0DzSdMbkW0YybC7eWnDQK7BeO1?= =?us-ascii?Q?JtQEg28oJDtfv99sJ+JVitf31FOVbR68/FRtOcCWP0v3pCYrzLnytdpF5OcZ?= =?us-ascii?Q?rtWY+JR1skLmDGCUPLtHrHRf0iepLYa05+PCDSDfSc7NJ4e2QHD3wzE5co/r?= =?us-ascii?Q?ml0a8waSR563+6D48rKsRN2+OpfD+9bFf3S88BiOglarkhEAaSIFpEt/ruIS?= =?us-ascii?Q?az/NisUZMkveouTmG2JflS5bO5UhgDyWfFB9rYk5g6nfKNLeqzH+o/PnVdzs?= =?us-ascii?Q?1PDdyIX33DY3eWHYWi7r4YTkA+Vsr0X0OEmB0ljcE6ItfYmCUULrKVAWi2vT?= =?us-ascii?Q?gRRc7KyIeJtxPYmaj3hrTce5Uan65Qsz8u/NcRNdY4mieBIAt8nMPFWLmiPD?= =?us-ascii?Q?ZJrf9HH0/lmI4BfWDvf2LDpnQPs4LiYwl6L+GyRYEi2sTEnlrrEFgNuf56KY?= =?us-ascii?Q?JokaDej94B4aQKsQynuoVYaqqGnM1OrQ7Ho1FohlafIGL8KX2VKhWW+aMrxV?= =?us-ascii?Q?Fgf5Va0lkp2c0r2DnUnnp0pg9h+NhpCfe2R1sTzTnDyqj+jEE6YxQyJgPaOh?= =?us-ascii?Q?1/len1y9KtYlNdHP8SrPA/PcZTuP8EqoRAUpINqxXLfV7nTTykkQ5R71Ly2n?= =?us-ascii?Q?2sR2JwfGEj4cj8a6QTZa5+GUqElDVG7ZXBx0PVDi6qnrPxM7vH6R5H2QeBRt?= =?us-ascii?Q?VtB8fzCk91r24MGRAWEuNHgOTvlr3PqhYQZt/h5cWxYW5iwJg6ETdxNU/fb6?= =?us-ascii?Q?qvOUukxMFg1fRjf80t3gQ5SFHZ9KsuFhreRUHhBTgoSuEs0of38kqge/bLdF?= =?us-ascii?Q?RIi2RVIYoPRyHNJANu68DMExteKTPxWucKFIdybJ8OL0olKRY3qj1ZATjlQw?= =?us-ascii?Q?2VrUgLeOiw7eECzbVDlWMi9B1qYMQZbynekUGG1+GQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7958.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vfvznQyUXv4RLtMqak/v/6Jl2NEcx0fU2n60GtckLv/Z+Nm4Y8YYOpn3Lo8K?= =?us-ascii?Q?6oTjGe7NYMo6c2aW5y8AoTmxqLNPebyPCjfLUNkHojZpoQjIoeIexw3R0YmA?= =?us-ascii?Q?sGlimfxjo+rhpBZpQ5+Lq9FrrCcgtJ6sUmhlcg9u6XbnMOS47rfbzgCfANZs?= =?us-ascii?Q?bnebV6j46nNje1/+563H6utdnYjOpjMW+3KjpYU/SGdZmZthcvKsCgpqEGcL?= =?us-ascii?Q?f4aLDrYQYXgmv6Fpci2SQZ/UQXG+KIuirTY9YW7u3iGFO6KQBAqd+e2nqivB?= =?us-ascii?Q?TKJ7n5SHXVWbpIidC7rHyPfSjL7quvHVxyufcXXHNryw0AIELBiIuWI0hyBr?= =?us-ascii?Q?xa+K8/6MDsFeDPezQ9+XuMSN2R2u303kfUG1mYPHWowm2GooAWZFWYLdswrm?= =?us-ascii?Q?+wPSw9TMRN3DPOpm/jBw4l14pkOqonWPg8PBgAoGOgxly/r5HLtKln2j/wig?= =?us-ascii?Q?2WSo94Yz/6rn0o/ENukd9X0ugT2Nx8ugMlQ330YDDJ2+aF5x328nRX2DgrRd?= =?us-ascii?Q?rwSjI/RGp0gy0GKwzAAtvRpPedws810IWuB/zguEpykt+Sx+439l8Hcp6swm?= =?us-ascii?Q?IuAWCBk871Vmymxtsc+SgtjRYlwi4nt/IWmVhEJ6+sOkqRqcu1mbbwuz4ZzT?= =?us-ascii?Q?CBaaw1VGOqo0jxH5RhfNS1OyMevNwpZa7XkP/zAtE+ian4jvIJ4tsuWd4zqE?= =?us-ascii?Q?FKF6KDJSyNyUHDut6Ok1AEGSjcjnuv1377W9gYtOgFUdHP56S05oHcGhIcv9?= =?us-ascii?Q?IY5L8JadclFJhOWs/B+ajcvhSGh5w7gLqgkKIItrKQP0UEFsNudniRBI0eAV?= =?us-ascii?Q?6fXqm12P/3d1PSywOYJdvbFhGRBATo0vmnqKtEur3IYiGyUPf4fHjnc64C5U?= =?us-ascii?Q?WY1rK6s+xUof+eXKXYNLUYstMagJsaeR7nTczZLSFjxTm7vNUBMb3vIhbG+N?= =?us-ascii?Q?Rs5A+0F9KafURMVIBey4QjcH+B2KFMwZaZ9BTbZ4G066fyyc/yzbahfwfQE4?= =?us-ascii?Q?23xxqW32CHTBsisnJaxZFhYe5JeRQxyBNulvR7BPkE3tEAAiifIxJzLk94ye?= =?us-ascii?Q?f0054yi3ua/t1wW6fyxidbUJibigJWJHXW/+M3JFI69kchaeZLb5O80n9vPU?= =?us-ascii?Q?8jp5H/n50ID+fknGA7CeYpyZwkDDMGqk0czITlHD31UX2mnp4lk9rYmJw8SH?= =?us-ascii?Q?70lHD2s1wOmxsEuH9DENhSaW+vFUNc56sFAF22uhrBH3j2+lSTy8oNAqYj72?= =?us-ascii?Q?O8jg27jsaKdVgtfsSntoHSOdzbVVpci3vKZeMAFz72TsgsmfoWkrc00+IBXy?= =?us-ascii?Q?0u+JIOAiSrMv8jfbZauHDLsxAchpuJ3KolgN89FXzJ5hBqAXz5n7jnj9feS0?= =?us-ascii?Q?LVYu6auxQQMd1928hV/GURgC3k3ZYoxgm1VTl1ZBsozbuXf7I3Z79YInslw7?= =?us-ascii?Q?4rkpUi2Enhf7+ZFIfnviNl0793zJyyi6YhxLEdEHqhQG5+eeiJD7p+IrB19i?= =?us-ascii?Q?L9KOJ0YTodJd7FKOg1Z2fB2gHYNsqkUZibp+lRK97dBMcIb15gAgGlluyJpR?= =?us-ascii?Q?IysjIS+wImoCa/BiQnYGe1TOFDpiw2CPk+EjJJ79wUz9Vaz8zZWfTQIpaA5g?= =?us-ascii?Q?Yw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eOwL1LP3uoK4aISRiixA2Uz7B8UIJKxTXAcm9GkixuEDA4jC8cp3pGvQQQjQSi3u60dOMRTtv1CmKqumxkb7eB5M9EqOZzikrhSm8lXvYksuw4u7Xvurt4y244YqiIYLZeZ2WFlplSa3XuDRFc7jgBaKAxRDeryyQ4KUZ8LgTUpUUTxCTbRMLbi9lBe7d5T/e1seOzFRIPXlXBVRt2V05iXRx/MmY5i7W8zKrBCHYGDZKC6UOEmS10DSEJ0YH16gZK4xgas4LZX8F87/W6uFtsiEh3LJS90gQpqVldmmQY34Ovwx8KAVV/x8uqHofgyNk2xpWCWKekxPGPIYAyi0g7dKisgbT12ghrLJEKKL4KytcSM53C7NQSdRPb5NxRYoHA6A3Z+0I8OOzmIrYKQOosGO8t8/UdbbzC6nrwfZoemnK1XlDrWWF4ID94n4A0KKtxS5x2BmopIK1CQnQSoe6/Jpc9mK/Pu7SjDhZwLOjsdJoPyk9KOCA6pNhDarJ8U3sfCqX+yj7OiW2uz5tDiu2WKLBvgSkZSru5MdK522+P+N+ea6tKpn6ZjGBq5zsGaEmQ/++S14ACavbvsZFDUBLCT5WnePk7cYWrqgDO3EIIc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bd86497-8c74-4db6-d8d6-08dc80f01155 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7958.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 21:32:55.2258 (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: BvrDYRh5Stcro1xT7dM6VjeqYbdxGYqundj8iVUEpVTEJGSubhHIk9JU3T4MKuY0h3gAAXhykvIuMDbzO7Bg9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6745 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-30_17,2024-05-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405300161 X-Proofpoint-ORIG-GUID: HscwfH1Het_3azS3kt7eBLCiTHv7L4gg X-Proofpoint-GUID: HscwfH1Het_3azS3kt7eBLCiTHv7L4gg X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,KAM_DMARC_QUARANTINE,RCVD_IN_MSPIKE_H3,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 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..1b6a9ed811f0 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 + CO-RE information is created, 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 5b064ffd78ad..e406df8673ce 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -33202,8 +33202,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); } -- 2.43.0