This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.
Index: cgraph.c
===================================================================
--- cgraph.c	(revision 146333)
+++ cgraph.c	(working copy)
@@ -639,7 +639,9 @@
 				 htab_hash_pointer (e->call_stmt));
     }
   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 ();
   if (e->caller->call_site_hash)
     {
       void **slot;
@@ -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;
   if (callee->callers)
@@ -1409,6 +1413,8 @@
 		 edge->frequency / (double)CGRAPH_FREQ_BASE);
       if (edge->loop_nest)
 	fprintf (f, "(nested in %i loops) ", edge->loop_nest);
+      if (edge->can_throw_external)
+	fprintf(f, "(can throw external) ");
     }
   fprintf (f, "\n");
 }
Index: ipa-pure-const.c
===================================================================
--- ipa-pure-const.c	(revision 146333)
+++ ipa-pure-const.c	(working copy)
@@ -830,16 +885,19 @@
       w = node;
       while (w)
 	{
+	  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;
 	      if (dump_file)
 		fprintf (dump_file, "Function found to be nothrow: %s\n",  
 			 cgraph_node_name (w));
 	    }
+	  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;
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]