]> git.ipfire.org Git - thirdparty/gcc.git/commit
Widening-Mul: Fix one ICE when iterate on phi node
authorPan Li <pan2.li@intel.com>
Fri, 27 Sep 2024 03:03:51 +0000 (11:03 +0800)
committerPan Li <pan2.li@intel.com>
Fri, 27 Sep 2024 13:57:22 +0000 (21:57 +0800)
commitcd430b1fd95dce5868ce6a8063119d253ea2f995
tree10de3d30bddc4da01dde277f1a9a635a35fc4489
parent9085cc2a34f1c851e16c497bd9b0e4fd38b08142
Widening-Mul: Fix one ICE when iterate on phi node

We iterate all phi node of bb to try to match the SAT_* pattern
for scalar integer.  We also remove the phi mode when the relevant
pattern matched.

Unfortunately the iterator may have no idea the phi node is removed
and continue leverage the free data and then ICE similar as below.

[0] psi ptr 0x75216340c000
[0] psi ptr 0x75216340c400
[1] psi ptr 0xa5a5a5a5a5a5a5a5 <=== GC freed pointer.

during GIMPLE pass: widening_mul
tmp.c: In function â€˜f’:
tmp.c:45:6: internal compiler error: Segmentation fault
   45 | void f(int rows, int cols) {
      |      ^
0x36e2788 internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0x18005f0 crash_signal
        ../../gcc/toplev.cc:321
0x752163c4531f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x103ae0e bool is_a_helper<gphi*>::test<gimple>(gimple*)
../../gcc/gimple.h:1256
0x103f9a5 bool is_a<gphi*, gimple>(gimple*)
        ../../gcc/is-a.h:232
0x103dc78 gphi* as_a<gphi*, gimple>(gimple*)
../../gcc/is-a.h:255
0x104f12e gphi_iterator::phi() const
        ../../gcc/gimple-iterator.h:47
0x1a57bef after_dom_children
        ../../gcc/tree-ssa-math-opts.cc:6140
0x3344482 dom_walker::walk(basic_block_def*)
        ../../gcc/domwalk.cc:354
0x1a58601 execute
        ../../gcc/tree-ssa-math-opts.cc:6312

This patch would like to fix the iterate on modified collection problem
by backup the next phi in advance.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

PR middle-end/116861

gcc/ChangeLog:

* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Backup
the next psi iterator before remove the phi node.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116861-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/testsuite/gcc.dg/torture/pr116861-1.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.cc