* [PATCH] PR rtl-optimization/106421: ICE in bypass_block from non-local goto.
@ 2023-01-09 19:49 Roger Sayle
2023-01-10 10:07 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Roger Sayle @ 2023-01-09 19:49 UTC (permalink / raw)
To: 'GCC Patches'
[-- Attachment #1: Type: text/plain, Size: 714 bytes --]
This patch fixes PR rtl-optimization/106421, an ICE-on-valid (but
undefined) regression. The fix, as proposed by Richard Biener, is to
defend against BLOCK_FOR_INSN returning NULL in cprop's bypass_block.
This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
and make -k check, both with and without --target_board=unix{-m32},
with no new failures. Ok for mainline?
2023-01-09 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR rtl-optimization/106421
* cprop.cc (bypass_block): Check that DEST is local to this
function (non-NULL) before calling find_edge.
gcc/testsuite/ChangeLog
PR rtl-optimization/106421
* gcc.dg/pr106421.c: New test case.
Thanks in advance,
Roger
--
[-- Attachment #2: patchbb.txt --]
[-- Type: text/plain, Size: 999 bytes --]
diff --git a/gcc/cprop.cc b/gcc/cprop.cc
index 5b203ec..6ec0bda 100644
--- a/gcc/cprop.cc
+++ b/gcc/cprop.cc
@@ -1622,9 +1622,12 @@ bypass_block (basic_block bb, rtx_insn *setcc, rtx_insn *jump)
{
dest = BLOCK_FOR_INSN (XEXP (new_rtx, 0));
/* Don't bypass edges containing instructions. */
- edest = find_edge (bb, dest);
- if (edest && edest->insns.r)
- dest = NULL;
+ if (dest)
+ {
+ edest = find_edge (bb, dest);
+ if (edest && edest->insns.r)
+ dest = NULL;
+ }
}
else
dest = NULL;
diff --git a/gcc/testsuite/gcc.dg/pr106421.c b/gcc/testsuite/gcc.dg/pr106421.c
new file mode 100644
index 0000000..73e522a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106421.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int main(int argc, char **argv)
+{
+ __label__ loop, end;
+ void jmp(int c) { goto *(c ? &&loop : &&end); }
+loop:
+ jmp(argc < 0);
+end:
+ return 0;
+}
+
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR rtl-optimization/106421: ICE in bypass_block from non-local goto.
2023-01-09 19:49 [PATCH] PR rtl-optimization/106421: ICE in bypass_block from non-local goto Roger Sayle
@ 2023-01-10 10:07 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-01-10 10:07 UTC (permalink / raw)
To: Roger Sayle; +Cc: GCC Patches
On Mon, Jan 9, 2023 at 8:50 PM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> This patch fixes PR rtl-optimization/106421, an ICE-on-valid (but
> undefined) regression. The fix, as proposed by Richard Biener, is to
> defend against BLOCK_FOR_INSN returning NULL in cprop's bypass_block.
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check, both with and without --target_board=unix{-m32},
> with no new failures. Ok for mainline?
OK.
>
> 2023-01-09 Roger Sayle <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> PR rtl-optimization/106421
> * cprop.cc (bypass_block): Check that DEST is local to this
> function (non-NULL) before calling find_edge.
>
> gcc/testsuite/ChangeLog
> PR rtl-optimization/106421
> * gcc.dg/pr106421.c: New test case.
>
>
> Thanks in advance,
> Roger
> --
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-10 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 19:49 [PATCH] PR rtl-optimization/106421: ICE in bypass_block from non-local goto Roger Sayle
2023-01-10 10:07 ` 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).