diff options
author | Jan Hubicka <jh@suse.cz> | 2016-04-21 11:05:07 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2016-04-21 09:05:07 +0000 |
commit | a2b056a364e622aac29160bb21fe637d5f6c9519 (patch) | |
tree | dd1fa989c4b9cbacc321b6ccd5f44964b611f58f /gcc/ipa-pure-const.c | |
parent | 9b7924dd177330167865a83f5696a9ae34554972 (diff) | |
download | gcc-a2b056a364e622aac29160bb21fe637d5f6c9519.zip gcc-a2b056a364e622aac29160bb21fe637d5f6c9519.tar.gz gcc-a2b056a364e622aac29160bb21fe637d5f6c9519.tar.bz2 |
re PR c++/70018 (Possible issue around IPO and C++ comdats discovered as pure/const)
PR ipa/70018
* cgraph.c (cgraph_set_nothrow_flag_1): Rename to ...
(set_nothrow_flag_1): ... this; handle interposition correctly;
recurse on aliases and thunks.
(cgraph_node::set_nothrow_flag): New.
* ipa-pure-const.c (ignore_edge_for_nothrow): Ignore calls to
functions compiled with non-call exceptions that binds to current
def.
(propagate_nothrow): Be safe WRT interposition.
* cgraph.h (set_nothrow_flag): Update prototype.
* g++.dg/ipa/nothrow-1.C: New testcase.
From-SVN: r235318
Diffstat (limited to 'gcc/ipa-pure-const.c')
-rw-r--r-- | gcc/ipa-pure-const.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index da8fd4d..7647a58 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1163,7 +1163,10 @@ ignore_edge_for_nothrow (struct cgraph_edge *e) enum availability avail; cgraph_node *n = e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); - return (avail <= AVAIL_INTERPOSABLE || TREE_NOTHROW (n->decl)); + if (avail <= AVAIL_INTERPOSABLE || TREE_NOTHROW (n->decl)) + return true; + return opt_for_fn (e->callee->decl, flag_non_call_exceptions) + && !e->callee->binds_to_current_def_p (e->caller); } /* Return true if NODE is self recursive function. @@ -1589,14 +1592,20 @@ propagate_nothrow (void) continue; struct cgraph_node *y = e->callee-> - function_or_virtual_thunk_symbol (&avail, - e->caller); + function_or_virtual_thunk_symbol (&avail, + e->caller); /* We can use info about the callee only if we know it can - not be interposed. */ + not be interposed. + When callee is compiled with non-call exceptions we also + must check that the declaration is bound to current + body as other semantically equivalent body may still + throw. */ if (avail <= AVAIL_INTERPOSABLE || (!TREE_NOTHROW (y->decl) - && get_function_state (y)->can_throw)) + && (get_function_state (y)->can_throw + || (opt_for_fn (y->decl, flag_non_call_exceptions) + && !e->callee->binds_to_current_def_p (w))))) can_throw = true; } for (ie = w->indirect_calls; ie && !can_throw; |