]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/116460 - ICE with DCE in forwprop
authorRichard Biener <rguenther@suse.de>
Mon, 26 Aug 2024 11:50:00 +0000 (13:50 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 27 Aug 2024 07:14:30 +0000 (09:14 +0200)
commit172637cf0d9b7b2798f83b9c5f9598b449675cb0
treebcc76340fe829a9651288c3671de56cb9e271db7
parent103127cd9398d140222c9da44715d447641bf791
tree-optimization/116460 - ICE with DCE in forwprop

The following avoids removing stmts with defs that might still have
uses in the IL before calling simple_dce_from_worklist which might
remove those as that will wreck debug stmt generation.  Instead first
perform use-based DCE and then remove stmts which may have uses in
code that CFG cleanup will remove.  This requires tracking stmts
in to_remove by their SSA def so we can check whether it was removed
before without running into the issue that PHIs can be ggc_free()d
upon removal.  So this adds to_remove_defs in addition to to_remove
which has to stay to track GIMPLE_NOPs we want to elide.

PR tree-optimization/116460
* tree-ssa-forwprop.cc (pass_forwprop::execute): First do
simple_dce_from_worklist and then remove stmts in to_remove.
Track defs to be removed in to_remove_defs.

* g++.dg/torture/pr116460.C: New testcase.
gcc/testsuite/g++.dg/torture/pr116460.C [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc