Message ID | CY5PR21MB3542F829E8CE4F809219707791269@CY5PR21MB3542.namprd21.prod.outlook.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1143166wrs; Sun, 16 Oct 2022 13:25:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LfhP40A9E67Wx/jDa2/p5e60/GF4SqO/vIBd8rPfwvN1VeMrj9ZDBsTT1Elu4KSPkg+4X X-Received: by 2002:a05:6402:2b85:b0:457:6216:d251 with SMTP id fj5-20020a0564022b8500b004576216d251mr7466585edb.56.1665951944263; Sun, 16 Oct 2022 13:25:44 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i10-20020a1709064fca00b0078261e73261si9628577ejw.567.2022.10.16.13.25.43 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 13:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QQNjAMCD; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C67A385828C for <ouuuleilei@gmail.com>; Sun, 16 Oct 2022 20:25:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C67A385828C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665951943; bh=Sg3IhglBnJ/Y8oRHCSe0aQF9sTIkTOxurVYYwK6EHxo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QQNjAMCD8UAzVa/PAng9P0Os4BFPEPx5Cgxv34i4XU+5kqgPjR6Qjadb2TRF0uHmR ArHjM3V0umnnUYWMDTBhDTtC2dSEnrSwFo3QJqCod2ODy9+ywmyHscNBNg/p1+RKuJ hPSbEcJQaPeXxdrLC6doAM/XIs42dNvP/NwMCiek= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from na01-obe.outbound.protection.outlook.com (mail-eastusazon11020020.outbound.protection.outlook.com [52.101.51.20]) by sourceware.org (Postfix) with ESMTPS id 4CCD93858413 for <gcc-patches@gcc.gnu.org>; Sun, 16 Oct 2022 20:24:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CCD93858413 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kQkr3icrqFZnrWcNlFQJGa7efHJjk0YQ5yMQdD4nxQnZQNe4VHRjKTjb+OggeCD24i4rDT3wfNRs6XUoKVfTIVjdFebvy+9jUqu6IEEyk1Aoe464xFS2AHKJpj7yIRmGX6RhmnkwoUDGRrd/OI0xFv6NSqJF9YtZOOgM++NhyKNbe2YTS7KMLa5k9iWqq2p8DPVtYIUogqtTJcnO8hIq/x8qFwiqp87bm3S+IqKDT33NwNVBOgDZDnrrpxxhcj0510H28AiqLqJBRxiatj+rutm+IqwerPfusOML0u/wGwRwGuMdEUtbsvaoKM6RcD+d3jMnvCq3BnhkrMz3E6HSgg== 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=Sg3IhglBnJ/Y8oRHCSe0aQF9sTIkTOxurVYYwK6EHxo=; b=mpCxCLETbo1JlTxwlT94vQ8i7vMG6+8DKvDNZHOqOt01NTIaeGbethuPntztksvsB5MBowa4XgAafTcFVDOaAwzwhNNshxPlbTaeFc6JQgMRipf+KBHsAH+Dh+UMTaS27xLCDkNsa6OcjSNq7AbonnfjKRB+NzOb2kR8v42lEhFR1fY6ESQwIxU1aRYdN0tX4sqeTdhWyKq6qO3lp2QXoe4PoljHgzhYlXUKQ5mujg5qEGNSjlZIcqOAJ2HJCa9BH3Pg0W/FzSujwlm686uEO97uqL7Q0nKjDQnRkJDEU9diompE/LyzPcUHx/VLwziT3iBrPDu/NjIafm+4Y+p2kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none Received: from CY5PR21MB3542.namprd21.prod.outlook.com (2603:10b6:930:d::7) by DM4PR21MB3610.namprd21.prod.outlook.com (2603:10b6:8:a2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.6; Sun, 16 Oct 2022 20:24:53 +0000 Received: from CY5PR21MB3542.namprd21.prod.outlook.com ([fe80::ff72:1a2:7c8:1b55]) by CY5PR21MB3542.namprd21.prod.outlook.com ([fe80::ff72:1a2:7c8:1b55%7]) with mapi id 15.20.5746.015; Sun, 16 Oct 2022 20:24:53 +0000 To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com> Subject: [PATCH] Don't print discriminators for -fcompare-debug. Thread-Topic: [PATCH] Don't print discriminators for -fcompare-debug. Thread-Index: Adjg+x91bYI9Uh2kSX69tWF/1EUr3A== Date: Sun, 16 Oct 2022 20:24:53 +0000 Message-ID: <CY5PR21MB3542F829E8CE4F809219707791269@CY5PR21MB3542.namprd21.prod.outlook.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=32d52412-badf-4e55-abab-a29994e9b759; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2022-10-16T01:02:36Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CY5PR21MB3542:EE_|DM4PR21MB3610:EE_ x-ms-office365-filtering-correlation-id: 69cd39f4-d888-49e1-b003-08daafb47be9 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WAJ2Mio3qqd6nJzDcPquVwosdidoDbJ61IQtbo8r9LaMn4Ozjr8KdkF/5OFyti4bTgdRUpDs0UJzWv/X1G9AoTsxNXdFOwUpxepS/8ppAhldmx9DKggicWEt4j1j+ZE1kgAa3T7wnXSXGX2+3paVROabydnqUUqKrudSLtgDElIIU+GuJ74wyNi584dqUq908Y4yHIUAtL68f6/hYeYn+9XFRmf8GDa3j5TPZuZXujvspbuVW4lqupy12nnMgwsNvW9GM2qbV37GFnt+YytgtMc6YzcQ49tjP2i3w7bf4DTHIOzBs8HRTgsOZnZ3uhc0TiC5s/xXngzH3IPEaVyvUXsZ9NBuIDFCoF/knhN8fOR6WHLVnfmsEcyIw3AXqqQkOkzkGHmQQJUVnm5kRwD5a9WkEIvUArVXS17d+ruz68qdrUr3Vo0iZskF22BQGxOhvaYlXcY/BOJUlp7ij8DqW6YetsCyzaWrg0rRAdJ0ntBNHJCzRgMG4zjbcaUVAZMs+75CdaRqwj3c41N8Z3GSXXrYfJ7MvgDpTrctL/7MJtznCPNGwHbUdw5T/cRd3kLfCVKPOBHCzYOuNPXHM9E+vI5or3LaIq/8gFgnVRvvn2HRvbug9GwK3ZAB7TpXWXGwARgLfr5jstCVYuYwWX4YmfUULwLC03EHcdNM9fgTY8Es0F9CVO+9AFIxIFgPJ1zzG+5ksDljTlMxLh1zm2m2DQ6ZuWgieU+bibonEAB+wKZ+IN2XMpvPpCUNNmqK46dcX9pQDjM8v2t7ZUwHDsUrT8R3W/TAb1V7D8BBfm/DUM7ffqbJ44aEo8YSfE//n035cUnoHIttV+UwJ3alVTM4tg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY5PR21MB3542.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(376002)(366004)(346002)(39860400002)(136003)(451199015)(2906002)(38070700005)(5660300002)(8990500004)(55016003)(82960400001)(82950400001)(52536014)(38100700002)(8936002)(122000001)(41300700001)(8676002)(66946007)(66446008)(66476007)(76116006)(66556008)(64756008)(83380400001)(186003)(316002)(110136005)(86362001)(33656002)(10290500003)(7696005)(6506007)(9686003)(478600001)(966005)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: YfNsoaFLWb/5+2h+6KPsrMT8jn4cR2xwqlegnQBU4jw1L+ldauv5774QK9hKiQbBARfHKNQnxw3smBhI3TXqMiuODvdXZKjg2YOlOi8eHQg970ff84DKjE5CuGgYZdoqbcYUW6jHp24HSStkuAyTmJevD7L7m39XE1w+fGSLvqU+EShRKQM/7MYPsuJGkIqXja9zCcYG05T27EvebZOnhgJh6sY18riguvvwjSRPCwhnsHDmYxJJT5UUR+/w8CC7az7E6ErGBFqqmdyQBE9i4zjZTbAVyJBmgBtxU40Jlry8p5kwWMgYLbJgHYyt+2eGllQsxOnlzvJ7+DZ59ARimkWQoNUztn03x9vLdKQ3t2HGB0PGQDkKU3YtIxsIeRXNN/hXdb8ROFI3DRfyLbxJj4xUWAXseD3amgB8AMsInXEDnNiXu8d+zzcsDpNTxx2b5/KH+Jvh3IfVL3ZthMTQ+LynFjZYq9q87nrkdogVMQLPAtFyfJXRT7vbjJBPUrJiIqe3kqu8k0KHBg27V4ZO7p+1bJ2jFbHZ861ImEAutHlUlxMl79Sx0Yubbb5+hwvmgMRiPNw2ne68p9qDI51v07Psov/BsnBdHntBPFsUafPd7TR5IwsWwpBFqWG87OiYRoc9l26qU/0WqAL0L15dshbDnHYbOawCWni0f1sYMIs3SAtsEBz3Pj6O2ybPtNWzHZ+SwKEJAquICyvQeJYirSV3lVjrSHhlNrBfhLqRJv3CGeh5FEeoeyoG/6Hioak120gDhWMUZf7fIuOqfkkJQv/WGCD1aHS3t9txWLhOelAzDN+CHdPzR3ke1vQmQb5aU8mPqmDime1DMmA1Cs1gYm3oX82NTB09S9h3wBmjQcxmm6rL5zXLGn5cuEkFME31Rzk1Mpemj/JcT1OadM1M7FiX3PLP0CxMrZJN50zPY9rJY+/GHUXS33okhUF4SwMIlxdD8WOPHE0ET/4/+ZhI8/3v40FIGYZ5Bsd/eJrPY8Df54l+DFPXDxo7d69lDa1Beomp5P9TaINWVfhU6xWBr3DdUswWmDsr/lJLcoAVPmZGS7DvERv53gzzg8hsKJUyyfm8TUBAgxanqa9uqvAPBl4Sr4xDBc/OMF5FxE0ZOsQ9C6gAuYwXSW/J7fJB6TaogoNYk9kCG3GNUtcFTAor9zkkcIi1oJIJ6hqWzjnFW4k7JWTPrTxblCJvpkda1xF1QdRBWGQ+TOseffaxG7IBxi1Oj1jhwEMB6BTOs8xs6HNlwPnYaERLX99GGyS4emZSwEXJArMoSZzYkt/LkC7uMORxeBX3dcG1DW0w7Oyc5tJXP/uwWKBI/CWsAaHjBi+efEKAbpH9efwyM+cJbccUssx6tsw8qo/lknkBWDPA2HLTRwV88hVy93hcGJk9lvvxdF1EskHR/aZjV3/eY7TAwL5zOZBSfmhbcUy19dHfkCAIaSR8vxzanNikudM8g/wuQ0AreO9bSO3QyFRKRSOkMGdh+X2as3Cb5JYjz5gxqa3QyH8AjtFavryVj1xZnPFHAbIaJCmpswcraNhmiX3+FGAp+X2vsXT5aQDl72gDfgQfP58YYSSrTB1586PJ0/m1G3L03/uWsG7BQe9cmDSD3nvIHM+DZ9eOFaGYw2Sf4XjgiUk33SgxouQDqw6Mw9B1 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY5PR21MB3542.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69cd39f4-d888-49e1-b003-08daafb47be9 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2022 20:24:53.3920 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: AnFpXX7iMu94Sa99dJSDsnMhP3GcFuEH/7VM6D71oDeLUL9VKZEXUSVqiqscceyQw1GmkqQYSIVOda05VDzLlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3610 X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746877225914070592?= X-GMAIL-MSGID: =?utf-8?q?1746877225914070592?= |
Series |
Don't print discriminators for -fcompare-debug.
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Eugene Rozenfeld
Oct. 16, 2022, 8:24 p.m. UTC
With -gstatement-frontiers we may end up with different IR coming from the front end with and without debug information turned on. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100733 for details. That may result in differences in discriminator values and -fcompare-debug failures. This patch disables printing of discriminators when the dump is intended for -fcompare-debug comparison and reverses the workaround in a test. Tested on x86_64-pc-linux-gnu. gcc/ChangeLog: PR debug/107231 PR debug/107169 * print-rtl.cc (print_rtx_operand_code_i): Don't print discriminators for -fdebug-compare. gcc/testsuite/ChangeLog: * c-c++-common/ubsan/pr85213.c: Reverse the workaround for discriminators. --- gcc/print-rtl.cc | 13 ++++++++++--- gcc/testsuite/c-c++-common/ubsan/pr85213.c | 7 +------ 2 files changed, 11 insertions(+), 9 deletions(-)
Comments
On Sun, Oct 16, 2022 at 10:25 PM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > With -gstatement-frontiers we may end up with different IR > coming from the front end with and without debug information turned on. > See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100733 for details. > That may result in differences in discriminator values and -fcompare-debug > failures. > > This patch disables printing of discriminators when the dump is intended > for -fcompare-debug comparison and reverses the workaround in a test. I don't think this is the correct approach. -gstatement-frontiers is known to be prone to these issues and is the one to blame here. I think the bugs should be SUSPENDED until -gstatement-frontiers is fixed or at least disabled by default (IIRC Jakub tried that but failed last time) > Tested on x86_64-pc-linux-gnu. > > gcc/ChangeLog: > PR debug/107231 > PR debug/107169 > * print-rtl.cc (print_rtx_operand_code_i): Don't print discriminators > for -fdebug-compare. > > gcc/testsuite/ChangeLog: > > * c-c++-common/ubsan/pr85213.c: Reverse the workaround for discriminators. > --- > gcc/print-rtl.cc | 13 ++++++++++--- > gcc/testsuite/c-c++-common/ubsan/pr85213.c | 7 +------ > 2 files changed, 11 insertions(+), 9 deletions(-) > > diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc > index e115f987173..0476f3d7e79 100644 > --- a/gcc/print-rtl.cc > +++ b/gcc/print-rtl.cc > @@ -453,10 +453,17 @@ rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx, int idx) > expanded_location xloc = insn_location (in_insn); > fprintf (m_outfile, " \"%s\":%i:%i", xloc.file, xloc.line, > xloc.column); > - int discriminator = insn_discriminator (in_insn); > - if (discriminator) > - fprintf (m_outfile, " discrim %d", discriminator); > > + /* Don't print discriminators for -fcompare-debug since the IR > + coming from the front end may be different with and without > + debug information turned on. That may result in different > + discriminator values. */ > + if (!(dump_flags & TDF_COMPARE_DEBUG)) > + { > + int discriminator = insn_discriminator (in_insn); > + if (discriminator) > + fprintf (m_outfile, " discrim %d", discriminator); > + } > } > #endif > } > diff --git a/gcc/testsuite/c-c++-common/ubsan/pr85213.c b/gcc/testsuite/c-c++-common/ubsan/pr85213.c > index e903e976f2c..8a6be81d20f 100644 > --- a/gcc/testsuite/c-c++-common/ubsan/pr85213.c > +++ b/gcc/testsuite/c-c++-common/ubsan/pr85213.c > @@ -1,11 +1,6 @@ > /* PR sanitizer/85213 */ > /* { dg-do compile } */ > -/* Pass -gno-statement-frontiers to work around > - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100733 : > - without it the IR coming from the front end may be different with and without > - debug information turned on. That may cause e.g., different discriminator values > - and -fcompare-debug failures. */ > -/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug -gno-statement-frontiers" } */ > +/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug" } */ > > int > foo (int x) > -- > 2.25.1
Yes, -gstatement-frontiers is the root cause here but the new approach to discriminators is especially prone to this. I added the workaround to pr85213.c in my original discriminator patch but now two more -fcompare-debug bugs were opened (PR107231 and PR107169). I suspect we'll keep getting more. So I'd like to disable printing discriminators in -fcompare-debug dums until -gstatement-frontier issue is fixed. Eugene -----Original Message----- From: Richard Biener <richard.guenther@gmail.com> Sent: Monday, October 17, 2022 12:06 AM To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> Cc: gcc-patches@gcc.gnu.org; Jason Merrill <jason@redhat.com> Subject: [EXTERNAL] Re: [PATCH] Don't print discriminators for -fcompare-debug. On Sun, Oct 16, 2022 at 10:25 PM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > With -gstatement-frontiers we may end up with different IR coming from > the front end with and without debug information turned on. > See https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D100733&data=05%7C01%7CEugene.Rozenfeld%40microsoft.com%7C5d3df88ec7e14f5eec2708dab00e0440%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638015871510301049%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2JjQHAgDi6%2Fet1vowA1IRcdInJMkkjuva9DbM5rHawc%3D&reserved=0 for details. > That may result in differences in discriminator values and > -fcompare-debug failures. > > This patch disables printing of discriminators when the dump is > intended for -fcompare-debug comparison and reverses the workaround in a test. I don't think this is the correct approach. -gstatement-frontiers is known to be prone to these issues and is the one to blame here. I think the bugs should be SUSPENDED until -gstatement-frontiers is fixed or at least disabled by default (IIRC Jakub tried that but failed last time) > Tested on x86_64-pc-linux-gnu. > > gcc/ChangeLog: > PR debug/107231 > PR debug/107169 > * print-rtl.cc (print_rtx_operand_code_i): Don't print discriminators > for -fdebug-compare. > > gcc/testsuite/ChangeLog: > > * c-c++-common/ubsan/pr85213.c: Reverse the workaround for discriminators. > --- > gcc/print-rtl.cc | 13 ++++++++++--- > gcc/testsuite/c-c++-common/ubsan/pr85213.c | 7 +------ > 2 files changed, 11 insertions(+), 9 deletions(-) > > diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc index > e115f987173..0476f3d7e79 100644 > --- a/gcc/print-rtl.cc > +++ b/gcc/print-rtl.cc > @@ -453,10 +453,17 @@ rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx, int idx) > expanded_location xloc = insn_location (in_insn); > fprintf (m_outfile, " \"%s\":%i:%i", xloc.file, xloc.line, > xloc.column); > - int discriminator = insn_discriminator (in_insn); > - if (discriminator) > - fprintf (m_outfile, " discrim %d", discriminator); > > + /* Don't print discriminators for -fcompare-debug since the IR > + coming from the front end may be different with and without > + debug information turned on. That may result in different > + discriminator values. */ > + if (!(dump_flags & TDF_COMPARE_DEBUG)) > + { > + int discriminator = insn_discriminator (in_insn); > + if (discriminator) > + fprintf (m_outfile, " discrim %d", discriminator); > + } > } > #endif > } > diff --git a/gcc/testsuite/c-c++-common/ubsan/pr85213.c > b/gcc/testsuite/c-c++-common/ubsan/pr85213.c > index e903e976f2c..8a6be81d20f 100644 > --- a/gcc/testsuite/c-c++-common/ubsan/pr85213.c > +++ b/gcc/testsuite/c-c++-common/ubsan/pr85213.c > @@ -1,11 +1,6 @@ > /* PR sanitizer/85213 */ > /* { dg-do compile } */ > -/* Pass -gno-statement-frontiers to work around > - https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D100733&data=05%7C01%7CEugene.Rozenfeld%40microsoft.com%7C5d3df88ec7e14f5eec2708dab00e0440%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638015871510301049%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2JjQHAgDi6%2Fet1vowA1IRcdInJMkkjuva9DbM5rHawc%3D&reserved=0 : > - without it the IR coming from the front end may be different with and without > - debug information turned on. That may cause e.g., different discriminator values > - and -fcompare-debug failures. */ > -/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug > -gno-statement-frontiers" } */ > +/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug" } */ > > int > foo (int x) > -- > 2.25.1
diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc index e115f987173..0476f3d7e79 100644 --- a/gcc/print-rtl.cc +++ b/gcc/print-rtl.cc @@ -453,10 +453,17 @@ rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx, int idx) expanded_location xloc = insn_location (in_insn); fprintf (m_outfile, " \"%s\":%i:%i", xloc.file, xloc.line, xloc.column); - int discriminator = insn_discriminator (in_insn); - if (discriminator) - fprintf (m_outfile, " discrim %d", discriminator); + /* Don't print discriminators for -fcompare-debug since the IR + coming from the front end may be different with and without + debug information turned on. That may result in different + discriminator values. */ + if (!(dump_flags & TDF_COMPARE_DEBUG)) + { + int discriminator = insn_discriminator (in_insn); + if (discriminator) + fprintf (m_outfile, " discrim %d", discriminator); + } } #endif } diff --git a/gcc/testsuite/c-c++-common/ubsan/pr85213.c b/gcc/testsuite/c-c++-common/ubsan/pr85213.c index e903e976f2c..8a6be81d20f 100644 --- a/gcc/testsuite/c-c++-common/ubsan/pr85213.c +++ b/gcc/testsuite/c-c++-common/ubsan/pr85213.c @@ -1,11 +1,6 @@ /* PR sanitizer/85213 */ /* { dg-do compile } */ -/* Pass -gno-statement-frontiers to work around - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100733 : - without it the IR coming from the front end may be different with and without - debug information turned on. That may cause e.g., different discriminator values - and -fcompare-debug failures. */ -/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug -gno-statement-frontiers" } */ +/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug" } */ int foo (int x)