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 778A63858D20 for ; Wed, 17 Apr 2024 17:49:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 778A63858D20 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 778A63858D20 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=1713376144; cv=pass; b=CsgwDnRvhONp2MsulAVB3lDhzk/hW506AS/O8iSa9MWEDpvpc8E9Das6LdKkQ9yTWa6vDbPjPWYSSqvaiwk0hJejl9oH9LDP3Y24AY9fmWk+3lCcRNgMCkpCCR1L88jT6BoArPTxeqdyEcM+R6MiyvK/lCCwXkxbBkUris+3o/U= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713376144; c=relaxed/simple; bh=KMnP9rlABP3odnaymLVmihDtxjfEnZGIUJORfkwbUKg=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=pZ5bQ+SfU/R4RuEsACqwNscfgJNxA+efia+Sftg8un/bDhr/2eDUJdf3fuimJ4g87dnnSAK27wNMpk0GttPfvRlFVb+XAeqRxB2CWXjSHxdbzJg7NHhd11YigWg1INZ09bDDGPXIt/VKNH1VMRPKhnm2ZCa50ohAvsb5IdHA2wc= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43HHhgkc009938 for ; Wed, 17 Apr 2024 17:49:01 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=c4QaxQP0SQ/ipbZRPY+hF8zV+RnIymI6HDOmT4bHZiM=; b=exszXuh1YFfYQcph+dFrQSlPHMgUMsbSbxYHiFBMI4NzOMLzgh+sRUjkQ7LNxsXqRq7+ T9C88t5X8q0WHs4RqRBrfNHrhrpTMtu99BVCyPH9ZE0XzUzQxYV9Ll9O8xQaZEYls3G4 keOz6CUy/1HKe0XKW4Jv7KNNMclrrnzi/uWJ1ZbGpB3Z7kdc2N82KsIxNnVqwfeVOM1C vXdn2iH7l0itwyT9YFAJ8Qc0lPYIP39Ehyxcjw4eGwWwsQlnZVqBgOqJXFfXkkjdm4Iy 7m8/7sjjM9e2Hrud5uF+SVl2/w89HhGlmfj+pGWsEy06XOubU4/h9qKIDt7vXb4ohrQX FQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfj3e8ny5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 17:49:00 +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 43HHlg2d004339 for ; Wed, 17 Apr 2024 17:49:00 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 3xfggffbej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 17:48:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EHNn239AYN2cH1zkWlyr+0BN1ba7pnjX3+CnqfSblg/8fLSRzuTrDprKfQONxtbiMZTUSvYYiTiXfrYkCxAPfMkFfHPkDXFlGD0DFRW9zbWcr7KKYqDrpXWSqvliERueqcKxmp2KHXIsOtWI7oo43OPIpP8fgXSdLoHBRJZL1g1YvwdFc78Jb6FgH9/jHsEfN0d9EoFodfx+QVup3i3BR7JRGi1McX8RYiEhTXg66BlIiNHIO78Rc8qPA8L0EfB9yn66HHSNZjMuymVyyCfgKEsb8rfSoQrYXTr3RqJn9iad/cXvvFyW9eWCR7pK7bQc70WQfN8C5+Z1WfptWBq/JA== 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=c4QaxQP0SQ/ipbZRPY+hF8zV+RnIymI6HDOmT4bHZiM=; b=U3xMbQxC6VOCFJHXQzTXg5DZd12NxYjT7d+rkgtqkx4ti3k+mf3w6T0MtjXTsh3uMO14euOTNxILRCcA/jZGsODfpqkLPRPeTw+0w9l/+AdnhULqfO3GSNc19M5uJAclwGgwP6iqKMgff5/11dKnlToe7YD8LdKI/b+PlXyjyddZNJ9+1aKFS5uAvlJJS3qZkzEaZCdUK4kH42KsK6c0w16FS6s1kjbJTEBBAWVO4TAMkzvLK5aNsYMvW+9DPRdFQvwUpJB1uJn/occFwHSU+fnydc3LRbxrpF0C1NdMglegDKLJeumvEb+n8jUcagCGUTkPHhbwS+XUAGtyFDsvrg== 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=c4QaxQP0SQ/ipbZRPY+hF8zV+RnIymI6HDOmT4bHZiM=; b=e0MrptEsSaIGLbL5Zzq12lC1NsdE7WcDe+srK1YM3lkj6vgmQy+YjHcF0fd9S8qsUuGOH4IWnTBaHVnLPKDQMDJCsJOBmYu/op7auT/b2UVVKUWV4uq261EfPpXsq0PllGocKHfblOmjCtTrdIQmJLyKcx3QFO8OsY4yeynCrvo= 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:48:57 +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:48:57 +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: <87mspsj8ja.fsf@oracle.com> (Cupertino Miranda's message of "Wed, 17 Apr 2024 16:47:21 +0100") References: <20240411111118.215612-1-cupertino.miranda@oracle.com> <20240411111118.215612-3-cupertino.miranda@oracle.com> <87il0g81i3.fsf@oracle.com> <87mspsj8ja.fsf@oracle.com> Date: Wed, 17 Apr 2024 19:48:53 +0200 Message-ID: <87mspr6fsq.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: text/plain X-ClientProxiedBy: LO4P265CA0315.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:390::9) 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: 7178e9ca-cf96-4ada-f11c-08dc5f06a7ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iGNRGF9D/2avz7Y7iQMakLJi7igN2SNidgLgHhg1IfDnPAb/nHlpQueddbeS?= =?us-ascii?Q?Q44K3zIcJXs7fo8SRSWSbLuIiqBF1CrbJRRiahhkL9V7ffnKzdjlqYritOHT?= =?us-ascii?Q?YolHmbuZhJJ4k+FvwOOxDhrMUVy9BQWCYbLt/iFCqPf205pu+PJw8PjS/np8?= =?us-ascii?Q?H7EEObNK/aFjGPhGr+pIarFIT151Ms4+S1SldZzZUnMp2OIyAiEokYHDyBAQ?= =?us-ascii?Q?gvdm5s1i7dJzjAJPOF3qWC8XQwbKESkWOsM9n9OWDrCc/pkYuUwF86ES3Yjy?= =?us-ascii?Q?oevsetv+ssBp1gtkx4bdjpd1W2IfZpB6FqkHux7EQ6hhafYd7VbmlytHxQdp?= =?us-ascii?Q?SVyMVPEASFst/V6wtJR98ZaLDjZLWYMkz+5WOqsDeE/dJ8fTjROQAla9nDjW?= =?us-ascii?Q?5XJFQnJeonJfabdrWKeGddMs3PdUYWwUbZtpxFW/uvtW9CG8nN+zPA2cUQch?= =?us-ascii?Q?Y4JZk37Yf8OS8st6JKhAoI7Ihpc2Hplp19TUrHbWz3Uu5AcKv8aWEBkMrqa9?= =?us-ascii?Q?NWau8aKmoe/NTpPC837mrO6x14w6+O+a8LPXMdGbjUQyKbS+891latXcik5r?= =?us-ascii?Q?N/oyzdCwl9342opPMi7UIXgtev5On/2X7Xxnj/QpkowZwyIbjNQ5V40Pxq0L?= =?us-ascii?Q?PYQ5JzRNDr1QDMDyobgNYnZZw1eATfue4dbLYRD1rwz2qoikRXzMA23pt3fl?= =?us-ascii?Q?lDRbpXmybRSvmtQXqzVfMybGJE/JNS0Cl5yYoLzy0cA8FXjQ3lOmT3IA6nvG?= =?us-ascii?Q?sVlsWa2HLBELBRz1vdbFS3itsQsFZtkHWLb/GvcEETRoy2obWmvRPP2pHjOQ?= =?us-ascii?Q?wBJv9+bSSDhSPHDeKQRVp+r2msSfeViHaHKr0X2VlTqGWwwtIBZVtALcYop8?= =?us-ascii?Q?FNwwLxhoIP7ve6QMllD9RhsyAISwIu3MHm/J28Bnik9JvHmObxXudRoRuQur?= =?us-ascii?Q?40cCFz1zUx9c2ZDBuc5A4mnTKHaLYyN+7asw6xiDGcPHTZ8efKxE7cbyTyJ7?= =?us-ascii?Q?TwFJLp4ODHQIg2ocxjJUMiKMgC9eGgDbZfmJFR/dhDXR1gCnl9kK2GgRLbJ6?= =?us-ascii?Q?sHmdkeF9VZHrAiT5u6bwPlrBrh0ImTW2BOVBcrSTnLPsNTnSWwwJnQK2UqRn?= =?us-ascii?Q?ky5DCI72Wu1ZtQSTV2YQUy4GPH76DTNNvUJF7fvtnC6Qh9gkyVbKQ6p/3opX?= =?us-ascii?Q?taDORzhpeZ4B0+3+TbMMxAUXstWFO4aYdGhB9CfuniCXFzW6XoMSpOMBYfN7?= =?us-ascii?Q?9q169MVHM/qgcO8XB5m2ad3Bzr4UVsxIRvpRon/btQ=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?0OeSHVE6Lhdm4UjWzHILHThqUNbsUBPXP8wEE/8tO+0l5EdlEWA9y2dW+jJy?= =?us-ascii?Q?S2iVcjsjfsjyLxtiP3IB1rB1ECKG0008koZ+CHb5Tl48shg1O0GSLbeEjR8I?= =?us-ascii?Q?YW7IBuxncelCnyYay6kHpg72jleIwoYXc/W6ofV4f1ZSN3vj5bOls6DbqVMU?= =?us-ascii?Q?IXXh63mUQ7o62eCDpHUkGQULvU2y/PKsPH2ewuOpT/egjsUh4eyn5/svRn6c?= =?us-ascii?Q?LA75kqGD46tDyAH0dMA3HGcv4zF+wFcvLA4IlZGZo26haN3NxrZn2vYoPCxm?= =?us-ascii?Q?lQvDAkRZNnzQAfdHatnaZ1ANLA1fksos/4jrHn/FEI/gFY+IakCV0yvv5zLp?= =?us-ascii?Q?TU7ysRYcEmMpgeCANXiyWNhBCjx3KgFSjk/1rQ6nGKTTBCsirJ1mlxUlvD7p?= =?us-ascii?Q?j9Ks56kbu/OqLEpMxXDzqAnBdJV4DYLv29ga2pKay6CFZvqLh3PmD0MPMzHH?= =?us-ascii?Q?jAjdzJqs7Albr3LVJeNl8/uxdrPhBN+HAqNXIkLfLs++wnp/ATfmKX4CKzJk?= =?us-ascii?Q?OvHOO9/4bLvQPLcN/SVGzzzcEeRCZguUs/aHSWjcMCVpI2FN9apfMk6Xs5gj?= =?us-ascii?Q?jlRTslLuMT0/WVrOpbU+pTr+FKLDyqMQu6n+u4Rt0pRoW/PydzosPzwOgUGx?= =?us-ascii?Q?7ukCQmLyza2+At7GMSlsl8rzARpWOY8Tz/j9ZFXgVPvXXfz3//xTJF5Jt4/t?= =?us-ascii?Q?HNQbmGnDNf8Ylxw/OnmkrGnjo1oBtFg1qeZtuWo2OKv6JIQzGiCDZ2O9/WnT?= =?us-ascii?Q?eAlWbl2W8nndi5GE6UwF8bHMa2R7WsPuhoV0XpH6KNHJMXfWgLDzTDYzk9O4?= =?us-ascii?Q?wTAnJOhIQskp8xA7FlZWLEbDbjDSJzrrwfvLgZQuLWORkf0EvYzHo0JnqrOx?= =?us-ascii?Q?ujJPuBcEyAOJQo4T76LShiEgK/RhIcAe/Y+ZGjy9ZTHenFI9qenu2oJDZBqT?= =?us-ascii?Q?sCBxSyYKmOl2/H79OR46nTFo0qQ3zbwmKNRZ9BdVXTDGs494YErFF4Qy5RCs?= =?us-ascii?Q?H70fYZetrrcng7476U6MNgO/7huayX4y8/t4mZKdfoY1Uld2HZ628buS+1c6?= =?us-ascii?Q?XyB4aWDHsl8mLVXTlnjcB9ZB+C8UfNqlcm4v2HPhmKjW2CQBmPNBm6PRJOYp?= =?us-ascii?Q?YgIMf3otrk/jKIiP4zuO27gVXWRMI3mniGZDu09h8SX80cNTkzAKUNDOsQOd?= =?us-ascii?Q?aPVvXPdgRsCqVGUZpT3d5T2MariOoeO4nk4v8Azl1+B0bervon3Nq7lUPTVS?= =?us-ascii?Q?PougLpqY7dsHnsqbe58jB8OUQeDwrCI4Ql63RHZvPFfvv0Qf0YqZvvpegOwu?= =?us-ascii?Q?uIBsjrB7gJxzUGy5fbbWEYtUub2VacfQAhZS8qZd8oXDB0NR6rRK9Mbml0Nf?= =?us-ascii?Q?XJb54xqjN+pqSEnVB/+QTPgKSJAX79eo89mbcjy0rjK3+VmraMiTUv1pxwwy?= =?us-ascii?Q?5IW+E1jxh20Yh2aGXPFPHCRwZpLFs4wwvN0VuaYY0q+CZvDEY0bavAGIlsXd?= =?us-ascii?Q?SVDynEO1dWv/rqpDwDro6v4UDEV/1IrDgg6yDiX0Qnx1fIHZRq6HGmV+ccH+?= =?us-ascii?Q?9/12iBhbGB0FNiYeZeuxD+Cchhez6amlrMnlWHOOXBXg0vXeuIojSJ36ndGF?= =?us-ascii?Q?bw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WeJQXr77RgSIgIz2GSF8MLZSR9UjBEgzZV2+l8dK/dBnLQ8i0oqakor7aHpaB4qJvMjNdC0R6N1TsKIis0uLYAFCeMNdeIQEeyxdpJ+3jatS4wWQktwAB5/w9ufXOKTRVAI90RTEjr1xXN6n2MbiRLBc46X+om14dKuV3Eu9PSYAKmjmaNnuWyLZuVV/c3QI0sUDF+iwuTfIxuKLEOAPS/PLizlBjNVjW8OxkJTQZlgG3tuVWl2RSUKcDzwr8EaOIREUD7wzzqTM7CwInPaUUOyG59hnVk80PCsFMbvwdYEBRSZXBx1yfDmXeGGC/eL8hM6PoiPWmfo3aomG6g4EsYGaVSfi40i9eRon4oBrUSUofkOS+on2W1foykmyQZebMVR14X4HHfpu6fAne1iw1yqrZ0yjpLpOekDQ8hmRS+tXEmtXw99ykpf1Cv6A2+dsMReXYyHrQCkcOwdeV7/zX2MZzsyJL21qcZHgpCYfMMnLOjf36MYlg8aslzmEgI1FssFu6AQyAJ2aMv9G+DGw91bw63FEPV0gGqr9JSGrqM7ntvT6fGUAkEQ6qLfSI+oWb82yeW5JsD+7kkoGeEVozkwqIIcahsBhgU5IxgpvHRs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7178e9ca-cf96-4ada-f11c-08dc5f06a7ce 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:48:57.2402 (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: UtCDqiN68dDaHRpP4O/JnDvP3rO5KH6ogKKDVPAOhb42EMVw8f6/zj0mrN1iO0phuOptDG4WayUbzajYhQoJbjuCYflA1KB1UITLZ58nL3U= 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 phishscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170126 X-Proofpoint-GUID: gvlV8m4MKdw2FcHCyxlWL0MD-MWM31EG X-Proofpoint-ORIG-GUID: gvlV8m4MKdw2FcHCyxlWL0MD-MWM31EG X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_LOW,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. >>> * 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 } } */