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 C39913858D37 for ; Wed, 17 Apr 2024 17:55:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C39913858D37 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 C39913858D37 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=1713376544; cv=pass; b=lmaJIPpJv12M0aDBgjj2GlKld/lD0MyuosWNmIcXMU742MM9WEYViOMmYy64DwVIOql3HLi7CsMaPbdcBYJSOFGtqUmWBjPiNp1CyBwp1genzQ6Bc6pSBMeHYZ9QLp+bzFOIaeTU6JGKywJLk5KUhE58hTlnxMBTAc7tP5uoPxI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713376544; c=relaxed/simple; bh=5IeDI53As9yNf3awuSmUX4VxdtM1CaO9r61SVyZT2lE=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=Z3KJJrxfkSp4k5DNEhraGIdV4P0ehYXSkojH+o2X2Ka+hvgMEzMzMvSFdjnkXkUnpSk5JncVmHGfTLEj7GijwvUoQZ41jnuidIywqwctZv5cRvdVy3tkMUSn//k73yWsTVFA8PjsYZCLycBsvcvCbSWeWTJlK4LKpqfQU2lgYGU= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43HHiUMO019595 for ; Wed, 17 Apr 2024 17:55:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : content-type : mime-version; s=corp-2023-11-20; bh=Lh5v1CqMZ9Da6hisOoq+skBAy1Nt0veEVn0HsYLX264=; b=EVBPDlN5eoWXRkBeUzM/gp8wTmg34NncMCscK5A7bhIa67R5uBYwHlLZhg/5V+GvMj8L RqcKqn0Viy3cEmRDh8xDRgsmwQEEbaalDDL44BKZ+JnZ+j/ytgyww0lC/sRhUOQUzVal m1Qx+E9Aff/g0fLxEi5e+wH74/0qdK/0XLG/6BCbsLB+Gp84sMux/ZsnhCbKC1mGDceO sE48ITy0o4XKkzGL/UEML/yBEIgg3e5onGmD0/Jt74vU8+vlcMn0nlV2kUpk5dD2ixcW lfgr7P/3kvBD+UiP8ur2T4qBXe56Ov4KpPSfiinENd19Fg4w30+XGbzBptoW8ETN65Ip 4A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfjkv8g1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 17:55:40 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43HHUtui029172 for ; Wed, 17 Apr 2024 17:55:39 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xfgg96npj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 17:55:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gDE9xhByg7tyIExti0QDPGG5owHpjubXc8sGYlK8qSQlXelLr/fgMPU2cOSXDXXqw932/02p7xb1v5q4TGIGXn6734g2swRoi+wnpifn85w4dwERQLLAHxcIj7ZJQWcsRfj/euzgYadJoJF42Uz0zYq+zh2NNQr4/MU8efyn/1p4sPJwFALIzXSkvJKK/0vDevYIP8y4G/rjUmIqAftWG4Wq6Mf9Cx4leY48qXDVW5mOo2ORHepMLLJXpDWRKikSuMs3q6ojG4pVXDSr/v8ItgSOb82j+lBSS5OspwGu8oFRos2gpZTsftvgq21vNBcXHmwWlwMCEHlqbgE8cgFhew== 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=Lh5v1CqMZ9Da6hisOoq+skBAy1Nt0veEVn0HsYLX264=; b=ajOucjsp5oy56Jr4ZoQwgql2x2oK7ei9rHvTWtPo2KxxiL2PM3x5777bgaXLXBQeei0bwNmPF8nlhBIKb4oy70PmV/0M6lyyKE+AnepOyY9OQmuEOMX+hS13AXCTjt74TuLRPB/g1uqZDYIxw0TNkauAEOxONnu5yERCREk5HYlUJ8Bhg4uAhNyyZyfsXT/IGXL3rnIk5jZebPfHu4SQBEOFVWhZPEmX4Btbi3le4a2M66nfO2I6GP9lF7bEYinRvHU6bDJFv3vtmHh1R+6xURTZRPd4R5iXqK8XLNr7bVzUph1UAy5MwcD/W9u5hzDnFy93qlKtFIzLtkQyASm+vw== 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=Lh5v1CqMZ9Da6hisOoq+skBAy1Nt0veEVn0HsYLX264=; b=CgCr9ePngJvGFIYB7j9STcH1BOAqxOJLVpg133EsOd28CHv8SxNmJ6mz31XcR5J0yNWELA4TIcrplrytr2G2gDAocrn05bSdleCrQ85g1ECsAhGctcKqmzX3hb9CwRGtovvCkdboYHZslxRQ3noAzPqgTDfzPzoWI74QgPuQLA8= Received: from DM6PR10MB3113.namprd10.prod.outlook.com (2603:10b6:5:1a7::12) by CY8PR10MB6491.namprd10.prod.outlook.com (2603:10b6:930:5d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Wed, 17 Apr 2024 17:55:31 +0000 Received: from DM6PR10MB3113.namprd10.prod.outlook.com ([fe80::aa3:c80a:fc6d:d1f8]) by DM6PR10MB3113.namprd10.prod.outlook.com ([fe80::aa3:c80a:fc6d:d1f8%4]) with mapi id 15.20.7472.037; Wed, 17 Apr 2024 17:55:31 +0000 From: "Jose E. Marchesi" To: Cupertino Miranda Cc: gcc-patches@gcc.gnu.org, david.faust@oracle.com, elena.zannoni@oracle.com Subject: Re: [PATCH 3/3] bpf: add line_info support to BTF.ext section. In-Reply-To: <87mspr6fsq.fsf@oracle.com> (Jose E. Marchesi's message of "Wed, 17 Apr 2024 19:48:53 +0200") References: <20240411111118.215612-1-cupertino.miranda@oracle.com> <20240411111118.215612-3-cupertino.miranda@oracle.com> <87il0g81i3.fsf@oracle.com> <87mspsj8ja.fsf@oracle.com> <87mspr6fsq.fsf@oracle.com> Date: Wed, 17 Apr 2024 19:55:27 +0200 Message-ID: <87cyqn6fhs.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: text/plain X-ClientProxiedBy: AM0PR10CA0111.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::28) To DM6PR10MB3113.namprd10.prod.outlook.com (2603:10b6:5:1a7::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB3113:EE_|CY8PR10MB6491:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a9cf1ac-dcab-48e5-1c9e-08dc5f0792b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yseTEZI38hXuveukW2fEYtcvLN+qB9cRlwzu9fr94p7d2vPNg4dtoSL7RvbD?= =?us-ascii?Q?+LGcFrcPrh7UAHhvqvnsS5DeI+Surp9bOv6MKZO5guLWTexLAdmK2r7cKKjN?= =?us-ascii?Q?kT9/1ptNHCwN+ahZfaBEUHXw/EePw3IZBtMqjNAAfbhdz5VkWHMyWAkNE9h8?= =?us-ascii?Q?zpKtMg6tEYMnhUrznyxE+r0qt7c4lUW/+uE3uYvymSVW/+WrS5juAQt/AlTn?= =?us-ascii?Q?1OWPtUyGqq0xD56/uIBPjC23gYLJEcWETqUR+bpUCMKTWZ4K2km/cFoZeotR?= =?us-ascii?Q?XFDGStVtwEuhiDHi1FFuJjTokM3mDobWZP1LPPOXUUe/obsVVu66if12yyNS?= =?us-ascii?Q?qZ+7wkjr11P3UdjX4mv55mt+S77wVuHm7AcGoFpaEoyrBiRxUIZ6ox7AHL39?= =?us-ascii?Q?VfUi+SHUcuIBiTP41b8FLAt8+P4QfgG7jaMldKamtvTltwvGNIYWT7VqU7+C?= =?us-ascii?Q?6vEbT12+uo4f4eye8A2Oj2fo2CKk6PWyRBauLjo2pRPy6nYprb7gAt1d++7d?= =?us-ascii?Q?DAblC9NUebBg9v0D/UB4OXIGNPOMs2B7zfRo9Ub1tXli/B+tOjz10hmUfv4f?= =?us-ascii?Q?iyDYZa1Lnokov1t7dfjLblOFfODDl1wnhKEzTDxOoR/kDYU8fTSxs+XeMmsN?= =?us-ascii?Q?zhqIHJY79ReTd3Z8p474Hj+xBeKl89fYISpcJ2ckaVByKraQRahpl7CxTBgX?= =?us-ascii?Q?ZqoV7xt6fXZnVeJZF+9kC/cYtG8j8/NJeUTdybzLbOiTZocRlERR8rMgVlGU?= =?us-ascii?Q?uzpTgooIbYLuVGaRyIcfqmeac/tUa1S2lhvJ/HnJRMvkOIwa4Co1PRP11Cgx?= =?us-ascii?Q?W3+rxS4W71tfLeP4HSmMzVtlE3kB6j6ThhXquf9MkUsnlHgxNmZOvBmmcez5?= =?us-ascii?Q?y2fMuavwzw/0U1s5lv2h3t56ewfCcCq+5x4qb2wI/sXKCTC0i8Z6k1RB4OAs?= =?us-ascii?Q?nupsXHVVQmQnsgMociM2KVfH6RbtsWbZyMO3TWipgung0LJo43ThEfQxLH40?= =?us-ascii?Q?b8hhTvyB1kiSLLgJSDFbQRGRSTBeQSla+SHXR4hrKh41NvEle5dAfTTP662L?= =?us-ascii?Q?jzC52/3OSzXebluAfO44wdHTIi8maPABqyGSFG8nihxhBfonPWLXqZ/9naaC?= =?us-ascii?Q?+YKAEZG43QLzaBo+Xr/ygvXVf1mhAj8eGST9TAmtCrEmASORDyiNfJAHxAol?= =?us-ascii?Q?J7mS6SG5Fa44X8p92LrlK+hcqbVHG0Y4GZtErP6OrE2PHoyB8pY9zCDkfVV6?= =?us-ascii?Q?LhavEvUQMKyQuIN/Bbt2yTBU2YwDll+c4/6wyYCODQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?nzqgNvmcu/e7wXErLwebSoAUnHioSydmJNvPFIAdda0exrpsI0EXMLqhPFys?= =?us-ascii?Q?29akA185CnOOrdHQ1cjnrg8B8u1q1qvgcN6Rg4NyXJrLtPVB0QWpHFi2QszB?= =?us-ascii?Q?R+h0GErjNWnenX0rv7Dp4ViUlmQIxxdjx34Bw0cAmzyV+Yx5NSq0qk0dr4UK?= =?us-ascii?Q?GvM/rZ5ofqlhfkR/U9BiOmI2HgpeFpkUfvn74VTar5dR6XB4pbGmy6WzPUsl?= =?us-ascii?Q?WdoXgRgZ/nPG13wIhyt2MK80Mpz403zZj/oZLNUogRPt6hfDi+flYGBv9CL1?= =?us-ascii?Q?12XnYDYxGCgGV56D8CIbWjrb9L0uDiOddl7M9UPzNPD2CY8DX3L2ZriIyfu0?= =?us-ascii?Q?kr1vGhcc8XfGt5kwmRWIV4gq5It3bKZ70iw8LHSeSsZwBaXDl6bnJ7tWCZoW?= =?us-ascii?Q?xEYp4Eo51byJzyqRgnNmD0OPV+2g+KXuazMUd+sfgveoeX+lIjQdy1tgZn80?= =?us-ascii?Q?3/m8oGCzkgvVNXCNtK9s/2uoUa0crI32ypKsuYY9S8C4FKwOBO4ULDVQOGTY?= =?us-ascii?Q?8AizOUDegnfFKPR1VCLiEAruyQSKcs7ZSlQKF8sMdAvOeo9UsfeIbTt6egqp?= =?us-ascii?Q?/bMTF/OiCOvUj0hWkrnLh0K8GmeunnIaANVEOpclWWFLbRM0KyudmAWuU0B5?= =?us-ascii?Q?F783ROzfUqAwEMO27UM3zhm7kK6yvV96huHKrEAwjSdsLeZ0QGNOqSOBx4dx?= =?us-ascii?Q?xk+VxkklnuWCcHI5Y0yjyUeYQwUUuteVNgvUGA+aEAvDZfVvm0SWsDdvVD+/?= =?us-ascii?Q?0VyyKaxnWUDGM7P+N8X9/fpgTzG+G6xjO4FzcfnrqAhu00AO1kBxshEy7JlS?= =?us-ascii?Q?N4UqcqkFuMO/6ykaedi+vNdrw9UP/wd9JqT2/1t3VO0S2rUUTumfD0WftLlq?= =?us-ascii?Q?+6DoVePTGE736OT96ufutQLnK4UWJOaYkt+IfVynJ7LmCQFZAaAv0+pFUeNq?= =?us-ascii?Q?Fu5NdfUqkColwbPD1X9Tqz92WM6/ckn7U2wsVuKNpsrUmAGkuWfAXQvTLdsM?= =?us-ascii?Q?8FuuXbfnG5et0ozaGJ5tswbXzfJgLGnmRnO7A5IjWbIZEii6axrgKqgvF28l?= =?us-ascii?Q?kHUznWefPBpdKLy13Nv8IBHp9OqKYAjyskCA2OeHzyEmjQjx4iVzilpyBHm5?= =?us-ascii?Q?cnRotiHs3rQMQrwdAhZT4wUL3TWex2fWsToxTzEXL1a/OxSGJeUrHEt6/jgp?= =?us-ascii?Q?QFdoHIonN0A0SuZyOlWh8tMoXGNK1OAPX30N2jLZ2JNezLRWqUG7kyWw/fUj?= =?us-ascii?Q?DJBDbPZkiWyTHt+v9EZ9hXsAeaMml8x/yAyigVYcv/J/XHR0uSJYTDC3QvTD?= =?us-ascii?Q?0S+PYgR3q1Jyvga9zMPw4q1qFFDqxMeRLkHSYUkhZJV25wL7QTQhD93UHJ+i?= =?us-ascii?Q?BXzBCr0BBXf9M/CxLrvTWxIDgerpplxpCP6z22/k5EGPiphloYC3pvCS3vOb?= =?us-ascii?Q?gTrPc+qmIjOvwB3E/nIY3xkBvhTQ1shUA8Jl8nJhyESPeyMsvvJdRKh07F4l?= =?us-ascii?Q?fb1Xgj822mGb7xJp6v4nN2jEpX8ok2p5tvpXPC6rguZWuYpulEhjBNe4WmQJ?= =?us-ascii?Q?Rfeb+fksa/gEqjcUU6HmR2DHHFt2QE0vHgcOoWff8dBZ5b7mMfr5Y0yfgz56?= =?us-ascii?Q?vA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 4oRh7R9BeDdg0UN6Cym19Ice7SFCARECp733f+KM5+eJncAdDSQiV7xKx+1PI0iNkgTMCKPpNnZ2Lt54O33cBtHkpeRYTXYNj7B57svmcAi7qttknsXUErQ9gxq4UkA2rrFuBZcWKm9vzovddE/ZPP8QdB1913xFvVWCv0VCuV9eDy6m3dUK/stFr7Um7iiqssKC5R7uPky1gZuohyv7M3xYZX4A2gjTvPZToV+p9rSqcHMtngqulVrLJFxYsGQHcCqXJCurzDYauz8eyk4moHNVyAy8u+doDbJ/gzUUgluGXNfB5FaVjhNx/zYSk73XHlIwhyTs0rFr4spFIkU56AtvLFBSIJNLAtI8EpLPP0F5W8f11Pk9kQjV9S811OjsTGvwwVxT18Ei7y4PqO9puCsIo/KSvi53Q78dWbv3zOePztIZBIa/QuK5pZ3u6REpydSqxMB/p45pRVEWEp6kuxF68W2l7F/vGHtFu3+bkIhjpoNtySvsUmMG9UbVV0D+Yjz5YT08cWfHoPpwmJ+ZuIIeO/NK3kYEFM5IatmSyVsffcUPt6ZOW2+wgE7CKssrMisNpKV2OwKa/DUB639eETc0K79LVAVJu3RKpqFXyMc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a9cf1ac-dcab-48e5-1c9e-08dc5f0792b9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:55:31.3022 (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: ThI2mLCW6KY2qnG/a4SjwdYCrD6RMgdXCHGbz8HLbzaMyD4l8V00H5a1jXJZclZaPBvIZiGMWp9g16GjBoJmM5swd8o/3jP1ddC5FG6uKWI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6491 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-17_14,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 malwarescore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170126 X-Proofpoint-ORIG-GUID: ZN9uLRUCUn0ZK6w90bwDS23s-G2kzPUf X-Proofpoint-GUID: ZN9uLRUCUn0ZK6w90bwDS23s-G2kzPUf X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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: >> Jose E. Marchesi writes: >> >>> Hi Cuper. >>> Thanks for the patch. >>> >>>> This patch adds line_info debug information support to .BTF.ext >>>> sections. >>>> Line info information is used by the BPF verifier to improve error >>>> reporting and give more precise source core referenced errors. >>>> >>>> gcc/Changelog: >>>> * config/bpf/bpf-protos.h (bpf_output_call): Change prototype. >>>> * config/bpf/bpf.cc (bpf_output_call): Change to adapt operands >>>> and return >>>> the instruction template instead of emmidiatelly emit asm and >>>> not allow proper final expected execution flow. >>>> (bpf_output_line_info): Add function to introduce line info >>>> entries in respective structures >>>> (bpf_asm_out_unwind_emit): Add function as hook to >>>> TARGET_ASM_UNWIND_EMIT. This hook is called before any >>>> instruction is emitted. >>> >>> Is it actually necessary to emit a label (plus .BTF.ext entry) for every >>> instruction? >> Maybe BPF would be Ok (not complaining of missing line_info) with just a >> single entry per function pointing to the entry instruction. That >> is not what clang does. Don't know if it emits any labels either. >> >> It is probably possible to add some logic to compute the offset from >> the function label and emit with an offset to the instruction >> location. In case of inline assembly we could add a symbol after, and >> restart offset computation. It will need to add code to compute the >> instruction encoding size, and increment function label offset each >> time we emit an instruction. >> >> Still, my personal preference is to create those labels to properly >> compute instruction location then some rather intricate solution that >> would lead to future complications. I know BPF is not like all the >> other targets, but I am thinking of assembly/linker relaxation. >> >> WDYT ? > > What I meant is: if it is not required to emit a line_info entry for > _every_ BPF instruction, but only for the instructions that "change" the > current location, then we better do so? > > Then, regarding the labels, I assume their purpose is to get the > assembler to fill in the `insn_off' field of the bpf_line_info in the > .BTF.ext section: > > struct bpf_line_info { > __u32 insn_off; /* [0, insn_cnt - 1] */ > __u32 file_name_off; /* offset to string table for the filename */ > __u32 line_off; /* offset to string table for the source line */ > __u32 line_col; /* line number and column number */ > }; > > Which makes sense, since "instruction offset" is really the business of > the assembler, not the compiler. I agree with you making it the > compiler's business would be overcomplicated, given inline assembly and > variable-sized BPF instructions... > > So, what about moving the task of creating these line_info entries > entirely to the assembler? GCC already knows how to emit .file and .loc > directives to track location info in DWARF. > > The BPF assembler could then process these and create entries in > .BTF.ext for line_info, all the fields above: insn_off, file_name_off, > line_off and line_col. Regarding file_name_off, hopefully it will be possible to make the assembler to simply expand the string table in .BTF (with the strings read from .file directives) without having to understand/redo the whole BTF section... >>>> * config/bpf/bpf.md: Change calls to bpf_output_call. >>>> * config/bpf/btfext-out.cc (struct btf_ext_lineinfo): Add fields >>>> to struct. >>>> (bpf_create_lineinfo, btf_add_line_info_for): Add support >>>> function to insert line_info data in respective structures. >>>> (output_btfext_line_info): Function to emit line_info data in >>>> .BTF.ext section. >>>> (btf_ext_output): Call output_btfext_line_info. >>>> * config/bpf/btfext-out.h: Add prototype for >>>> btf_add_line_info_for. >>>> --- >>>> gcc/config/bpf/bpf-protos.h | 2 +- >>>> gcc/config/bpf/bpf.cc | 103 ++++++++++++++--- >>>> gcc/config/bpf/bpf.md | 4 +- >>>> gcc/config/bpf/btfext-out.cc | 108 +++++++++++++++++- >>>> gcc/config/bpf/btfext-out.h | 4 + >>>> .../gcc.target/bpf/btfext-funcinfo.c | 3 +- >>>> 6 files changed, 203 insertions(+), 21 deletions(-) >>>> >>>> diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h >>>> index b4866d34209..ddaca50af69 100644 >>>> --- a/gcc/config/bpf/bpf-protos.h >>>> +++ b/gcc/config/bpf/bpf-protos.h >>>> @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see >>>> /* Routines implemented in bpf.cc. */ >>>> >>>> extern HOST_WIDE_INT bpf_initial_elimination_offset (int, int); >>>> -extern const char *bpf_output_call (rtx); >>>> +extern const char *bpf_output_call (const char *templ, rtx *, int target_index); >>>> extern void bpf_target_macros (cpp_reader *); >>>> extern void bpf_print_operand (FILE *, rtx, int); >>>> extern void bpf_print_operand_address (FILE *, rtx); >>>> diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc >>>> index d9141dd625a..f1a8eb8d62c 100644 >>>> --- a/gcc/config/bpf/bpf.cc >>>> +++ b/gcc/config/bpf/bpf.cc >>>> @@ -754,14 +754,12 @@ bpf_output_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED) >>>> bpf.md. */ >>>> >>>> const char * >>>> -bpf_output_call (rtx target) >>>> +bpf_output_call (const char *templ, rtx *operands, int target_index) >>>> { >>>> - rtx xops[1]; >>>> - >>>> + rtx target = operands[target_index]; >>>> switch (GET_CODE (target)) >>>> { >>>> case CONST_INT: >>>> - output_asm_insn ("call\t%0", &target); >>>> break; >>>> case SYMBOL_REF: >>>> { >>>> @@ -774,26 +772,20 @@ bpf_output_call (rtx target) >>>> { >>>> tree attr_args = TREE_VALUE (attr); >>>> >>>> - xops[0] = GEN_INT (TREE_INT_CST_LOW (TREE_VALUE (attr_args))); >>>> - output_asm_insn ("call\t%0", xops); >>>> - } >>>> - else >>>> - output_asm_insn ("call\t%0", &target); >>>> + operands[target_index] = GEN_INT (TREE_INT_CST_LOW (TREE_VALUE (attr_args))); >>>> >>>> + } >>>> break; >>>> } >>>> default: >>>> - if (TARGET_XBPF) >>>> - output_asm_insn ("call\t%0", &target); >>>> - else >>>> + if (!TARGET_XBPF) >>>> { >>>> error ("indirect call in function, which are not supported by eBPF"); >>>> - output_asm_insn ("call 0", NULL); >>>> + operands[target_index] = GEN_INT (0); >>>> } >>>> break; >>>> } >>>> - >>>> - return ""; >>>> + return templ; >>>> } >>>> >>>> const char * >>>> @@ -1144,6 +1136,87 @@ bpf_debug_unwind_info () >>>> #undef TARGET_DEBUG_UNWIND_INFO >>>> #define TARGET_DEBUG_UNWIND_INFO bpf_debug_unwind_info >>>> >>>> +/* Create a BTF.ext line_info entry. */ >>>> + >>>> +static void >>>> +bpf_output_line_info (FILE *asm_out_file, rtx_insn *insn) >>>> +{ >>>> + static unsigned int line_info_label = 1; >>>> + static tree cfun_decl = NULL_TREE; >>>> + static bool func_start_added = false; >>>> + const char *label = NULL; >>>> + unsigned int loc = 0; >>>> + const char *filename = NULL; >>>> + unsigned int line = 0; >>>> + unsigned int column = 0; >>>> + >>>> + if(!btf_debuginfo_p ()) >>>> + return; >>> >>> I think it would be better to put this guard in bpf_asm_out_unwind_emit >>> instead of bpf_output_line_info. >>> >>>> + >>>> + gcc_assert (insn != NULL_RTX); >>>> + >>>> + if (current_function_decl != cfun_decl >>>> + && GET_CODE (insn) == NOTE) >>>> + { >>>> + label = current_function_func_begin_label; >>>> + loc = DECL_SOURCE_LOCATION (current_function_decl); >>>> + filename = LOCATION_FILE (loc); >>>> + line = LOCATION_LINE (loc); >>>> + column = LOCATION_COLUMN (loc); >>>> + func_start_added = true; >>>> + } >>>> + else >>>> + { >>>> + if (GET_CODE (insn) == NOTE) >>>> + return; >>>> + >>>> + /* Already added a label for this location. This might not be fully >>>> + acurate but it is better then adding 2 entries on the same location, >>>> + which is imcompatible with the verifier expectations. */ >>>> + if (func_start_added == true) >>>> + { >>>> + func_start_added = false; >>>> + return; >>>> + } >>>> + >>>> + loc = INSN_LOCATION (insn); >>>> + filename = LOCATION_FILE (loc); >>>> + line = LOCATION_LINE (loc); >>>> + column = LOCATION_COLUMN (loc); >>>> + >>>> + if (filename == NULL || line == 0) >>>> + return; >>>> + >>>> + char tmp_label[25]; >>>> + sprintf(tmp_label, "LI%u", line_info_label); >>>> + ASM_OUTPUT_LABEL (asm_out_file, tmp_label); >>>> + line_info_label += 1; >>>> + label = CONST_CAST (char *, ggc_strdup (tmp_label)); >>>> + } >>>> + >>>> + cfun_decl = current_function_decl; >>>> + >>>> + if (filename != NULL && line != 0) >>>> + btf_add_line_info_for (label, filename, line, column); >>>> +} >>>> + >>>> + >>>> +/* This hook is defined as a way for BPF target to create a label before each >>>> + * emitted instruction and emit line_info information. This data is later output >>>> + * in .BTF.ext section. >>>> + * This approach expects TARGET_EMIT_BEFORE_INSN to be returing TRUE as >>>> + * this function needs to be called before the instruction is emitted. Current >>>> + * default behaviour returns TRUE and the hook is left undefined. */ >>>> + >>>> +static void >>>> +bpf_asm_out_unwind_emit (FILE *asm_out_file, rtx_insn *insn) >>>> +{ >>>> + bpf_output_line_info (asm_out_file, insn); >>>> +} >>>> + >>>> +#undef TARGET_ASM_UNWIND_EMIT >>>> +#define TARGET_ASM_UNWIND_EMIT bpf_asm_out_unwind_emit >>>> + >>>> /* Output assembly directives to assemble data of various sized and >>>> alignments. */ >>>> >>>> diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md >>>> index 95859328d25..3fdf81b86a6 100644 >>>> --- a/gcc/config/bpf/bpf.md >>>> +++ b/gcc/config/bpf/bpf.md >>>> @@ -546,7 +546,7 @@ >>>> ;; operands[2] is next_arg_register >>>> ;; operands[3] is struct_value_size_rtx. >>>> "" >>>> - { return bpf_output_call (operands[0]); } >>>> + { return bpf_output_call ("call\t%0", operands, 0); } >>>> [(set_attr "type" "jmp")]) >>>> >>>> (define_expand "call_value" >>>> @@ -569,7 +569,7 @@ >>>> ;; operands[3] is next_arg_register >>>> ;; operands[4] is struct_value_size_rtx. >>>> "" >>>> - { return bpf_output_call (operands[1]); } >>>> + { return bpf_output_call ("call\t%1", operands, 1); } >>>> [(set_attr "type" "jmp")]) >>>> >>>> (define_insn "sibcall" >>>> diff --git a/gcc/config/bpf/btfext-out.cc b/gcc/config/bpf/btfext-out.cc >>>> index ff1fd0739f1..42ec48e394e 100644 >>>> --- a/gcc/config/bpf/btfext-out.cc >>>> +++ b/gcc/config/bpf/btfext-out.cc >>>> @@ -32,6 +32,7 @@ >>>> #include "rtl.h" >>>> #include "tree-pretty-print.h" >>>> #include "cgraph.h" >>>> +#include "toplev.h" /* get_src_pwd */ >>>> >>>> #include "btfext-out.h" >>>> >>>> @@ -124,7 +125,8 @@ struct GTY ((chain_next ("%h.next"))) btf_ext_funcinfo >>>> /* A lineinfo record, in the .BTF.ext lineinfo section. */ >>>> struct GTY ((chain_next ("%h.next"))) btf_ext_lineinfo >>>> { >>>> - uint32_t insn_off; /* Offset of the instruction. */ >>>> + const char *insn_label; /* Instruction label. */ >>>> + const char *file_name; /* Source-code file name. */ >>>> uint32_t file_name_off; /* Offset of file name in BTF string table. */ >>>> uint32_t line_off; /* Offset of source line in BTF string table. */ >>>> uint32_t line_col; /* Line number (bits 31-11) and column (11-0). */ >>>> @@ -235,6 +237,26 @@ bpf_create_or_find_funcinfo (const char *fnname, const char *sec_name, >>>> return *head; >>>> } >>>> >>>> +/* Function to create a lineinfo node in info. */ >>>> + >>>> +static struct btf_ext_lineinfo * >>>> +bpf_create_lineinfo (const char *sec_name, btf_ext_info_sec **in_sec = NULL) >>>> +{ >>>> + struct btf_ext_info_sec *sec_elem = >>>> + btfext_info_sec_find_or_add (sec_name, true); >>>> + >>>> + if (in_sec != NULL) >>>> + *in_sec = sec_elem; >>>> + >>>> + struct btf_ext_lineinfo **head = >>>> + SEARCH_NODE_AND_RETURN(struct btf_ext_lineinfo, >>>> + sec_elem->line_info.head, >>>> + false); >>>> + *head = ggc_cleared_alloc (); >>>> + >>>> + return *head; >>>> +} >>>> + >>>> /* Function to create a core_reloc node in info. */ >>>> >>>> static struct btf_ext_core_reloc * >>>> @@ -429,6 +451,47 @@ btf_validate_funcinfo (btf_ext_info_sec *sec) >>>> } >>>> } >>>> >>>> +struct btf_ext_lineinfo * >>>> +btf_add_line_info_for (const char *label, const char *filename, >>>> + unsigned int line, unsigned int column) >>>> +{ >>>> + const char *sec_name = decl_section_name (current_function_decl); >>>> + >>>> + if (sec_name == NULL) >>>> + sec_name = ".text"; >>>> + >>>> + struct btf_ext_info_sec *sec = NULL; >>>> + struct btf_ext_lineinfo *info = >>>> + bpf_create_lineinfo (sec_name, &sec); >>>> + >>>> + unsigned int line_column = ((0x000fffff & line) << 12) >>>> + | (0x00000fff & column); >>>> + >>>> + info->insn_label = label; >>>> + >>>> + if (!IS_DIR_SEPARATOR (filename[0])) >>>> + { >>>> + char full_filename[256]; >>>> + >>>> + /* Filename is a relative path. */ >>>> + const char * cu_pwd = get_src_pwd (); >>>> + gcc_assert (strlen (cu_pwd) + strlen (filename) + 2 < 256); >>>> + >>>> + sprintf(full_filename, "%s%c%s", cu_pwd, DIR_SEPARATOR, filename); >>>> + info->file_name = ggc_strdup (full_filename); >>>> + } >>>> + else >>>> + /* Filename is an absolute path. */ >>>> + info->file_name = ggc_strdup (filename); >>>> + >>>> + info->file_name_off = btf_ext_add_string (info->file_name); >>>> + info->line_off = 0; >>>> + info->line_col = line_column; >>>> + >>>> + sec->line_info.num_info += 1; >>>> + return info; >>>> +} >>>> + >>>> /* Compute the section size in section for func_info, line_info and core_info >>>> regions of .BTF.ext. */ >>>> >>>> @@ -537,6 +600,48 @@ output_btfext_func_info (struct btf_ext_info_sec *sec) >>>> } >>>> } >>>> >>>> +/* Outputs line_info region on .BTF.ext. */ >>>> + >>>> +static void >>>> +output_btfext_line_info (struct btf_ext_info_sec *sec) >>>> +{ >>>> + unsigned int str_aux_off = ctfc_get_strtab_len (ctf_get_tu_ctfc (), >>>> + CTF_STRTAB); >>>> + bool executed = false; >>>> + while (sec != NULL) >>>> + { >>>> + uint32_t count = 0; >>>> + if (sec->line_info.num_info > 0) >>>> + { >>>> + if (executed == false && (executed = true)) >>>> + dw2_asm_output_data (4, 16, "LineInfo entry size"); >>>> + dw2_asm_output_data (4, sec->sec_name_off + str_aux_off, >>>> + "LineInfo section string for %s", >>>> + sec->sec_name); >>>> + dw2_asm_output_data (4, sec->line_info.num_info, "Number of entries"); >>>> + >>>> + struct btf_ext_lineinfo *elem = sec->line_info.head; >>>> + while (elem != NULL) >>>> + { >>>> + count += 1; >>>> + dw2_asm_output_offset (4, elem->insn_label, NULL, "insn_label"); >>>> + >>>> + unsigned int file_name_off = btf_ext_add_string (elem->file_name); >>>> + dw2_asm_output_data (4, file_name_off + str_aux_off, >>>> + "file_name_off"); >>>> + dw2_asm_output_data (4, elem->line_off, "line_off"); >>>> + dw2_asm_output_data (4, elem->line_col, "(line, col) (%u, %u)", >>>> + elem->line_col >> 12, >>>> + elem->line_col & 0x00000fff); >>>> + elem = elem->next; >>>> + } >>>> + } >>>> + >>>> + gcc_assert (count == sec->line_info.num_info); >>>> + sec = sec->next; >>>> + } >>>> +} >>>> + >>>> /* Output all CO-RE relocation sections. */ >>>> >>>> static void >>>> @@ -609,6 +714,7 @@ btf_ext_output (void) >>>> { >>>> output_btfext_header (); >>>> output_btfext_func_info (btf_ext); >>>> + output_btfext_line_info (btf_ext); >>>> if (TARGET_BPF_CORE) >>>> output_btfext_core_sections (); >>>> >>>> diff --git a/gcc/config/bpf/btfext-out.h b/gcc/config/bpf/btfext-out.h >>>> index b36309475c9..9c6848324e7 100644 >>>> --- a/gcc/config/bpf/btfext-out.h >>>> +++ b/gcc/config/bpf/btfext-out.h >>>> @@ -99,6 +99,10 @@ extern int bpf_core_get_sou_member_index (ctf_container_ref, const tree); >>>> >>>> struct btf_ext_funcinfo *btf_add_func_info_for (tree decl, >>>> const char *label); >>>> +struct btf_ext_lineinfo * >>>> +btf_add_line_info_for (const char *label, const char *filename, >>>> + unsigned int line, unsigned int column); >>>> + >>>> unsigned int btf_ext_add_string (const char *str); >>>> >>>> #ifdef __cplusplus >>>> diff --git a/gcc/testsuite/gcc.target/bpf/btfext-funcinfo.c b/gcc/testsuite/gcc.target/bpf/btfext-funcinfo.c >>>> index 6fdd14574ec..0f1e0ad1e89 100644 >>>> --- a/gcc/testsuite/gcc.target/bpf/btfext-funcinfo.c >>>> +++ b/gcc/testsuite/gcc.target/bpf/btfext-funcinfo.c >>>> @@ -39,6 +39,5 @@ int bar_func (struct T *t) >>>> /* { dg-final { scan-assembler-times "ascii \"bar_sec.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ >>>> /* { dg-final { scan-assembler-times "FuncInfo entry size" 1 } } */ >>>> >>>> -/* { dg-final { scan-assembler-times ".4byte\t0x1\t# Number of entries" 3 } } */ >>>> -/* { dg-final { scan-assembler-times ".4byte\t0x2\t# Number of entries" 1 } } */ >>>> +/* { dg-final { scan-assembler-times "FuncInfo section\[^\n\]*\n\[^0\]*0x1\t# Number of entries" 2 } } */ >>>> /* { dg-final { scan-assembler-times "Required padding" 1 } } */