* [PATCH] Don't print discriminators for -fcompare-debug.
@ 2022-10-16 20:24 Eugene Rozenfeld
2022-10-17 7:05 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Eugene Rozenfeld @ 2022-10-16 20:24 UTC (permalink / raw)
To: gcc-patches, Jason Merrill
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(-)
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Don't print discriminators for -fcompare-debug.
2022-10-16 20:24 [PATCH] Don't print discriminators for -fcompare-debug Eugene Rozenfeld
@ 2022-10-17 7:05 ` Richard Biener
2022-10-17 14:49 ` [EXTERNAL] " Eugene Rozenfeld
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2022-10-17 7:05 UTC (permalink / raw)
To: Eugene Rozenfeld; +Cc: gcc-patches, Jason Merrill
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [EXTERNAL] Re: [PATCH] Don't print discriminators for -fcompare-debug.
2022-10-17 7:05 ` Richard Biener
@ 2022-10-17 14:49 ` Eugene Rozenfeld
0 siblings, 0 replies; 3+ messages in thread
From: Eugene Rozenfeld @ 2022-10-17 14:49 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, Jason Merrill
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-17 14:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 20:24 [PATCH] Don't print discriminators for -fcompare-debug Eugene Rozenfeld
2022-10-17 7:05 ` Richard Biener
2022-10-17 14:49 ` [EXTERNAL] " Eugene Rozenfeld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).