https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96565

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, well - but the fix exposes (IIRC I ran into this at some time in the past
already) that GIMPLE_RESX does not have virtual operands but it needs to
represent a use of global memory at least in the case it exits the current
function.  So with the fix which is simply

diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index cc93f559286..6b2f64c0250 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -888,11 +888,16 @@ dse_classify_store (ao_ref *ref, gimple *stmt,
          gimple *def = defs[i];
          gimple *use_stmt;
          use_operand_p use_p;
+         /* If the path ends here we do not need to process it further.
+            This for example happens with calls to noreturn functions.  */
+         if (gimple_code (def) != GIMPLE_PHI
+             && has_zero_uses (gimple_vdef (def)))
+           defs.unordered_remove (i);
          /* If the path to check starts with a kill we do not need to
             process it further.
             ???  With byte tracking we need only kill the bytes currently
             live.  */
-         if (stmt_kills_ref_p (def, ref))
+         else if (stmt_kills_ref_p (def, ref))
            {
              if (by_clobber_p && !gimple_clobber_p (def))
                *by_clobber_p = false;

I see

FAIL: g++.dg/eh/spec7.C  -std=gnu++98 execution test
FAIL: g++.dg/eh/spec7.C  -std=gnu++14 execution test
FAIL: g++.dg/eh/spec7.C  -std=gnu++17 execution test
FAIL: g++.dg/eh/spec7.C  -std=gnu++2a execution test
FAIL: gcc.target/i386/cleanup-1.c execution test
FAIL: gcc.target/i386/cleanup-2.c execution test

also (a testsuite issue)

FAIL: gcc.dg/builtin-object-size-4.c execution test

the RESX issue is possibly latent even without the above patch.

Reply via email to