From patchwork Fri Jul 30 20:12:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1511800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yiz9+JEZ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GbzD60fc2z9sWS for ; Sat, 31 Jul 2021 06:15:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C022398702C for ; Fri, 30 Jul 2021 20:15:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C022398702C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627676131; bh=q+CDzTdMNVIyxPP7emiuUm/Qf6Je+e1rglW2kcJzOPc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yiz9+JEZKNwNxl8FQoAsqQQ0qSJzsE2oScU/WiHilRzpQL/UGGVqlY20cLFgZ7oLM fN+KSwk7rrHI7asuZp9Il9Ulgl9vMYIdGj1r3NRrKTQ2sql93Q9XSqmLliVfS+RZip y5J5PkPFIh5qmY0bjl477YUqyfVidyvOMESCCWJs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 054783864866 for ; Fri, 30 Jul 2021 20:12:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 054783864866 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16UKBmHq004656 for ; Fri, 30 Jul 2021 20:12:57 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a3uujbsyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Jul 2021 20:12:57 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16UKB5wu003823 for ; Fri, 30 Jul 2021 20:12:55 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2042.outbound.protection.outlook.com [104.47.74.42]) by userp3030.oracle.com with ESMTP id 3a235a6a5u-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Jul 2021 20:12:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SMeGzBoM5yB+lKbHPfZKt/C3YEM316FTS0tmIXrjh5BB8oeRV2vD1cQbfIVklhFN450k31qE42jGsHe3Rk0DKqLSwFA6/FVsv9jirR5NOCbl40fHMkPdCZX8ucq4fhCCCkBAGs7rY6nDpV1/Dboe+X389H8oGr3aJxxrG5uc5QZ/dACQYNUbo2KY9TAUXR2PEpkItVsdsghWyFB/HH99IPAXug8hoitHGtJL65Jpnp5NozqiT4RJILGYKuo5+MEnkux65fLc1GPIwbumW/FdU4dSZI1zl6Z+OQOCci8K9AzJMo6A7snmR8XgU4E5HKBCCB3xN0VkCmOdF1yI6jwa1w== 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-SenderADCheck; bh=q+CDzTdMNVIyxPP7emiuUm/Qf6Je+e1rglW2kcJzOPc=; b=jtWURTAlIFwX0T8MxRB7Nev/Xp1rPIVR0PFA6hXOhKfzZIyO3TEWz62F+Pi6P2Ijflp/c0wmWYAI/rOwzuQhhCau3kQYj0qS+QnKILKz6T6vhGTCzxyZb29lSfH6cHZQ3VXd9BvbpCyM1HDHvwZ61Mgt9DOesDeYgVTP+VI/ixn6bDrcRM3lTIX1E+iV7YOmXsT35Xd9pSX0NL+r+rv/tpxQfUBc6sySuS8ytFvZKvjVlT5eNfvFznCV1FagpKa+t3q5Eaa7aaXXPW8zKl5/BdFKjOaT9nXCO8QjcclWigWHiTdj3we1XePhlEn7l9eB4qQEypm52ZNWxdNw9t+XJg== 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 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO1PR10MB4689.namprd10.prod.outlook.com (2603:10b6:303:98::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Fri, 30 Jul 2021 20:12:50 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4352.033; Fri, 30 Jul 2021 20:12:50 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] bpf: Add new -mcore option for BPF CO-RE Date: Fri, 30 Jul 2021 13:12:37 -0700 Message-Id: <1627675959-17662-2-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1627675959-17662-1-git-send-email-indu.bhagat@oracle.com> References: <1627675959-17662-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: MWHPR08CA0042.namprd08.prod.outlook.com (2603:10b6:300:c0::16) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.hitronhub.home (24.80.24.133) by MWHPR08CA0042.namprd08.prod.outlook.com (2603:10b6:300:c0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Fri, 30 Jul 2021 20:12:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c62cbde8-5535-4685-9c49-08d9539667b4 X-MS-TrafficTypeDiagnostic: CO1PR10MB4689: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aoj12mpGXqkeMi6zQ9LSjzI9W66J/eo3LMvn85xuaCY2ShH9ty8nh2lf6qVOrg5IBYuJc/9aTXbD9/HmwyynD8YvPdXamKrRLoBnUVHctTDAuS6+Ra6hZpYqkuEegHGYpw1tWSmwL5ZZoGb1S9gEui16nsr11paPnUuvEgbjxfqAMl/HsQWPBNpDoLrEGivunMv2BqT+Pu6809ZlSOWxyXBZm2yJcTMHCWXLpKecgye2gkHOASNWtbv9RzdXzmzo+mLaJvzPa6mSjONNgnDVLOkWOx+LlYeY0DTXpw5uWathh9yeD2pYbFvq0oUlk12ngiZdIWsoilqhyFMDs4fNquBKpwFk+0BOmz04hTv9DjEE3Kf8TrNq8gQQgmzmvDcRlJwqtmNGC8VzA8tHfSsHGFdpIAlM88oVIolwNxvHZ0xaEm8fVWSwZWvrIaPbIVYfBYAICdeOnqLYMoG6EXkR/H4A4iawLIOH/mR3YyCDWCh4kVoM2IXX1BYEf9ccbhcm61a+XfmSpnpmE4vpHiGdeZuUo54pK2h99gpl5rZz3AS/iTaavg2TisgV2NbFMA2ussFqEyg5lXXVF/+snHa5YJyHnN9n7Mo4O1SC6AaR631LmGc/oLfIKdnJJRUoj2NzPV47i4+dTVxxkZoTdtnUuP163YxwSwFFWYXoJ+WQwIJIjWaFIsIcSfuq/qEdsKhjQvZjiO35kyqfOMhg/0eRYXaz0YbqGpIp5TiaO/XNrKvWW2jps1T5iuPpvsLxIao34cDEd9kbEjRYudyq7i+mIX2M871dDrh8jnDfDwvUWTU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(396003)(366004)(136003)(376002)(66946007)(2906002)(66476007)(66556008)(52116002)(316002)(6512007)(6666004)(6916009)(36756003)(44832011)(186003)(8936002)(5660300002)(86362001)(2616005)(83380400001)(38350700002)(6486002)(26005)(6506007)(478600001)(956004)(8676002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: in4ctZPafYX8AK/fdM7eOCgW6yLv6SNPoqmuA3W14TDuuJqp/yIWgwX8P86eBDfY85yneLTDWG6qmd9h+jXEndqEHj4PFTM5H2FcCAfMmEJTj3vwzriGKVULZwm9JvajH21b5+k+HFoNdrzVNVPdBQzYa/Xy2R63g2TWdBojoJ4WaIZYinKwrTlXYrJiw7BZvcap9kEAvCrki3BctXgHzbGn6J3bi8Wb6r14zynp28zhQY6o+4JXLBYCg7klJScyXwLApDn01QQge3ZVUJ2xaJ6KHF9hlo0BEyRn3iFTb8NM1Y/j1oqOwsXjUo9ohauE4UJCAh89FK0jfVPLoyDyt3cKqRmM1amfVWRb0i/Ss8FzOL4TUd86C3eiufoWdzA/EBve42uHcmBa2nEToiSB20oNliJMP8f1/yXN+ZcKYoUEqbk3Ov8SJ4Sw0nHIBc1nJezqtHHoUQ6js8cvipvBH5oNtYjQmvZ8y80XqJ06R80CRT0LnF496RZM1SxquZTpel2kapG1k3IEYYBrtdGLFMO65E7QWhvuRxVbszB/tl2LTE/hfHGWZdF1SOegfphVNPfEDWFIFDBvYRS0vxtHETjmZVag2OW4aoyFnPpIz49XRzOzpz/XFCPYc2HvwRxvq0UFQJMubhos2gezPQsdaOt2sFbJG3FwtZmnjndBD5qivkOfhkRFCL1brP0ReM+aQVv9x7Te1hjDMY1Zm4DoA7/KMNcC2+F5X5yDkyL/VvtncpPbJmS1kyUiaqfrHoJBI4/mRsR3Kl+bT3R3R/Opkn6BXURAFfRS3CGGBdcR5ANM5wobyVBUNfmEH+bbVSpjKiR4lKZAzjbTOw5PkOfkNzqsXdiPFK0lDdvv7IqyUFOeIiRlRIfjH/sn8WmuVN9D3Y6q87tgdQZFO5ksfGUK8StGJ3zpXgdTwOPB1gQM8gItvz0LtsVTSyILNVb7s7DTaZ33tWK2m4sh/FmqXrXH4LsQy9BizqW0yJy32HGcTNtycobaDsxS7R3zLMfRw6NOwyHBLcpmlfx2q0+fWVziLKNlQPQps7HOZ+kXl4K9e6uaVSUvCbRevl/VhmdFs252vubf6Qf+lMwxjOdEz6rxNHIWFeVRPnAe88P8ZGXMngd8FOaLdeAe79yPgvXbJV/SHZ3RQmwkEa0Bmz+JCDoYWcOmAPEVh0uliWmO2i+zpCoc916wzR8/0sGVIsDb+Hmgl7EwtYlD4LeIH0YZo7RaQCf2Tr/UctCDyyrABhjGZZ8AZNYaLmgoXnIt3KytjKLllFTBTsoYRLYSUwYN1fabCBFF6wNv8zrFlqV9dHXSf+7iO0twzx6XW78ta9WpUam6 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c62cbde8-5535-4685-9c49-08d9539667b4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 20:12:50.1174 (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: NFXGyB4gt6RJDAMFuf/1V73oVAiRhlmqZs92Ar7d1l2j1pyShsv9jxTi9UzzOy3VBYZ43c3EgR9BPy8WNMz9ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4689 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10061 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107300137 X-Proofpoint-ORIG-GUID: BbGc-YjVdvIHHuL5meMHxGrq_jG6lwad X-Proofpoint-GUID: BbGc-YjVdvIHHuL5meMHxGrq_jG6lwad 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, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" -mcore in the BPF backend enables code generation for the CO-RE usecase. LTO is disabled for CO-RE compilations. gcc/ChangeLog: * config/bpf/bpf.c (bpf_option_override): For BPF backend, disable LTO support when compiling for CO-RE. * config/bpf/bpf.opt: Add new command line option -mcore. gcc/testsuite/ChangeLog: * gcc.dg/debug/btf/btf-mcore-1.c: New test. --- gcc/config/bpf/bpf.c | 15 +++++++++++++++ gcc/config/bpf/bpf.opt | 4 ++++ gcc/testsuite/gcc.dg/debug/btf/btf-mcore-1.c | 14 ++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-mcore-1.c diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c index e635f9e..028013e 100644 --- a/gcc/config/bpf/bpf.c +++ b/gcc/config/bpf/bpf.c @@ -158,6 +158,21 @@ bpf_option_override (void) { /* Set the initializer for the per-function status structure. */ init_machine_status = bpf_init_machine_status; + + /* To support the portability needs of BPF CO-RE approach, BTF debug + information includes the BPF CO-RE relocations. The information + necessary for these relocations is added to the CTF container by the + BPF backend. Enabling LTO poses challenges in the generation of the BPF + CO-RE relocations because if LTO is in effect, they need to be + generated late in the LTO link phase. This in turn means the compiler + needs to provide means to combine the early and late BTF debug info, + similar to DWARF debug info. + + In any case, in absence of linker support for BTF sections at this time, + it is acceptable to simply disallow LTO for BPF CO-RE compilations. */ + + if (flag_lto && TARGET_BPF_CORE) + error ("BPF CO-RE does not support LTO"); } #undef TARGET_OPTION_OVERRIDE diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt index 916b53c..e8926f5 100644 --- a/gcc/config/bpf/bpf.opt +++ b/gcc/config/bpf/bpf.opt @@ -127,3 +127,7 @@ Generate little-endian eBPF. mframe-limit= Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(512) Set a hard limit for the size of each stack frame, in bytes. + +mcore +Target Mask(BPF_CORE) +Generate all necessary information for BPF Compile Once - Run Everywhere. diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-mcore-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-mcore-1.c new file mode 100644 index 0000000..58f20d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-mcore-1.c @@ -0,0 +1,14 @@ +/* Testcase for BPF CO-RE. + + -mcore is used to generate information for BPF CO-RE usecase. To support + the generataion of the .BTF and .BTF.ext sections in GCC, -flto is disabled + with -mcore. */ + +/* { dg-do compile { target bpf-*-* } } */ +/* { dg-error "BPF CO-RE does not support LTO" "" { target btf-*-* } 0 } */ + +/* { dg-require-effective-target lto } */ + +/* { dg-options "-gbtf -mcore -flto" } */ + +void func(void) { } From patchwork Fri Jul 30 20:12:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1511802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PTxMWTMt; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GbzFH3wH7z9sWS for ; Sat, 31 Jul 2021 06:16:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C0CF3986423 for ; Fri, 30 Jul 2021 20:16:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C0CF3986423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627676193; bh=oVxDawwOjQ6gGWUHDzFuf+US8iggOewFtbjNASdw64g=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PTxMWTMt1UBteFlT2GwzSBLFmhudTIWrMChIx1wLz8Gnm+Hap3m9jlB5mrCVv7dFf 2qlnE61eykXMQaFFSZO6L30rq1+bhE+frfu0lmfZfn0klxKanDWagSvTdhxjlpzXmF aQRqHY32Yxt+ONydLUZhfa3DpsO/thhA6DC/fZgk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id A34773983C4D for ; Fri, 30 Jul 2021 20:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A34773983C4D Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16UKBmHr004656 for ; Fri, 30 Jul 2021 20:12:57 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a3uujbt00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Jul 2021 20:12:57 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16UKB5ww003823 for ; Fri, 30 Jul 2021 20:12:56 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2042.outbound.protection.outlook.com [104.47.74.42]) by userp3030.oracle.com with ESMTP id 3a235a6a5u-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Jul 2021 20:12:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VPif0nwx+Oq0SD0mFwyMWciDU+UMskijWef1rhuc/tH25w+L6fB6qS1cApyfiGe/eTVNKt6BKaTP7YpdkLGyVebSIQUB5BTd4ix6WAtQwc3mhmWN7MqeHI/bV7S/WHDGuklAzVxLoaRbCgZ/JxS1aQZ19abC+L8gI+mE6k3TSQRKH2FbM8gf2P0wnXO7hftbrR2oqDKGDnRD7lqIPMjLHkdHJA8dywr4vwHrMglpNpJ0Gqm0b56zKUUK7bvY+OspZU1LIg4o2fe4568kBAWNMpL2eCMpRx4tM96VMHaVHgHOoPKTJnorU9VRlKwfxMdIRrNMQC/cZYYjAE4ioQxv7Q== 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-SenderADCheck; bh=oVxDawwOjQ6gGWUHDzFuf+US8iggOewFtbjNASdw64g=; b=UW4sCsh9HHf0oAUu0O6dgCrZWW+R136endHWm5jB7IHJjNUhoB9MyewT17VjSZzWRZTw1+HGOWJAk5Z1zvZ0dvIELcniei/npksDEv+l/GbezWBDJ4rpdNX933uJUauvGvvQEPwrFYURyt9Kz/qnd7uKi6GsKubOXPvbK6sKRnBlpO7Ov7F0aUj4CUTrdjHUwamiw1RHl5PHmJqO71Gug+jTerwX5cKcqAXm/+SlJ9ekO9Usj/ztZe/6j7dhzEYnPvtILjl33Z7qIGiQz9B7che79nMVdzJeFQVRXucK8ex+bH/L2EO6vLg/3rK/+VaAAKRgwvbZfgoW7y+7uhPAMg== 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 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO1PR10MB4689.namprd10.prod.outlook.com (2603:10b6:303:98::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Fri, 30 Jul 2021 20:12:50 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4352.033; Fri, 30 Jul 2021 20:12:50 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/3] targhooks: New target hook for CTF/BTF debug info emission Date: Fri, 30 Jul 2021 13:12:38 -0700 Message-Id: <1627675959-17662-3-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1627675959-17662-1-git-send-email-indu.bhagat@oracle.com> References: <1627675959-17662-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: MWHPR08CA0042.namprd08.prod.outlook.com (2603:10b6:300:c0::16) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.hitronhub.home (24.80.24.133) by MWHPR08CA0042.namprd08.prod.outlook.com (2603:10b6:300:c0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Fri, 30 Jul 2021 20:12:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f99def4a-c3aa-4753-8f66-08d9539667ee X-MS-TrafficTypeDiagnostic: CO1PR10MB4689: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 594I4CD5CBTmSRx/bhblCQEWBhIlKjht4ngSXS3uR0oml6WgXUmjjPw9P/KotH4ks/D7jRqblUSDBKwD0FJ6RFMfBrsMeo5Jon+G3nfq75556UWGClcMV3rtJUymExIvkBOgZr96C3dwPNCyRlBkd8/5AUkNOOro9Cb/+4yP6uL+T5KdxXnYZIIbpR29ms1LtuxB64p8EQIKUwFwBDkALqoz2NEOLYIR6/bnmUsebKk/aQteYI9sk4BlJvsJzvUDjjm7VBl8ZB436nyaeLv0hPOqW2+RXABEe0RCYAcBK+aZOBMPYA51DqpQ0kHQuysuW0MK9+tzRsJ55so/1QpyKo8XHMAIGpnFMwdjuKOnHqtDzW9PnBPmZIueflYwiXne0UeBAyUeVwooA6zkt07Hgr/1VUvQTJ8rlSVSYfrxtte+JEkxwy0k6uYNXqsg8fbxqKO1b46La6voPwzSlYaf8q85k2vEgdr8a94K5U4/sPgtSz4NnHGIkcXXA/La+GLTFz9kYuQNvUOFhopv4KRx3qxXiPUbyWvR+djdjre0grJG6gLwkiAMmV1xcIVABps9AAcutnot0OXt4l+qS1VPDq8sHc1s4xsIOhkC70s+TadglCSGbl0Ez+DHPMzA/LaX2Cg9IKRps+dYS0/+TWpbJ105NviPzmzlJaMqnBRsvvwBg/2ZtPVXxeJrAKmloo9eJDbzntCgED0OnSLzHkEKqA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(396003)(366004)(136003)(376002)(66946007)(2906002)(66476007)(66556008)(52116002)(316002)(6512007)(6666004)(6916009)(36756003)(44832011)(186003)(8936002)(5660300002)(86362001)(2616005)(83380400001)(38350700002)(6486002)(26005)(6506007)(478600001)(956004)(8676002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8gIu/8KHPopLCg3xf4niN0Sx1ziHh+EZr1q0sGMoZ5jEtLEj8JCBBfvxYwj4WQK1C5WTe41/n+tDd6VGEiMzlSLZkySvz75eh63gwsC3p3Mc/Gg9gFrh40hsBjq17GheS+k51oD0aWexA75rQPaF19yL2AYyR5Ckoj+FQYPAOAUGTw0CjUTIDHjVRcJnt4p/cB66SGMXEBvjRC+9BfOMSBI+GRCKvt5CzWCrpy3Zc/XJ8x7grkbbHMO38ZW8JtSg6DPA5y82uW6OE5xLshdL9OW37ISmeY4qGqE8uY9Md1O37NsS5mivMc17UmwzMPtZ7g/CqXlnaquqCiugzrg+JbVsLXJyDBOWSBqmiqlCxgPqWAxp2MRU378bX2lKQHh43jPNJWp2TeK2GYpO53S4dJQH/tLR9k8JpXwLNF4HIQTdAbKBmwN3E5DIob/u3j6mtSDzzQRVwEfAjixpi/v1hWtbuxp5lMn6RK2hNSe4+3ppKJXY9YYqiZTgzWLmOc5KKpP21115QMYcCZQgF4YxhoCDIbRQWv/A2y6qTS1m4EVMFaVmSQ0MWu31c4DAuOTenoaZpVkeUIJDCLfxuTqaMgEkRJbRzCHpA/hMnQLYBC0XCLrTDaC8GkbhbLYlEdTeWN+xAXtF0tlKj5KtivLRYNYJJZv9/TmqKpA2AaStJMSe90D0WKgu7xOO5jS4o4MQ7ySNMoSlyFxmIDyvKwSg0sK7OyR3Fbmv2YnkXGzdrUQ73ajfDDL3XnOjyZok9spKnTA1ILF+41nXpEuCn+qVRQGsQLBAAN7xT+ccmA8VwBSzLNmxRBlZ//YZ8VxJ77x5xN6KB32DtG0js7DP6OLR6rltWuCoO03NGw1+97G/jW0bcEVPBxvuBWxnuN0EtIQTzjP8V+1mDTkheD8+dKQNvru7P1bvPRRdQ9tXowqFtiL4lTHlGcBCXwSsESq6xIBJvEElVawoA1egDbIU2y+zjy1qN78RUrcf4jBBZKcXOhWs3Mdy8HHnmA9bA5cUBxx6TY4x2ncdfi/RmWk3SQpp3SgvOTH99qAoywK9BjYj7BkBNCm0tkUDi6ma9/gqAz5+N2GbLky0XGxiNQ247IFrbZs3ZL0ZVqLq/ZFyV9zza0D4SgNmkT9bBnGLwinLUSNKLezB6ZL0EmCZATBb5SwwU2qPGUwvv81TDuW+CRxvQZ5FAV9RGkehlYqAQXfirJvy+XhxAUaQYPkRgJLqBCRxFakaRIXnw3KMeqkyjijbGNZrgmPDkPA7Y/ZAMUdIXSuCuB9LsBjwk+vIsUNmtN2sFVADezFPngEPZAfIrU3ARSzkvfo50BMeBZtQHb7vlobk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f99def4a-c3aa-4753-8f66-08d9539667ee X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 20:12:50.5262 (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: 8UNK78DLzEZWDHmUPqyqVjqmpT6HBFaqgcjqUecTYb4IG9v3F9VpLiNUgH9tp63wlgYz2u/thgkXH0y3cdlDpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4689 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10061 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107300137 X-Proofpoint-ORIG-GUID: R2IbB3_wnRAqwPBO1MkGiHxvDL0oMItX X-Proofpoint-GUID: R2IbB3_wnRAqwPBO1MkGiHxvDL0oMItX X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch adds a new target hook to detect if the CTF container can allow the emission of CTF/BTF debug info at DWARF debug info early finish time. Some backends, e.g., BPF when generating code for CO-RE usecase, may need to emit the CTF/BTF debug info sections around the time when late DWARF debug is finalized (dwarf2out_finish). gcc/ChangeLog: * config/bpf/bpf.c (ctfc_debuginfo_early_finish_p): New definition. (TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P): Undefine and override. * doc/tm.texi: Regenerated. * doc/tm.texi.in: Document the new hook. * target.def: Add a new hook. * targhooks.c (default_ctfc_debuginfo_early_finish_p): Likewise. * targhooks.h (default_ctfc_debuginfo_early_finish_p): Likewise. --- gcc/config/bpf/bpf.c | 14 ++++++++++++++ gcc/doc/tm.texi | 6 ++++++ gcc/doc/tm.texi.in | 2 ++ gcc/target.def | 10 ++++++++++ gcc/targhooks.c | 6 ++++++ gcc/targhooks.h | 2 ++ 6 files changed, 40 insertions(+) diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c index 028013e..85f6b76 100644 --- a/gcc/config/bpf/bpf.c +++ b/gcc/config/bpf/bpf.c @@ -178,6 +178,20 @@ bpf_option_override (void) #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE bpf_option_override +/* Return FALSE iff -mcore has been specified. */ + +static bool +ctfc_debuginfo_early_finish_p (void) +{ + if (TARGET_BPF_CORE) + return false; + else + return true; +} + +#undef TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P +#define TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P ctfc_debuginfo_early_finish_p + /* Define target-specific CPP macros. This function in used in the definition of TARGET_CPU_CPP_BUILTINS in bpf.h */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index a464d26..df408ee 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -10400,6 +10400,12 @@ Define this macro if GCC should produce debugging output in BTF debug format in response to the @option{-gbtf} option. @end defmac +@deftypefn {Target Hook} bool TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P (void) +This target hook returns nonzero if the CTF Container can allow the + emission of the CTF/BTF debug info at the DWARF debuginfo early finish + time. +@end deftypefn + @node Floating Point @section Cross Compilation and Floating Point @cindex cross compilation and floating point diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 0b60342..6119a30 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7020,6 +7020,8 @@ Define this macro if GCC should produce debugging output in BTF debug format in response to the @option{-gbtf} option. @end defmac +@hook TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P + @node Floating Point @section Cross Compilation and Floating Point @cindex cross compilation and floating point diff --git a/gcc/target.def b/gcc/target.def index 6b4226c..67bdcba 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4007,6 +4007,16 @@ clobbered parts of a register altering the frame register size", machine_mode, (int regno), default_dwarf_frame_reg_mode) +/* Return nonzero if CTF Container can finalize the CTF/BTF emission + at DWARF debuginfo early finish time. */ +DEFHOOK +(ctfc_debuginfo_early_finish_p, + "This target hook returns nonzero if the CTF Container can allow the\n\ + emission of the CTF/BTF debug info at the DWARF debuginfo early finish\n\ + time.", + bool, (void), + default_ctfc_debuginfo_early_finish_p) + /* If expand_builtin_init_dwarf_reg_sizes needs to fill in table entries not corresponding directly to registers below FIRST_PSEUDO_REGISTER, this hook should generate the necessary diff --git a/gcc/targhooks.c b/gcc/targhooks.c index eb51909..e38566c 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -2112,6 +2112,12 @@ default_dwarf_frame_reg_mode (int regno) return save_mode; } +bool +default_ctfc_debuginfo_early_finish_p (void) +{ + return true; +} + /* To be used by targets where reg_raw_mode doesn't return the right mode for registers used in apply_builtin_return and apply_builtin_arg. */ diff --git a/gcc/targhooks.h b/gcc/targhooks.h index f92e102..55dc443 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -255,6 +255,8 @@ extern unsigned int default_dwarf_poly_indeterminate_value (unsigned int, unsigned int *, int *); extern machine_mode default_dwarf_frame_reg_mode (int); +extern bool default_ctfc_debuginfo_early_finish_p (void); + extern fixed_size_mode default_get_reg_raw_mode (int); extern bool default_keep_leaf_when_profiled (); From patchwork Fri Jul 30 20:12:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1511798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=sj30V4w+; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbz9Y4x8cz9sWS for ; Sat, 31 Jul 2021 06:13:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1C2E3985823 for ; Fri, 30 Jul 2021 20:13:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1C2E3985823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627675997; bh=KezdGtI5Aclq2+VTxKza/3eYYtigjKSRJcWUK7haAG4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sj30V4w+JZfe4IDrXybJD3Xv7SgbWF4yEeWglQLvTzn5nr5TkI1BEU5nUo/ZsP503 qgL7EswlDMP2rvo50PX8Dnl8UoycegrNSx1MgauCIb0JOHEEjuW1NjArlsBrkrasb7 oAbRBXXS0ylNaVhDanaoh6rtD578h9ywMkMAAFJ8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 7D54D3864866 for ; Fri, 30 Jul 2021 20:12:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D54D3864866 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16UKBZQd030302 for ; Fri, 30 Jul 2021 20:12:54 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a488da4j4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Jul 2021 20:12:53 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16UK9fpS121026 for ; Fri, 30 Jul 2021 20:12:53 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by aserp3020.oracle.com with ESMTP id 3a234eta0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Jul 2021 20:12:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N4Q2HJVtCJqYhlodFeZG5ZLahF5xhPRphsY7g3wsuomxRJkDwpGUPUdLsauMBBxCI7og6ySNPCczUwyBnjgH61YIqyqQMQaHu/kn9anuCrjs1l1B+KfiHzTUX1YAfcSuCFSC9jmTq++MiwFPoBtAVoVNUKHAb5WUkp9m2ONbnKpqx9kFTOxrEHzgyeshOMehzfkNzdw8jNbalawowkYeBaXoGgpge/3o8oE1k9tAEKXTsyz2ie4brbE8KIyVMwfevjdtd4hTniLenXCKPghueC7+HXjl3nxNGlTVG7QY6GjxW/Kgh56w4Fai0ozunJt7NZeAOOqQYOftBjdZ2oXrwg== 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-SenderADCheck; bh=KezdGtI5Aclq2+VTxKza/3eYYtigjKSRJcWUK7haAG4=; b=ctqVPUQ/y6Z3X9N1c22oYjj/u6crHaoPklTm3YHbWjQfVLLz5vEqFWF510z+LxA41Vfkww2f/vepYiDwxj2HsdFWyKEgVlFml++Ika9FuAR5+TDrQkE9YRUQXSYX4abnGhVp3+J+VU5BNgUpOCK+dELLimTHgMFONSJ8cQMwDMMq7p45OBqd9FlrtwnFIYxdqVQ8wfsRQ8oqu2fP6utREXh6d9NNMkls3gtC+JdvU30vlpAVunaE3LYr446tlJ6nBYV1rPh6gqCqxk6c9tHmauyue9v5XYtDtey2SiR/U6KSb5JckonNogsolaBbMd4+uQnpHBRwyJNfXpU3w2pVMw== 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 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO1PR10MB4402.namprd10.prod.outlook.com (2603:10b6:303:99::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Fri, 30 Jul 2021 20:12:51 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4352.033; Fri, 30 Jul 2021 20:12:51 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Date: Fri, 30 Jul 2021 13:12:39 -0700 Message-Id: <1627675959-17662-4-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1627675959-17662-1-git-send-email-indu.bhagat@oracle.com> References: <1627675959-17662-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: MWHPR08CA0042.namprd08.prod.outlook.com (2603:10b6:300:c0::16) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.hitronhub.home (24.80.24.133) by MWHPR08CA0042.namprd08.prod.outlook.com (2603:10b6:300:c0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Fri, 30 Jul 2021 20:12:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d229e78d-808e-4f0e-e327-08d953966854 X-MS-TrafficTypeDiagnostic: CO1PR10MB4402: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AI/gvRkmzqYu0a7BAyREEB+SRc4lsESWmQXn4LEAptkVcVJOuG+br3GpYEbjUICytbEHGtfj1F3hjx7mv/lyNH2JvkMFuTup9Cr4HDEOhtmtAfG8euf/faHFo6RnK81lM9L/Zr4JKjS6GrvOcFhE1RdhsnUSDqOBJ53V6vCpaqKWAWbDkE3zdh3yexItqPMkLK17IO1aqp3oaWlBkz36S8d9yBHnQnlXvKviC8lY56oAWY2un9QNUyxYSuolKl1YeWcLdF4rT5cbO2LzIRGqu6SCyKe7/+NdadLiI3xDbyRzkl94aJaq6a6fxt60lBr8KLwxd+x6Z7GLqj+GLSoG3hsTRMMRiin2v6qAcTi3E5KyYfIFSoh5DDspFvs1KTh9RdlYBKVP1ims6Lui9b0E8fSFZqJo0IMQeCqReV9XuoMDn/ttWtPMYTBoazcLcG8ZyMNnkaNbQNRriFvWefHkJCrXw0iQZBeGIau00tJokr2l0Ber+dM3B8oa2BYlfHEL7Y/DS1orLjD8NmU3nqdgV9YCIkHmZmWsEAW5VDhsL5I9eFXRb4YCc5SXPXIsl+nJdAcpNbn0hjA4QQ3vbY3omqatTg4hH7nm6V4OY86rJD0tGoXaTvUEogqPdIHDiAa8DFxufixFg9aACQ8OYvAg+yVhHpBpVGr/Oxm+EPJTuPBl7YUQ5xZ0GKIywqdNzgn/IgrapTEjQqjLapBdlJNtgQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(376002)(346002)(39860400002)(136003)(396003)(66946007)(6916009)(66556008)(6486002)(66476007)(6666004)(316002)(44832011)(6506007)(8676002)(186003)(38350700002)(38100700002)(83380400001)(6512007)(2616005)(36756003)(86362001)(8936002)(52116002)(478600001)(2906002)(956004)(5660300002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2jPoUuI9dehajzY+PO9J49vPZr1HcQl3QhoY//lF+TB60W1RyD1rqdRLqVRPlyZrxTrXX52MKMP84EvWZjTV44D+25Im7QZrUVwn5RzlLURlNHxrCwP1t8tRNmANXc2WtnqYYOZFasW1eRTbYHI9fjResAWAATbN/x28pksN+8GsZ6xinIIyO735pf2FjTyI9Sdvv1Tk1dUSdqOxzBqPlJ6W/VRRg+xHVp9sQcUYGueVwcm3YCXC46kDdPjm+T/QWVB38iU4hP6winIuXhM9h5X9pihmfqTfXc39eAbXQx+BZqU565hO7p13KrU53jUlP9awd31Se7vYsd5QehZrmo8Cbmv1jQ0765XEfBc+XxlMyyx05YDottLZDPQpr7d+pDipxy7DWdKas5ZvUVxqEzKvKCfI8O5SpZbqiPsMdlr3yd31CoVWZdspCJKfpnObtM0NZJZca4xSLpS01bd4f5qoi4nOCQFe+N8Gd21/lm5rVjBMpWDx1bnybFKyMvMyNB+X6Bl+P4sWjxced4eJJyC3A+zODZxkpFQ57i8oFvXO2bWzs80ukeEq4TNFMM0n/MMobtslHyv9V6+7FMTOqnVIYNk21tvtGst2UaTRz9azs3YFuApYsk/OSC1CbN5ag9lAZCwRAMY054KN4rG8kdjGa3wv3lPAEWKoNZMW3Tsamm3Tm0BjrQrHYtEI9Rpd5WC/W2+T0L7RhQuL691HllKiQPDTNZ8gfaKuxyErATifDzdyXjwSDDZkabY/woqLmDu3ZgetbUmbGI47+j++ZprNq89qHZ3uElY2l91/jethYLs+BwHc1bVH1R/YJrb38+l2b7pHsdea8SFl2vE6al8d3boIoolkB2X3kGGmXSIp5cRl2tM/iRTYjLY/sHnj3WMQfFl1WCgcMh4GZ/K6jbw6sWKWmeLfpwPsr8hB6w/CAwUHgO2DAG+YrZqyI1kBZkOWeGX5qwVazCq+iEHtNBtqha2wfxEFRbyxJ06ycZqSPbVQvRXA6910JCvWRsDsUw6T2I+n6sJiSRapEllyq2i4RqQ18LXPGDYMIqpANDiatTczhCPWMRcN95Z7zUrs4kz4QX0zDg5OcInK4dESyCgq220rlFyblRBiW58gM/VvjvcS2+JtHV64t7ElG7zO/80qy2Tu7mLGFd0wFdhAlSTVD5BjjgWdpRTlpQMEM6lImA+F5pmkj5iRQ8bBOnWwFdLO8/eo75PXYvV+HLPFybB88l9XPgGD5LunYKxdBZeZofniclVh4AMfNyVdRL2V6ZEvY7KUovhJdqHH1w9EFPANl7YMGSRPzicO87zTfz2ILcD9/aPy0aITstDeJK0R X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d229e78d-808e-4f0e-e327-08d953966854 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 20:12:51.1948 (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: a20BLEr5fxN7pSEGMfoUYVNgkJ37mzCVMYBZ7Q0kB+lEKjl4Eq8w+7io2Rl2iRehpy3Z1LM6px3tyzjahUPAyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4402 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10061 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107300137 X-Proofpoint-GUID: jJB9SwpykLLOfWBLWcoEET2TnVUSss_D X-Proofpoint-ORIG-GUID: jJB9SwpykLLOfWBLWcoEET2TnVUSss_D X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" DWARF generation is split between early and late phases when LTO is in effect. This poses challenges for CTF/BTF generation especially if late debug info generation is desirable, as turns out to be the case for BPF CO-RE. In case of BPF CO-RE, the BPF backend adds information about CO-RE relocations to the CTF container. This information is what needs to be emitted as a separate .BTF.ext section when -more is in effect. Further, each CO-RE relocation record holds an offset to a string specifying the access to the structure's field. This means that .BTF string table needs to be modified "late" in the compilation process. In other words, this implies that the BTF sections cannot be finalized in dwarf2out_early_finish when -mcore for the BPF backend is in effect. Now, the emission of CTF/BTF debug info cannot be moved unconditionally to dwarf2out_finish because dwarf2out_finish is not invoked at all for the LTO compile phase for slim LTO objects, thus breaking CTF/BTF generation for other targets when used with LTO. The approach taken here in this patch is that - 1. LTO is disabled for BPF CO-RE The reason to disable LTO for BPF CO-RE is that if LTO is in effect, BPF CO-RE relocations need to be generated in the LTO link phase _after_ the optimizations are done. This means we need to devise way to combine early and late BTF. At this time, in absence of linker support for BTF sections, it makes sense to steer clear of LTO for BPF CO-RE and bypass the issue. 2. Use a target hook to allow BPF backend to cleanly convey the case when late finalization of the CTF container is desirable. So, in other words, dwarf2out_early_finish - Always emit CTF here. - if (BTF && ctfc_debuginfo_early_finish_p), emit BTF now. dwarf2out_finish - if (BTF && !ctfc_debuginfo_early_finish_p && !in_lto_p) emit BTF now. - Use of in_lto_p to make sure LTO link phase does not affect BTF sections for other targets. gcc/ChangeLog: * dwarf2ctf.c (ctf_debug_finalize): Make it static. (ctf_debug_early_finish): New definition. (ctf_debug_finish): Likewise. * dwarf2ctf.h (ctf_debug_finalize): Remove declaration. (ctf_debug_early_finish): New declaration. (ctf_debug_finish): Likewise. * dwarf2out.c (dwarf2out_finish): Invoke ctf_debug_finish. (dwarf2out_early_finish): Invoke ctf_debug_early_finish. --- gcc/dwarf2ctf.c | 55 +++++++++++++++++++++++++++++++++++++++++++------------ gcc/dwarf2ctf.h | 4 +++- gcc/dwarf2out.c | 9 +++++++-- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/gcc/dwarf2ctf.c b/gcc/dwarf2ctf.c index 5e8a725..0fa429c 100644 --- a/gcc/dwarf2ctf.c +++ b/gcc/dwarf2ctf.c @@ -917,6 +917,27 @@ 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 (); + } + + else + { + /* Emit the collected CTF information. */ + ctf_output (filename); + + /* Reset the CTF state. */ + ctf_finalize (); + } +} + bool ctf_do_die (dw_die_ref die) { @@ -966,25 +987,35 @@ ctf_debug_init_postprocess (bool btf) btf_init_postprocess (); } -/* Prepare for output and write out the CTF debug information. */ +/* Early finish CTF/BTF debug info. */ void -ctf_debug_finalize (const char *filename, bool btf) +ctf_debug_early_finish (const char * filename) { - if (btf) + /* Emit CTF debug info early always. */ + if (ctf_debug_info_level > CTFINFO_LEVEL_NONE + /* Emit BTF debug info early if the target does not require late + emission. */ + || (btf_debuginfo_p () + && targetm.ctfc_debuginfo_early_finish_p ())) { - btf_output (filename); - btf_finalize (); + /* Emit CTF/BTF debug info. */ + ctf_debug_finalize (filename, btf_debuginfo_p ()); } +} - else - { - /* Emit the collected CTF information. */ - ctf_output (filename); +/* Finish CTF/BTF debug info emission. */ - /* Reset the CTF state. */ - ctf_finalize (); - } +void +ctf_debug_finish (const char * filename) +{ + /* Emit BTF debug info here when the target needs to update the CTF container + (ctfc) in the backend. An example of this, at this time is the BPF CO-RE + usecase. */ + if (btf_debuginfo_p () + && (!in_lto_p && !targetm.ctfc_debuginfo_early_finish_p ())) + /* Emit BTF debug info. */ + ctf_debug_finalize (filename, btf_debuginfo_p ()); } #include "gt-dwarf2ctf.h" diff --git a/gcc/dwarf2ctf.h b/gcc/dwarf2ctf.h index a3cf567..9edbde0 100644 --- a/gcc/dwarf2ctf.h +++ b/gcc/dwarf2ctf.h @@ -24,13 +24,15 @@ along with GCC; see the file COPYING3. If not see #define GCC_DWARF2CTF_H 1 #include "dwarf2out.h" +#include "flags.h" /* Debug Format Interface. Used in dwarf2out.c. */ extern void ctf_debug_init (void); extern void ctf_debug_init_postprocess (bool); extern bool ctf_do_die (dw_die_ref); -extern void ctf_debug_finalize (const char *, bool); +extern void ctf_debug_early_finish (const char *); +extern void ctf_debug_finish (const char *); /* Wrappers for CTF/BTF to fetch information from GCC DWARF DIE. Used in ctfc.c. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 884f1e1..4d7b707 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -31976,6 +31976,11 @@ dwarf2out_finish (const char *filename) print_die (comp_unit_die (), dump_file); } + /* Generate CTF/BTF debug info. */ + if ((ctf_debug_info_level > CTFINFO_LEVEL_NONE + || btf_debuginfo_p ()) && lang_GNU_C ()) + ctf_debug_finish (filename); + /* Initialize sections and labels used for actual assembler output. */ unsigned generation = init_sections_and_labels (false); @@ -32788,8 +32793,8 @@ dwarf2out_early_finish (const char *filename) ctf_debug_do_cu (node->die); /* Post process the debug data in the CTF container if necessary. */ ctf_debug_init_postprocess (btf_debuginfo_p ()); - /* Emit CTF/BTF debug info. */ - ctf_debug_finalize (filename, btf_debuginfo_p ()); + + ctf_debug_early_finish (filename); } /* Do not generate DWARF assembler now when not producing LTO bytecode. */