From: Jakub Jelinek Date: Mon, 3 May 2021 10:03:02 +0000 (+0200) Subject: tree-ssa-dse: Fix up go.test/test/fixedbugs/issue16095.go miscompilation [PR100382] X-Git-Tag: basepoints/gcc-13~7935 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80bbb7ff83d81544b09820428bdd7db9f50fe362;p=thirdparty%2Fgcc.git tree-ssa-dse: Fix up go.test/test/fixedbugs/issue16095.go miscompilation [PR100382] The new DCE code inside of tree DSE removes in -fnon-call-exceptions go code a load from NULL pointer the testcase relies on throwing an exception and so the test hangs. The following patch just repeats a check that e.g. tree-ssa-dce.c uses to prevent this. 2021-05-03 Jakub Jelinek PR tree-optimization/100382 * tree-ssa-dse.c: Include tree-eh.h. (dse_dom_walker::before_dom_children): Don't remove stmts if stmt_unremovable_because_of_non_call_eh_p is true. --- diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index aecf6ab8c46c..76929fa03c7a 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "gimple-fold.h" #include "gimplify.h" +#include "tree-eh.h" /* This file implements dead store elimination. @@ -1193,7 +1194,8 @@ dse_dom_walker::before_dom_children (basic_block bb) /* When we remove dead stores make sure to also delete trivially dead SSA defs. */ if (has_zero_uses (DEF_FROM_PTR (def_p)) - && !gimple_has_side_effects (stmt)) + && !gimple_has_side_effects (stmt) + && !stmt_unremovable_because_of_non_call_eh_p (cfun, stmt)) { if (dump_file && (dump_flags & TDF_DETAILS)) {