From patchwork Thu Aug 5 00:50:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1513695 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=xEnkoJlX; 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 4Gg99V09j8z9sWd for ; Thu, 5 Aug 2021 10:54:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C7763983800 for ; Thu, 5 Aug 2021 00:54:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C7763983800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628124858; bh=vnObY0OUYHZ+4INKZ9rdInNNfa2fM5UoRSxARkfh8a4=; 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=xEnkoJlXoSTPtRM805icGMX1H2NjCq+qRL+pvvvXlQ2BihQHkJxDtEGB3KWHGNomt u+tneVNKX1dexdetfoRG0EqCqL5R+N5m5jtWGbHXlW+LNAEwgVfiSAYdCoALAqdHBu g32hcbqL67BCjNoKBu5Qt/YduSMsPbwkMcyBVOpA= 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 96B68396B42C for ; Thu, 5 Aug 2021 00:50:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96B68396B42C 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 1750or2u025090 for ; Thu, 5 Aug 2021 00:50:54 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7hxpjqqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Aug 2021 00:50:54 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1750oAFQ189052 for ; Thu, 5 Aug 2021 00:50:40 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by aserp3030.oracle.com with ESMTP id 3a78d7nnn4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Aug 2021 00:50:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xj/s05qDwBTZJL19NE++k/wYvjRPS6kj/7lnAvS8o18AiHl19J+rrOi97axiX/lgYYmzfD333xTe4Tv7cvCKi8zNT2LEpE1rJEiq9C1Espqvnty4JN5WASvst1t0aJw2cQCKjqUVsOCRBnVmhL3whZaWAoUndGCZfSUKlxeczeLTr1FKrGVw27bBZz8Uld/s4x9yRNXldtN1Qle6bU94c8dhNywPLe9ayrK65ygxt/YDNTIWZJ7yRDfl1TemV4vF0SlSeNhs/Xu3YEugOGgP8Hh2JTsMCvgl+Qg+GpI1ZeWq4d0c+VcGMoDcrG2wtCJuK+h1AWFEKjb+AK8E0CKe+g== 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=vnObY0OUYHZ+4INKZ9rdInNNfa2fM5UoRSxARkfh8a4=; b=LMIqrh9ObP212/GadRj6GmlHdUUvgin/FklOCI7dHb+a0n9lkiaj6E1wbfRXpDkwUetLMhoJZ5364UJqJLOmNJpR9GIUfyipBxResfYElTaQepnNfmoigquqpNcBcyIHB0b+All0yhmRWn2pYO4/lv3cSwAdPWWKIrq0rBdupUjOa59ZVUQRfRSA1oDf5TBZ6jsQQto4FKS9y4765myrGJIqPjTf9oTbsxlBf/lPThepQwga/vXbIWVkFg0tpiXWyNpInycULq/HGjWHesMP3H6VIUMcHV0QNp8BNc+Sgl+TODk7w8es6B1CZcykHCPzno52BGKUkjM9eblrMJMSNg== 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 MWHPR10MB1887.namprd10.prod.outlook.com (2603:10b6:300:10b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Thu, 5 Aug 2021 00:50:38 +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.4373.026; Thu, 5 Aug 2021 00:50:38 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH,V2 1/3] bpf: Add new -mcore option for BPF CO-RE Date: Wed, 4 Aug 2021 17:50:26 -0700 Message-Id: <1628124628-28706-2-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> References: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: MWHPR20CA0001.namprd20.prod.outlook.com (2603:10b6:300:13d::11) 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 MWHPR20CA0001.namprd20.prod.outlook.com (2603:10b6:300:13d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Thu, 5 Aug 2021 00:50:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d7cee52d-d656-47b6-1596-08d957ab0b09 X-MS-TrafficTypeDiagnostic: MWHPR10MB1887: 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: 7Ku4q3r5E2ZIEARl0lrtU6l+NSVw+od39KdUXHb5QjeMv6RFWmO0wmUOeCU+EkLZAQW7FMAzmxtQ+jvTdDIUp9TH6qoW3U21DmXpP3PJR/aMAk8N3Mt9CQ3XkrBHoknZ4pobXBcKk2jRMUFMo/rzo18/yQh/H79UKtRD9Txc+lFrvYjYrBcX0z+Ku5W5apbkrqAvqcDgbHh8FxZg97KtpLNDO7sprV2PQTco2qb0HQ8LCW0L4qHuxoC3LJOE67h3GYMqAOP2UJGlkVtF/XkOXD9Sh6rE/EC3tpVKrPe/7Ra5Bqsi8JmJYnlsXRM8hF2EfcQAAJ8JBJZfJjblsUw6hf3ClyMLKbl7uUngzmj7ngaLmc5z8oiJ3T9IBMwvMeSqTdxVNtWafMMWOu9etUcEyVZ5x1lIRVySR2ngahyaF5vaF2AlBXLNZbhCck4jnG1dAYNgNHOmVGPvMI34Stm/6HVSZbocmDZ+TkWZnSGrTXYMSQmJjfPuSZDBBGh23LE7kVDHdZfmUfshzvMY90yyPi42ZkrqXAUoS3IyigJDdIXBiltgdRen4l89KTMD5we4TVQziLB7/tpWxhsnyXzzXvkzmrRRXw+K2esDVQgzhUOO4FQYdAx8zXeP66MDLSvw961odp0Rx+Jtjv8VqP3TdT+JXMGuhG4qnFhKTq3WYCZRSBqfROuxf76VWQXpe2tNHnKA88TFNWURiF6kD1vxHsc50VnA0XYAXQPtQReggzNNryDAbHOms6kI+S/9QdJKON5i2Ad3buNDsL5rxi5K/w== 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:(376002)(136003)(366004)(346002)(396003)(39860400002)(6666004)(66946007)(86362001)(66556008)(66476007)(956004)(2616005)(5660300002)(83380400001)(38350700002)(478600001)(38100700002)(36756003)(6512007)(6916009)(8936002)(52116002)(6486002)(26005)(8676002)(6506007)(44832011)(2906002)(186003)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7KH3co4gVGSJxYDZu4Cgrt3ZXA4Ce1UJ/+ofS/G/I+EvI6ziXPNxmzdS/yjew1p4mjnCwl5SsDmDqo2B4gQ13/dzJsobpzR8F6ECsQVswdJu0B2LS+FLVD73aXnXcqp8yAURurjSFMs4ghaQlEuWHIEaxz54SvQJLMXnH6cuFdxqish03AEu6PjtxgprxPD7j7JKbn4zbE/5tSn0FFXJYZHwOCt6C0o4XV2jO0ReAjwJ8EpuhOofYijXF8U/OYCVbxtzzGGsjpp35N86VxjRGMUb1kMR7BsJP8kga1K+6O9x7oeLho4thivQQ9GHQxELj8SIp/ckcH8BoxziHuT2h+CHcuu+dQfcA0oeIcLDhnSdb99QDTDHRlYQNvns21IANWsD0ycvXEIhU1QuJ2dZxnkzK4L5fiQ8kO1sKFzpusZNS1O9k2Fwdg2G8+v97tx9JFBsHBLXUfv80RCBgqa/z1JpjkjY1vkmuPCq4HmTz8pNxcZtX2ntHzjzpkXFF0haQeLtNA6MQNL6sKPQ5zBWAhR2dkKHsQ5uHeoh+Um1x/HJPNtCRkRG+MxMFF3S6eN8HbHqfy4Rr3dkvC9MWHx51JZJpsHL3WexFq8StV/ff7hpllg6QYVfyCUZWAgoYpAMOU8U+1UJ470CEZK9KXC2zU+tMi1TaO5cLHXSEFPMxbjwjmWfOAaVPslSojTDu1kWDH/dcCsdY+RVUtn2HD5u5mfDU+A9oXDUGFpqwEHZTxjc+Xvxe1nLvkbfAU/F0or+aHmQcIq6SHPaNyHWzNkttiWZIY61ajO6wxclI6J36Fy0PM7AhWi80tX7rcFef0u4RNfJ8IbSj8LIr+dd998kT/R1kYU5Qus5buSYXnQ3JUPTU7ubKLGZW9G1wnIMSUW2kwVwteIHYMNhq+PGnXwwjKokDsRamDG2KOtnVbru+230G69J/xlPTA0tUWF8GWKqYRxTZ0+2u/toszxTbizgBPfBLQ8Wb9JRtwrYm2NmjRuACCk5hEkDCBI1rZ3kND73Itxz7vNKOpn+yMY1ASjzDIKtOP6jvIVEauFqRkxO146yvlE1mxOXonfuZu2ZcBprO8LbaRVDroA9OX1+GOYbF86d2PEJokbZdEx+1xcXbcPAE231VuMnoMZfz+wc24HKHlNQ/j/SIbwIWs6HOPxLu+FbZeudwUJiosPegiWWVfb+OdYhEYyhd3P9g/ahiM9oTvHun4PVXRz6oNKdRSfOnS37Ow0xi08KGi8BQU6iuQ3qFQMK8lSDOfdxd7E8PvOUxYkSto35Y+zgDLXm5w9SFDSu3s4HGKEH7e3UIaNBnqJcQVNbmuSOSoUxwITnVZzs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7cee52d-d656-47b6-1596-08d957ab0b09 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 00:50:38.6674 (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: 6/3msbszvDHhw8dMTq+mMrCBKgRi9OcZxuLV69fPRM4zV2Jhd3ejPkvIHc+IBOnkDDdNnlu3+MDN5ZCK+VTnRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1887 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108050005 X-Proofpoint-GUID: C41HsP-OvO7J0qDjGdCP53kSxRmvQCiX X-Proofpoint-ORIG-GUID: C41HsP-OvO7J0qDjGdCP53kSxRmvQCiX 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, KAM_SHORT, 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" -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.target/bpf/core-lto-1.c: New test. --- gcc/config/bpf/bpf.c | 15 +++++++++++++++ gcc/config/bpf/bpf.opt | 4 ++++ gcc/testsuite/gcc.target/bpf/core-lto-1.c | 9 +++++++++ 3 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.target/bpf/core-lto-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.target/bpf/core-lto-1.c b/gcc/testsuite/gcc.target/bpf/core-lto-1.c new file mode 100644 index 0000000..a90dc5b --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-lto-1.c @@ -0,0 +1,9 @@ +/* Test -mcore with -flto. + + -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 } */ +/* { dg-error "BPF CO-RE does not support LTO" "" { target bpf-*-* } 0 } */ +/* { dg-options "-gbtf -mcore -flto" } */ From patchwork Thu Aug 5 00:50:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1513669 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=8.43.85.97; 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=Iw3Ig7s0; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4Gg96y2cVYz9sRR for ; Thu, 5 Aug 2021 10:52:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACB39398242C for ; Thu, 5 Aug 2021 00:52:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACB39398242C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628124726; bh=K8VI+A31lPVdTCxpdkqKO8e+G+zyolF/UyhGstw50RQ=; 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=Iw3Ig7s0r7ar43DEm1dDA554oy2OrGXGmMOjgYGD6uFYxEJVlgkYr+Sz5HZ0sa+aT oetP1Fl/HXf09tQLHmksw/+xcBVj4ji0PVAxRPm13sJxjqqkybrO+RkZ5DvjdzcaeP Ep+IxZHU6Wa4pjxU/lvLIjLvzQdCs0qqRHYOkQxc= 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 37383385700B for ; Thu, 5 Aug 2021 00:50:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 37383385700B Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1750fNlr001733 for ; Thu, 5 Aug 2021 00:50:42 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7cxn30qk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Aug 2021 00:50:42 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1750oAFR189052 for ; Thu, 5 Aug 2021 00:50:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by aserp3030.oracle.com with ESMTP id 3a78d7nnn4-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Aug 2021 00:50:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RG1czJ1v3EHzA0L+vw/ra0V3TxXzh+nsVlou/lolJxh/A3biL38WzfLSQxFLhGIeuOcpZsayCcZDycgWGQShYvdf510Dj7h8BMm/nkLMu94mF8RLnSyDTqWk1YtTeuadu7Zc2z28VD/CuHOcxs34q61y+LO3r+ioIIERc0deagvNlrZVPxl6mrisUjDL7RK5FwgDXpvie2n3odC3XbdpAYUrkwfaIKUza3BSj1Drxc+zm6Ml7SnhAr4mipLVYZKwC6EUTP1HXtfxZTbK8vnEPPYiMGAEbX9uvW271yYfmJkT7cZSKX/cNc5iHpe8ArXV45Pshs+zSYvn5qqjsYP3mw== 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=K8VI+A31lPVdTCxpdkqKO8e+G+zyolF/UyhGstw50RQ=; b=LbEnL/J5OIqaEt4pXnRP5GURK2VoSawu9MyfoPd3EOcb/xiK0+HWATJD/UPkRB4h0SXXmabIngvaqLEtCnEyTHyCPT3WhgXhsgXjOFQxbJ1yv+vNDV1c7yD8gd+eD0TdASrUVfTpLRH06jLopeqMbNbndAQw52KZNsaGC3KMhh1jrsZPcSN+OHGvGUx0s5tILSC1NRbYkq5yirBCFyM6V2F+T1wbznlqZoS+SjaazR6OrzRlxaWW+REFdj+L+H7AnikzZa4qyNzGK5+zoNNOs5l0ziogT5C4KxX1vTnron5SAMgH9ahSckCBqQsDug4C8GgLKGHTbtD8lmnjpeClFQ== 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 MWHPR10MB1887.namprd10.prod.outlook.com (2603:10b6:300:10b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Thu, 5 Aug 2021 00:50:39 +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.4373.026; Thu, 5 Aug 2021 00:50:39 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH, V2 2/3] targhooks: New target hook for CTF/BTF debug info emission Date: Wed, 4 Aug 2021 17:50:27 -0700 Message-Id: <1628124628-28706-3-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> References: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: MWHPR20CA0001.namprd20.prod.outlook.com (2603:10b6:300:13d::11) 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 MWHPR20CA0001.namprd20.prod.outlook.com (2603:10b6:300:13d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Thu, 5 Aug 2021 00:50:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f2931da5-1710-445d-b257-08d957ab0b3d X-MS-TrafficTypeDiagnostic: MWHPR10MB1887: 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: kHh5EoWPSYMFi0kka8OsQ4I2uNdwMcKPoDHkeC1A4iTHF0AL/RoHDZQwYGPs5WHLa4YhoOODuvgFLoyQ4aemE53Fvl4b7r+2OysQ5FATgR7B6fgIMwQe+9fkB/bOLa326/y83b5xSy9Gh4foLTsSnHI0aLvS61/lY9jX1zo7aMrXacNkPL8r6XVIL9JeACi4DV0QHXK5MchArqnQkYe3OsLZFVLS0KRR3Lw1/KrFajqhWn5d4+oP6LLlUMxRRHHHkGjKhTN7MrVGVht082MUJtOOfSnJbEPKeF2SERVlMXQp1O0dk5ibPKmGb2URotXiNXRdtXZrQsdVfgeXSKEZPmLNMxDFffAcyd0uD1KfIrptu6/i7gPJqqQkCnDAhlwxX4wQqBvPkGmMcbsywrhK/9WVqKmmh+IQd26XJiWDXhm1gPSlbysonQENjl4fHvsBkDxU9hNxvDEI/bTcFihFVJEr4b+400x+XhlwxaCosSlaRixUATylJI9k4jeSho1Xk8AteP5SkafoPlKjZ3ICs8myaYCo2yap++w0/99Zb8Hdv/de7fwW2vnjnEifewpI+p05yycTbMPkDutWEDigjmzE5VVEIkvTm7AXu6Jq8NLAM5FPua27I2PZhl/s6FBO/wYud6nhsXb8KNiBaWy0+91PjKBe5ObTYQLvc3zb2mUDqBLYp1N7p8nfh6C5vdsYCB9dimIqiwYpU17JvPk8DA== 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:(376002)(136003)(366004)(346002)(396003)(39860400002)(6666004)(66946007)(86362001)(66556008)(66476007)(956004)(2616005)(5660300002)(83380400001)(38350700002)(478600001)(38100700002)(36756003)(6512007)(6916009)(8936002)(52116002)(6486002)(26005)(8676002)(6506007)(44832011)(2906002)(186003)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ClwSY/NYLNyuI0Msu9BEaU7pKKDa2WUHF0D0Sn9ztH3vpL5epxWlqsR4KnJBYOwzGeGjGT/yHeMWemrTQuT3c5n+CfS8wKwrK5pG/5CROpBiybYz63NIYOHlUKN8DgX4wPC3RJ2PYq+7G6dmbybcJY2JudaM48aGFlg9IJS3ekzDK5PAMBnQUYfU8Nu92Rodm0OP5FeBbpaMzED83FHDvDuPq5Z3y3O4ehUcoC3yRfTsymEDs0dqRiki5an01EKZA8ovntt/5rM7dB3cvIXRLbXHuDqsqAjP/NHQP29FeODt+/RLVHvq/8wlBp9las7ozYiIR6uQYgEROYd9j2HBgJFq+e3I8lqsUPZDiZy0ckAlAA2oxBi4Yhiw+c4TNNXrNssCPDUMQw9vmWthe/4gu+exa9fTVkQQyZ2vNJwLAQigzfusqFz6eBN7ouqiKkQ5LKE9URfgg471cLpzPoMjLM7+6sTnw1X37mjWkh/9jCK7ts7yqepJeNNMT9bf4gSiYMIzbB50LdnHwP3J7XqHFzB+V32mZ/TOX4McGsogiAPZSAcFcB5MtQ2ftRnZLRijIInn18hJll5FY5ioFH/XJza1G/T3Z2XyUNgq5goHTd20UEnrCCyMlVTM0U0gRbdaKs66a3T2p0gKl8K/2XwAJ//Rwp07gK4s/hShXQUYteQKi1OgD8GA4xWx5Wph75zvbbxETTMFjNZLsD4xyVstejuXI34bi3FcO7nPLQGWPugcLtLgjNUXYtWCLsSQiS5eDULuGvwloXaZLJ+hXr5BuKUoe+AUTLEY+8511KcbU2nKUEvSQGVJbk1jPwqehovtMr6h15JnctCdiwha0FnvWBSF+GVKqPONW4Qv6HWVbmPIJcHoVgEdFDRwuhvX8bk1ny8zVoaEPpZtL0tOGHfw34Q+RbxPOZ2OcMlSEFBgksdpLiexknlV5hhW7tEubO/rD4EeMVuwewBTTXZaob3h+aoKnYt60zJ69N6CTZ79A/mJdPIUb1j9NTFUAojHqnv+UlpTu7psSG6E8yf0z/5xO6ICb+4KOcUwkA6tDWW/wkeuwlmh2AQNkYuyXKcyU1R9YCICrMemarWSW6T08jSShsbzxXv4m5/+6XqrfJ8V5S070gMXWqhe6dpHCm/9AFUu/LCImKVI26euEiKlg7FI/gNYW3moWI3usrg5wY6YiniRGoMlhQbFDvZSVicLViOtOZH8Mdy/ZqFUmSzvK/RvP6bjcu8WQ3rAIHtuIYfIppoqgXQlSCrUiP8UoFSmlmMTcH8/+/ZitIAf4cPhJeD9V09a3ILXr+N6kO2/grEH0zuo9eeDeqJgFNOLTb+y6r6r X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2931da5-1710-445d-b257-08d957ab0b3d X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 00:50:39.0981 (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: VL55YBqTnhKThubmn86+VFqfUu2NEf+fLqix3b3XRco/nxA0gpzTDrkXgCU2MNcbNKFEzKYPreABQtiVvr21gA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1887 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108050005 X-Proofpoint-GUID: qpbP0rZVnkPZ7XXDlCVNZCvJQCH0G6LG X-Proofpoint-ORIG-GUID: qpbP0rZVnkPZ7XXDlCVNZCvJQCH0G6LG 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, 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 cb01528..2d5ff05 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 4a522ae..05b3c2c 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 68a46aa..44e2251 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4016,6 +4016,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 Thu Aug 5 00:50:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1513678 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=8.43.85.97; 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=Dqn8Yv4e; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4Gg98j6c3pz9sWl for ; Thu, 5 Aug 2021 10:53:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B2CE9396B42C for ; Thu, 5 Aug 2021 00:53:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2CE9396B42C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628124819; bh=q+9+nr/l673hQqATQbwUXAu1JbxGUaGilTkrqXMkF80=; 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=Dqn8Yv4eIf9kynUcyp26wvI/Hg+8j0WiWgvpOUKT1P3rHRm/ryw3wgBf1Oh2vJ6s6 rio0P+yfFO+oLii8PZmDLzCDiQk9X7u7/FYFCSpsPI5OU2PhOMzgXMbes/7+aEzMec KCW9/I4kfYkuVu4lqYmb/DoITyRAHj607vzd9rgM= 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 1AD6E396B40D for ; Thu, 5 Aug 2021 00:50:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1AD6E396B40D 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 1750or2s025090 for ; Thu, 5 Aug 2021 00:50:54 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7hxpjqqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Aug 2021 00:50:53 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1750oAFS189052 for ; Thu, 5 Aug 2021 00:50:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by aserp3030.oracle.com with ESMTP id 3a78d7nnn4-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Aug 2021 00:50:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k73QdvMqusNBe3LK+NFndPAEga5VCFCw82wNdiaKQOA2RWak/AN8l/evoiDaGgyDARbgBkF5YNNPu0WbaxvH9zz157kj0wMco/Ms9ATa7lQx9b82YeM21o1zb9ZEMVJiKBa3ZpsRbPFxWQp8AAi45o28HSVowSdlXWPrL+Urs0VTJ48yEuLG/IYvzJJ0bAjB3MEtv6GbTx4tlL4SKknDd6HElEhRfP+seSHzjkZf2Y4azcjJBhxvX1MvgvQgktD5ex9IxOjqSezFGW14UPJhhkba+f7u/LxpEjaTRWEo8G7indC2isI+v+LaAqvYlPqbEen5kVFt6BnZUoTXoZNQsw== 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+9+nr/l673hQqATQbwUXAu1JbxGUaGilTkrqXMkF80=; b=lDKgL8YU3pAs3b2IIPGDovtv2vDtxMrIBbWwFOdRuW7ktH/LDvn2cdZajmRxwUFwNAgP1EwhIfebpN17Bz+M0fhme3NkMqJOU2JuKKkhP4Q6KpjeBuz4Egu5MWZMnlxF9OyqIiqZbKH74dnUD5zCnDCoeG0/TcpjagfjRyHaXHqdaxUrFzV/0PICF581i4g/NIGpRu34Mo2esrisriWaglRM0kYpb8f3+V61QObhhVObQhyHrTxHC47gv5VY5wKUb7tciw+tlZggKNxnTRMSKzb8EO8UOkN+Z3G9+XP6MPVUDjDsoEJ4k3YGFBAP1743QoBPZ7fM/kwLx5AAu/CWiQ== 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 MWHPR10MB1887.namprd10.prod.outlook.com (2603:10b6:300:10b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Thu, 5 Aug 2021 00:50:39 +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.4373.026; Thu, 5 Aug 2021 00:50:39 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH, V2 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Date: Wed, 4 Aug 2021 17:50:28 -0700 Message-Id: <1628124628-28706-4-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> References: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: MWHPR20CA0001.namprd20.prod.outlook.com (2603:10b6:300:13d::11) 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 MWHPR20CA0001.namprd20.prod.outlook.com (2603:10b6:300:13d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Thu, 5 Aug 2021 00:50:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66528029-143c-43b2-2768-08d957ab0b7b X-MS-TrafficTypeDiagnostic: MWHPR10MB1887: 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: FLqrbHHGjyLHJ37UtDe/VahbsBiWvm6W9WOVq/mHMpk8bvl5KIfD4i26X+N76FDOyEqG2G99Lx963Y/6V1NQy+g+drqUbybsfNURMnDyPmCEdAk14FEXXruF5Jf2G9ySlgLQsoOnyaTHk8U5pMJqwmr6d81r8z9utQ/VT4miUmNEUWncX6VIgwOx8UVGj51c6d/XS0tKCE2cmq3+E6SBc8aDaE6Zv9cJxhMv6kS6RImGAj8M2SQ7T7bJTm0lMGvo9xCHWmU2kZNNnY4EWAYzP8j0dDXYfB/zXKPFj3y7qSzc00+HOc7bn/POTIyShvVOv2uzffInzMQgCs2ai8qgh+IEuO4yEWJ4boSP1CdNKi0Uc7bzyw+ywqhaAD5dc3teAmABbDKXY1M4+i0pFXi3KDz4xwb7RtpRevNV9/DFJHbVIYAfSyJ3/KQCW+qALWnviK2hlIcDIJwitNsaLNfCcGjxgWnqK4jzLmMaKL0OaCqP3/DW/7mAUyvukKjYuMMRdW4uP2vmDf04X6Pj0+Faj3qA1NHKD8hPN5qjoG6Bfm1P3meHBKYiYzGy/tG/SCoOhe3OuT02osU6z4ULu+dOO7wHI70M9+45XP6C37HRfamcPx9i/pF4uBQeDzcuLzBW8Vkk57Cf5dS4I++3gKVLYgcDdpOsw5IW26Jt+4UzkHgawDEEe7W3VQQm/qyRs4UX3DvV64QnrsnYNJxJdir0BA== 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:(376002)(136003)(366004)(346002)(396003)(39860400002)(6666004)(66946007)(86362001)(66556008)(66476007)(956004)(2616005)(5660300002)(83380400001)(38350700002)(478600001)(38100700002)(36756003)(6512007)(6916009)(8936002)(52116002)(6486002)(26005)(8676002)(6506007)(44832011)(2906002)(186003)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Rs02bfaVYH4WF5wPSoaeeixcz9qMRKCCCSXV+N7tpM6SWOTCaYiVQh1bYeAfyB1GWqWEShW2npKPVbbkG2afns+xhLY7j2UOalx3ARtXshTPTlfpVVwIUauWt8+jyXwsVu/WhewiuIIP+k9EtZx5uvpH3rh/+BMyw66NeM3F2nDiNuy5+jdh+Kj9nsYCOa4HvNgOY2rMuw+6feqoMfmqLoCVKu0il5+I40WKPLaEi1khxbEtryLmgcryavYK2neXNVVdD6mgJdoKdzrpqoC/7kU6Rtae9CK7ZMJ949HFjd6RZ61yw88gw3egir0hTjmsGfrD7+9yy8RvgRnltCed7MJXH3KZNVDc9DOuyMgwPvArkJyRfLrV6IhBmVhQIbBMh0wV7QAed1SoubuZ5hm0dApd+lP17R9zLHecES4ypV3CLwIErI5b0tZyNUW4eG4Y22UecfrpywkGl1G6LIr4HGFTp7rLDBnbvaMg3QtZvIxljaWt/F3lysmw1pagLGAhjK85XfVl5Z6gKKHvSnmTjpUXYYL9C+DpyhNSEXx1gqXBpa8IFe/9d1Ezzae6HVG8gWcLT3lcr0P7tXnc/l0vkrTesBWNpS6EALeIxmssGGqg9AQkoOla+ffM2NI031O6+DhXtirMEmUaAog81HWO4SRVyyRShHLNY1GT1SbafXgIoSj6Hua7mpJ1LngKyokIpHj77iYZFWM4oN6gSOiF5YBMzb7IXHqCus4mkrQjwtyKDaK5S0LBA7VeD0zG3Bh3xAhn0FxeHx8wVuHNh4fIqkE5pykj4ymoXpqFJbi6lVYJQgCLsyOPpLxm1+0xJKRwyg0J8sALgYo5OxoffgE85spXAFNY6ca61SiqWKmvYCY4cwwXFQzEJ/5ZFm1n3Zvcx402UfAtLx2tOVwhjxMrC8PbsEpkwX6UKO8Rvus4FqS+3mS/TCE1N3OtCzEAKgw1fERCKojr7K7hBCj0qY0TJBFjeNHvhiviOcovWNnGx9TW8ak2ciidmCCQ+RDO4KTRlEmlAhDWkZxoYX6dRcZo1INrGkhMZpt9IrlNFe/n3H22jmaynuFz0+r76/gYP/735+Jr5MNIVApI4V9heDkyN8K6aBxXngdQqSC/rhxwnU73dUsBewvw8F5zVswQ7S3Psve0J/19KneEpIYlSwwb3YEZ2HMCEtelX9znF2qJrKSUn1kDoI7S2OWsFqCrLdZO80sQg+OMv4aDmYWMJZJtxQ50pkeW2VtjYK7FdWLbwpq2IUYJdSi5MvgEuM4Ml78lMDvtYL3GIJHTbFCXqoq/DFe/0rhIWfUPMBeP8m1OqadLihLa0/4LHFNR1WckEdSY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66528029-143c-43b2-2768-08d957ab0b7b X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 00:50:39.4849 (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: BpPYJ/PN6UtZodvPaJG6QOlVOckq28dLOwF5aOMhkFx1DF7UmWWFPsJG8mdhie30W/legphi9geiKJ/GJpZJpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1887 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108050005 X-Proofpoint-GUID: cZizHA0n0DyDbAZNpa-NOpeDQQD5XbFo X-Proofpoint-ORIG-GUID: cZizHA0n0DyDbAZNpa-NOpeDQQD5XbFo 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 b91a9b5..708cd1f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -31895,6 +31895,11 @@ dwarf2out_finish (const char *filename) unsigned char checksum[16]; char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES]; + /* Generate CTF/BTF debug info. */ + if ((ctf_debug_info_level > CTFINFO_LEVEL_NONE + || btf_debuginfo_p ()) && lang_GNU_C ()) + ctf_debug_finish (filename); + /* Skip emitting DWARF if not required. */ if (!dwarf_debuginfo_p ()) return; @@ -32799,8 +32804,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. */