This is the mail archive of the
mailing list for the GCC project.
Re: [pretty-ipa] Enable IPA nothrow discovery
> > I've merged this to mainline now. Will do the cgraph datastructure
> > changes as suggested in followup.
> This may have caused PR c/39812.
The i386/cleanup-1.c is semi-invalid testcase calling function doing
unwinding from within asm statement. It however excercise real bug in
propagation of throwing flag. The following patch should fix it, I also
added proper cfun sets/gets across can_throw_externally so answer is
right (this does not happen in current code but in general,
cgraph_create_edge is allowed to be called without cfun set
correspondingly to the caller).
I am doing full testing on x86_64-linux and hope it will fix Ada
testcases too and will commit it once testing pass.
* cgraph.c (cgraph_create_edge, cgraph_set_call_stmt): Set proper cfun.
(dump_cgraph_node): Dump can throw external flag.
* ipa-pure-const.c (propagate): Fix propagation of nothrow flags.
--- cgraph.c (revision 146333)
+++ cgraph.c (working copy)
@@ -639,7 +639,9 @@
e->call_stmt = new_stmt;
+ push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl));
e->can_throw_external = stmt_can_throw_external (new_stmt);
+ pop_cfun ();
@@ -774,7 +776,9 @@
edge->caller = caller;
edge->callee = callee;
edge->call_stmt = call_stmt;
+ push_cfun (DECL_STRUCT_FUNCTION (caller->decl));
edge->can_throw_external = stmt_can_throw_external (call_stmt);
+ pop_cfun ();
edge->prev_caller = NULL;
edge->next_caller = callee->callers;
@@ -1409,6 +1413,8 @@
edge->frequency / (double)CGRAPH_FREQ_BASE);
fprintf (f, "(nested in %i loops) ", edge->loop_nest);
+ if (edge->can_throw_external)
+ fprintf(f, "(can throw external) ");
fprintf (f, "\n");
--- ipa-pure-const.c (revision 146333)
+++ ipa-pure-const.c (working copy)
@@ -830,16 +885,19 @@
w = node;
+ funct_state w_l = get_function_state (w);
if (!can_throw && !TREE_NOTHROW (w->decl))
struct cgraph_edge *e;
TREE_NOTHROW (w->decl) = true;
for (e = w->callers; e; e = e->next_caller)
e->can_throw_external = false;
fprintf (dump_file, "Function found to be nothrow: %s\n",
+ else if (can_throw && !TREE_NOTHROW (w->decl))
+ w_l->can_throw = true;
w_info = (struct ipa_dfs_info *) w->aux;
w = w_info->next_cycle;