From: Andrew Pinski Date: Sat, 23 Oct 2021 19:24:43 +0000 (+0000) Subject: Fix PR 102908: wrongly removing null pointer loads X-Git-Tag: basepoints/gcc-13~3652 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7518e4c2f0758daac5d650d400565cf49ac3c8c5;p=thirdparty%2Fgcc.git Fix PR 102908: wrongly removing null pointer loads Just like PR 100382, here we have a DCE removing a null pointer load which is needed still. In this case, execute_fixup_cfg removes a store (correctly) and then removes the null load (incorrectly) due to not checking stmt_unremovable_because_of_non_call_eh_p. This patch adds the check in the similar way as the patch to fix PR 100382 did. gcc/ChangeLog: * tree-ssa-dce.c (simple_dce_from_worklist): Check stmt_unremovable_because_of_non_call_eh_p also before removing the statement. --- diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 372e0691ae63..1281e67489c0 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1828,6 +1828,11 @@ simple_dce_from_worklist (bitmap worklist) if (gimple_has_side_effects (t)) continue; + /* Don't remove statements that are needed for non-call + eh to work. */ + if (stmt_unremovable_because_of_non_call_eh_p (cfun, t)) + continue; + /* Add uses to the worklist. */ ssa_op_iter iter; use_operand_p use_p;