diff options
author | Richard Biener <rguenther@suse.de> | 2020-05-18 08:51:23 +0200 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-17 13:03:36 -0300 |
commit | 804937f5b730ee7c1ec5e32fbfad1f07840076cc (patch) | |
tree | 2fc56a991e30e738ee7a9606a9061e2ec7e1e54d /gcc/tree-inline.c | |
parent | 22ba2a95b21a20b4a8ecd5872d0ea5cf4b9e5818 (diff) | |
download | gcc-804937f5b730ee7c1ec5e32fbfad1f07840076cc.zip gcc-804937f5b730ee7c1ec5e32fbfad1f07840076cc.tar.gz gcc-804937f5b730ee7c1ec5e32fbfad1f07840076cc.tar.bz2 |
middle-end/95171 - inlining of trapping compare into non-call EH fn
This fixes always-inlining across -fnon-call-exception boundaries
for conditions which we do not allow to throw.
2020-05-18 Richard Biener <rguenther@suse.de>
PR middle-end/95171
* tree-inline.c (remap_gimple_stmt): Split out trapping compares
when inlining into a non-call EH function.
* gcc.dg/pr95171.c: New testcase.
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ee96c9c..943f3f9 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1956,6 +1956,37 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id) gimple_set_vuse (copy, NULL_TREE); } + if (cfun->can_throw_non_call_exceptions) + { + /* When inlining a function which does not have non-call exceptions + enabled into a function that has (which only happens with + always-inline) we have to fixup stmts that cannot throw. */ + if (gcond *cond = dyn_cast <gcond *> (copy)) + if (gimple_could_trap_p (cond)) + { + gassign *cmp + = gimple_build_assign (make_ssa_name (boolean_type_node), + gimple_cond_code (cond), + gimple_cond_lhs (cond), + gimple_cond_rhs (cond)); + gimple_seq_add_stmt (&stmts, cmp); + gimple_cond_set_code (cond, NE_EXPR); + gimple_cond_set_lhs (cond, gimple_assign_lhs (cmp)); + gimple_cond_set_rhs (cond, boolean_false_node); + } + if (gassign *ass = dyn_cast <gassign *> (copy)) + if ((gimple_assign_rhs_code (ass) == COND_EXPR + || gimple_assign_rhs_code (ass) == VEC_COND_EXPR) + && gimple_could_trap_p (ass)) + { + gassign *cmp + = gimple_build_assign (make_ssa_name (boolean_type_node), + gimple_assign_rhs1 (ass)); + gimple_seq_add_stmt (&stmts, cmp); + gimple_assign_set_rhs1 (ass, gimple_assign_lhs (cmp)); + } + } + gimple_seq_add_stmt (&stmts, copy); return stmts; } |