From 1980ffec48c6fa41396bea66366f2e591798e1e1 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Thu, 4 Jun 2020 17:03:27 +0200 Subject: ipa-sra: Do not remove statements necessary because of non-call EH (PR 95113) PR 95113 revealed that when reasoning about which parameters are dead, IPA-SRA does not perform the same check related to non-call exceptions as tree DCE. It most certainly should and so this patch moves the condition used in tree-ssa-dce.c into a separate predicate (in tree-eh.c) and uses it from both places. gcc/ChangeLog: 2020-05-27 Martin Jambor PR ipa/95113 * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Move non-call exceptions check to... * tree-eh.c (stmt_unremovable_because_of_non_call_eh_p): ...this new function. * tree-eh.h (stmt_unremovable_because_of_non_call_eh_p): Declare it. * ipa-sra.c (isra_track_scalar_value_uses): Use it. New parameter fun. gcc/testsuite/ChangeLog: 2020-05-27 Martin Jambor PR ipa/95113 * gcc.dg/ipa/pr95113.c: New test. --- gcc/tree-ssa-dce.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'gcc/tree-ssa-dce.c') diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 757cfad..fae5ae7 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -201,9 +201,7 @@ mark_stmt_if_obviously_necessary (gimple *stmt, bool aggressive) { /* With non-call exceptions, we have to assume that all statements could throw. If a statement could throw, it can be deemed necessary. */ - if (cfun->can_throw_non_call_exceptions - && !cfun->can_delete_dead_exceptions - && stmt_could_throw_p (cfun, stmt)) + if (stmt_unremovable_because_of_non_call_eh_p (cfun, stmt)) { mark_stmt_necessary (stmt, true); return; -- cgit v1.1