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 379B63858D20 for ; Wed, 17 Apr 2024 15:14:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 379B63858D20 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 379B63858D20 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=1713366896; cv=pass; b=xcbQJvBO43peREoBjbiLAh31nzukP98njycVJQfr8iYOkJJE24ZDfStdFLhr0MkJJIVJ6MWM5k6D+QyYc4wjBz74MMgZNRoYOL8F3uqdToS0+llS95TsFWpIj9Ts3CAEVXxqDGyG3afHN6n1Hg2EjdqnwjMcBqHpHuf/8xwP07g= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713366896; c=relaxed/simple; bh=OICb5ty/vQk3hKptYkE2YpWpMBSu46Dz1rQM9HPxGXQ=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=W+hEHqn/FNitfaq2mbIexSORhjgCJTkiipzmjsxFVRZGzubnHjEb5im6bUpC+OQyKv5Ul9WbTFS4R2KR9b/tM4cnlAtqOyyaYp4duEmDZ1pAZKWA4a6HKR+uQWo5JjKvYG3oZhVR2FtjPXjs5944NqUaDvGulPpd6m65IYq5f98= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43HF589R032289 for ; Wed, 17 Apr 2024 15:14:53 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=3s1IIJEWU2+p5ma3nJxUHB9DWU6XeV/dldw8MW22k8c=; b=ec6Yl6Eq8R/AMBOl0tbhXuSefbrXpAhIuNiR4kx/AQg00iAH2IlK8uzEEXRJlE04UktI 8QCJKljhRLiEm+ZJrJ0g/sQG/jITA+x2v2IVwwbCNzWDKLttqCtHTHAW2fQJFMEWfc/D zrV+dWNMRncsflX3WnR+WGtwineF2m0HsDcPDcfHrnkHPs6JSOAmSC/7gW4JqKFmKYIK bq6gN0w5Zsg43efvQUSPeo+aBBqRv2mMKRhN1Pu7gSLHAwh2yEi4VvQM6dePRIAIDJoO gTp3hIgxO9ndlDrTDSpfKG8qlLY/9uQKSROaexesWQwWw7uFNQi7IzLy0GxP12ouYSIs qg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfgycr56y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 15:14:52 +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 43HExHoB028900 for ; Wed, 17 Apr 2024 15:14:52 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xfgg8yp76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 15:14:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f94/8j4n7sr3rynxlDaK44oO3wKLaMgIqPFQoQ6lXsIGlcUH6fqm95WUeDL+YIIZfO9E+/hzAQw3XdbrVl5JvN1n9RrEHf7UPUj6xrdRrgfU0ofrbdavbRsIMqn4rUz98mOOluB0eqvXal8n4njBKsqm/OJ96a1bQV1jzzFsAjrJdWCQPfTS3zx8glNkZQc7WpImbW/Cajt4sSqJJW89uQT7BKaf1NF5qFUW5/WuLHgzPtah8RdHm/zVVmhZnPxTJVeCN9JcaZL03J8GQlVf9nlY0arDMOu2QG+frRPhEjn+Cqp0XI4RJzXZGMVJLCtJPDEygHKSIEXTEakkH7vFEw== 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=3s1IIJEWU2+p5ma3nJxUHB9DWU6XeV/dldw8MW22k8c=; b=PayWdoVNROZ5M1jfAojJjtp/4K3o69G4XtdSTzeagxuPJ2mX5vsMXRZtWoyPJZ8fcLG7zYktHyY7hajfxzhcZ7KEdvJyP+U3ZwEQnRHieTrhREiPHXZOqLZydvHmuuILraqeel0yP+74NvwhsWe6jeObpvEJmMVmDVXOaw9ZuywiGGvc7Wh5YwGldpUBtZp08oObmuiHxv1RwdT88mhjBwK+Pm5Cv9lFXSUM/vI+8piHWyiaFrF4FwulMTwENZ5b4Q4c10LbVhCggVmDsj38LPfbQRddaMyrsNxL2bWgbAyuv6tr0sExb5lVMBU2ynjGI2R9ArC4LLug3dseKCFEcQ== 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=3s1IIJEWU2+p5ma3nJxUHB9DWU6XeV/dldw8MW22k8c=; b=DCfFcWab4IHOvozX0raWGHHmwkbDbRyvkM83ey2P6isoRbNSvs5BTORmfkoy0mRdJ0+W1UEjzVTLz9ocbB2CofDbog+yp+hgsSFCnt1ZC/OTkIVaqrXS6Tf951zJlN47zCkQuQaCFY5rAOARZygGWOxdZGWn6GfIsfpg53S5ToY= Received: from DM6PR10MB3113.namprd10.prod.outlook.com (2603:10b6:5:1a7::12) by MW4PR10MB5701.namprd10.prod.outlook.com (2603:10b6:303:18b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.37; Wed, 17 Apr 2024 15:14:49 +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 15:14:49 +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: <20240411111118.215612-3-cupertino.miranda@oracle.com> (Cupertino Miranda's message of "Thu, 11 Apr 2024 12:11:18 +0100") References: <20240411111118.215612-1-cupertino.miranda@oracle.com> <20240411111118.215612-3-cupertino.miranda@oracle.com> Date: Wed, 17 Apr 2024 17:14:44 +0200 Message-ID: <87il0g81i3.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: text/plain X-ClientProxiedBy: LO2P265CA0469.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::25) To DM6PR10MB3113.namprd10.prod.outlook.com (2603:10b6:5:1a7::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB3113:EE_|MW4PR10MB5701:EE_ X-MS-Office365-Filtering-Correlation-Id: f1ce24fd-a311-4d76-e072-08dc5ef11f81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H7H6wHsRkyxJWHlTyCfp5qZojjlkdcQ/C6a+o/SOlxGVYTiuZveLewdQqfWK++53VbmRG2zFGPUva/7oLUbiw7sOzDNGaG/NePfAsuMAJa/ALpJloiKhhbJs9tSzZvLx9mgGxGQuXDOZ2UwLrUYwDW0iPjZzMmDtR9oW0epii/VhtK9MgiKPqIDyKzHxey1yRqU+TnI0j3BXixQRjDB6hd0MmJxOr0elni65TVMnU0oIx8jyzYKb4jpS0rAJM1//LIvRmQC5EVmnKZPjc0eekt3UcqsyKIzPxkE9XRPkitakfNPNKs8oTuj88hjJeh9E+gxj14GXZjXBAB0owrwRTEP5JKbIcbzArC6tLNdsF6npVm8XnsqJBq4mxioDTHPtschfCndgljD0uvTLa9crAPwxU4gVHww9xyS9zbM56uNVXx4Hggr676QQskLRiYxcCF5FpQ0RoeFH1h+ty8gsDoH2eoc0FN0O3Hp6ZcKMsdv8oOaSBJ0yOEWZlkudWqOR9nS3kHJpOoILwRytOdm4a6UqNg+4Sh3zqlp709hD2wq6jfIfvyZ6Loq1vmKKwpkVZ90Is99zOZuDs+ZkGckdDM6V/5Me2bXMb6VhQD34D9v1G7OvYKF1s0ImM2vyaOnZ24bFyiUAOSwjHeFfPLilyyKX2/9qLXA0JY3uP2PwDqU= 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)(376005)(1800799015)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?SSg9Id0yAFlthUGlJjZY14k2b+mTK8zj1OkUArzFYkiN752MVUTmC70YxCkh?= =?us-ascii?Q?a47nlVUSXvAobX63RuizyV3i9NBL7PEk0GTAeEdfEu+hDHfp7FBGOfadZ/xb?= =?us-ascii?Q?EbgeeApejYLjCKJW/1GZE9lE8DkQu/GPjAZCTYEoLJ7Q2/ckp40QG2vhq0TJ?= =?us-ascii?Q?DzjuYKgZqTnSDm/dWPppt0JxOYHjH4tlzKp+diOMP05+IRL7mOQS4qgsSmum?= =?us-ascii?Q?p8UoYNzYBw7STV/IQBoBbE99njZg9UWj79XeqdYlbuATrQ45NeALG+7ULJPz?= =?us-ascii?Q?ACR1+njPml+EhzoYzz2jxOurS1BXDWEy4CL7RNElBlvqSJg3irWW+affsTZS?= =?us-ascii?Q?6XJJA5lJe6BNnIj8YcWPqg8Mw9BRL6anWuDlUhqLxvHAfgiY8x3TMNPsslom?= =?us-ascii?Q?L4W8uPtN6+gySt3kDNyYwmRMKTbSdSZDtwYfEVSXlh3jID/Tl936W/S09I0A?= =?us-ascii?Q?bDzU5Ot7Kti2nAMvaMeHXPF6A9MSp+qzvuKJupls9uGuLbOniP3QvUZDxxNP?= =?us-ascii?Q?z8K/ZOpHNLaLQWmEiO1Rbpu8v/e4j7cFcz1BozrDDGxatKhKto7jO+AbBmKf?= =?us-ascii?Q?+lSHHEgutFylRw2bgSvAYnIrNVl+n73k+kDeoPUSLl+Y0AzjwIIz5E8urrly?= =?us-ascii?Q?+FHwPE4/1LysxjZ8kk0z6zz5y2UgL6Mf6LmaINpShMRcCUBpCJdmtt0/YzHS?= =?us-ascii?Q?YTPbB4BNgzjjs98unZVBeCt4Yuyq3GOmPTwzkl3LNGJpH2rIgVsEV4Ern+CH?= =?us-ascii?Q?l2R6Jc3TRbfpTSZU1YOF8vFwnWNfFK7sz4oJGiAUeQUWF3nQjOHPHAGcHodS?= =?us-ascii?Q?KSkfZ6iUQ/NHraMRIT6n2v04CGZqFLKflRUBeae4tbjZU1Eywii97bFd4NZ+?= =?us-ascii?Q?pz6P4EfwGTTE6jtgPZXDVlwreyGAD8G8moUZMuZF333vw2ijEREHabCkeQbZ?= =?us-ascii?Q?ifO2wFkgcTsg2qeZYXh9PjEZKfgWnnhBZm9JeTu91HaR9V7LA0TdsY26Skit?= =?us-ascii?Q?H0j0uzoA8oozHNNMfwMlX6P/8OCBg07LkdsGcPX3snL6k2MYg2pbyaQR9odo?= =?us-ascii?Q?gOSwQuyYz4ATLciWFizaCASVY5z8GJ8U1f3vGqUiUySVYeKblcma1cIHHuu8?= =?us-ascii?Q?lXq66qJSa9gJej+1NO5rQuBKZi//3QyL87rnpe/NgiKp2eBwjMo265YOrrfk?= =?us-ascii?Q?N/9jDIAzytMeWey40SO6rUxTQWl1+PUWY9uoNBc+vqD9uZHpQN1YnTeueL7U?= =?us-ascii?Q?jjrCPgRXsgFgt2ZIDp5t3pFaMiQ+D3khkczC8LGDObDtNRgWa+RtbB07IsGZ?= =?us-ascii?Q?IX+xinb3EOMUk/0/762DYmvlSTrC8tU2aN+i9qqHr+XGshQHoMdlPL7X02rh?= =?us-ascii?Q?mEzzlEuwT3lNO99YqIk7uHRAaJhr1D+yGliGEJ5UToeNEDZ84EZPizlWuoY+?= =?us-ascii?Q?SmSL+vVitgZYNw/3+PepfC3uT6C6/OvXU1IP8WK3/6YQKmotM+SWljmKSUEw?= =?us-ascii?Q?FA3gAysZDsrwYVQcMEzC+Q3+4adHnJKw7Eq02ebPrrHP5UjZe7K+yBMD8gK6?= =?us-ascii?Q?zEZaZlAudwTHdmn2fSclMxqpozUuRVy77v2QVJTs4wQL8lGvIBbJb2GtSe8D?= =?us-ascii?Q?jg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ltW+Zo4rUz54+VYeQ60MDzTd9uhvnDdjjUpb78i4IpuFW8FHNKhRx6whgapG4aLi1mGbtoklrnSP+jVxwlFAR4q4HeoIyDARkuWRZZYLhpBKCVhHrVvSf/a3xwql/5awuXzLXvAfnFPyD7ZV71VFIiJhj/Pf8I2uNoI2Qu2MidgMr9RZMx+kmwZJ7zttnTU5sd0Rbd4pfCpMvz1QNScH0+9GQ1nydmHB5+uR5mPsnz7VuJcTleHAvnFYveF7VxZeHCH+tnuefKthmSsrLg8doKkXKfPz4fWxuuseZA0FgB1YYlEGw7lXaMWgfY/V+nrwOjdIeanCsNqkO7QJEK7nF/Iee+ApgUsaVaK5X598W750nFkZ4JtCgDpFeoceZAY9zyO2xWoZdLIyjgVosm2SK1uhylbVtkT2/KyJ9vE+SwJWVc2mI+EnPahvl54l5Jf7YHAfDdgi1Rz9JMARYenU1ZN4bnpGy6pTJ2wrViBFfcYSUeTtRo1xD6FZQRE1DrzsuwNXW0m8O7bJ8v+XKNxF5n8oxa13tguul/OIWswfXi/aPY7HCNLNdBGkD4908uOJB0RUjj0GuV1j04n9UhEUFxGX1lKWmnaDVRw74ZB6Nw0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1ce24fd-a311-4d76-e072-08dc5ef11f81 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 15:14:49.0520 (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: XJZpHPf/3ANCSd7w1p9FiYzJJwL4yWcjyUYGeN9YSwJc8lxLp9ipKxl7OMBwzX0Hdwj4fo3glBd024bRkl7wpzdj8DizbN5Id3f8eXYCYl0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB5701 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_12,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170105 X-Proofpoint-ORIG-GUID: Ovy-vQgFjA9TaFFgP365e8Op34PbqjHi X-Proofpoint-GUID: Ovy-vQgFjA9TaFFgP365e8Op34PbqjHi 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: 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? > * 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 } } */