* [PATCH] emit-rtl: Fix -fcompare-debug bug with label references in debug insns [PR105203]
@ 2022-04-20 16:50 Jakub Jelinek
2022-04-20 18:54 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2022-04-20 16:50 UTC (permalink / raw)
To: Richard Biener, Jeff Law; +Cc: gcc-patches
Hi!
When we compute LABEL_NUSES from scratch, mark_all_labels doesn't call
mark_jump_label on DEBUG_INSNs:
if (NONDEBUG_INSN_P (insn))
mark_jump_label (PATTERN (insn), insn, 0);
and so doesn't increment LABEL_NUSES from references in DEBUG_INSNs.
But, when we call emit_copy_of_insn_after e.g. when duplicating some
DEBUG_INSNs, we call it even on those, which then results in LABEL_NUSES
differences and -fcompare-debug failures.
The following patch makes sure we don't call it on DEBUG_INSNs.
Bootstrapped/regtested on powerpc64le-linux, ok for trunk?
2022-04-20 Jakub Jelinek <jakub@redhat.com>
PR debug/105203
* emit-rtl.cc (emit_copy_of_insn_after): Don't call mark_jump_label
on DEBUG_INSNs.
* gfortran.dg/g77/pr105203.f: New test.
--- gcc/emit-rtl.cc.jj 2022-02-23 09:17:04.805125253 +0100
+++ gcc/emit-rtl.cc 2022-04-20 10:26:44.972198107 +0200
@@ -6440,7 +6440,8 @@ emit_copy_of_insn_after (rtx_insn *insn,
}
/* Update LABEL_NUSES. */
- mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
+ if (NONDEBUG_INSN_P (insn))
+ mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
INSN_LOCATION (new_rtx) = INSN_LOCATION (insn);
--- gcc/testsuite/gfortran.dg/g77/pr105203.f.jj 2022-04-20 10:29:44.830696254 +0200
+++ gcc/testsuite/gfortran.dg/g77/pr105203.f 2022-04-20 10:31:13.532463772 +0200
@@ -0,0 +1,20 @@
+C Test case for PR debug/105203
+C Origin: kmccarty@princeton.edu
+C
+C { dg-do compile }
+C { dg-options "-O2 -fcompare-debug -ftracer -w" }
+C { dg-additional-options "-fPIC" { target fpic } }
+ SUBROUTINE FOO (B)
+
+ 10 CALL BAR (A)
+ ASSIGN 20 TO M
+ IF (100.LT.A) GOTO 10
+ GOTO 40
+C
+ 20 IF (B.LT.ABS(A)) GOTO 10
+ ASSIGN 30 TO M
+ GOTO 40
+C
+ 30 ASSIGN 10 TO M
+ 40 GOTO M,(10,20,30)
+ END
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] emit-rtl: Fix -fcompare-debug bug with label references in debug insns [PR105203]
2022-04-20 16:50 [PATCH] emit-rtl: Fix -fcompare-debug bug with label references in debug insns [PR105203] Jakub Jelinek
@ 2022-04-20 18:54 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-04-20 18:54 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jeff Law, gcc-patches
> Am 20.04.2022 um 18:52 schrieb Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>:
>
> Hi!
>
> When we compute LABEL_NUSES from scratch, mark_all_labels doesn't call
> mark_jump_label on DEBUG_INSNs:
> if (NONDEBUG_INSN_P (insn))
> mark_jump_label (PATTERN (insn), insn, 0);
> and so doesn't increment LABEL_NUSES from references in DEBUG_INSNs.
> But, when we call emit_copy_of_insn_after e.g. when duplicating some
> DEBUG_INSNs, we call it even on those, which then results in LABEL_NUSES
> differences and -fcompare-debug failures.
>
> The following patch makes sure we don't call it on DEBUG_INSNs.
>
> Bootstrapped/regtested on powerpc64le-linux, ok for trunk?
Ok
Richard
>
> 2022-04-20 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/105203
> * emit-rtl.cc (emit_copy_of_insn_after): Don't call mark_jump_label
> on DEBUG_INSNs.
>
> * gfortran.dg/g77/pr105203.f: New test.
>
> --- gcc/emit-rtl.cc.jj 2022-02-23 09:17:04.805125253 +0100
> +++ gcc/emit-rtl.cc 2022-04-20 10:26:44.972198107 +0200
> @@ -6440,7 +6440,8 @@ emit_copy_of_insn_after (rtx_insn *insn,
> }
>
> /* Update LABEL_NUSES. */
> - mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
> + if (NONDEBUG_INSN_P (insn))
> + mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
>
> INSN_LOCATION (new_rtx) = INSN_LOCATION (insn);
>
> --- gcc/testsuite/gfortran.dg/g77/pr105203.f.jj 2022-04-20 10:29:44.830696254 +0200
> +++ gcc/testsuite/gfortran.dg/g77/pr105203.f 2022-04-20 10:31:13.532463772 +0200
> @@ -0,0 +1,20 @@
> +C Test case for PR debug/105203
> +C Origin: kmccarty@princeton.edu
> +C
> +C { dg-do compile }
> +C { dg-options "-O2 -fcompare-debug -ftracer -w" }
> +C { dg-additional-options "-fPIC" { target fpic } }
> + SUBROUTINE FOO (B)
> +
> + 10 CALL BAR (A)
> + ASSIGN 20 TO M
> + IF (100.LT.A) GOTO 10
> + GOTO 40
> +C
> + 20 IF (B.LT.ABS(A)) GOTO 10
> + ASSIGN 30 TO M
> + GOTO 40
> +C
> + 30 ASSIGN 10 TO M
> + 40 GOTO M,(10,20,30)
> + END
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-20 18:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 16:50 [PATCH] emit-rtl: Fix -fcompare-debug bug with label references in debug insns [PR105203] Jakub Jelinek
2022-04-20 18:54 ` Richard Biener
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).