Patchwork [updated] Make emulated TLS lto-friendly.

login
register
mail settings
Submitter Richard Henderson
Date July 13, 2010, 6:56 p.m.
Message ID <4C3CB6E0.2000000@redhat.com>
Download mbox | patch
Permalink /patch/58807/
State New
Headers show

Comments

Richard Henderson - July 13, 2010, 6:56 p.m.
Test #5, delta from #4.

Moving the generation of the constructor function from the end of
compilation into the IPA pass, while simplifying things generally,
revealed to latent bugs:

(1) The cdtor generator function failed to zero out all the state.
(2) Cgraph failed to run all of the required passes on the new function.


r~

Patch

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index da1f983..0d5e792 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -418,12 +418,17 @@  cgraph_process_new_functions (void)
 	  push_cfun (DECL_STRUCT_FUNCTION (fndecl));
 	  current_function_decl = fndecl;
 	  compute_inline_parameters (node);
-	  if ((cgraph_state == CGRAPH_STATE_IPA_SSA
-	      && !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
-	      /* When not optimizing, be sure we run early local passes anyway
-		 to expand OMP.  */
-	      || !optimize)
+
+	  /* ??? Honza: what's the real difference between IPA and IPA_SSA?
+	     We seem to be assuming that the "real" ipa passes require SSA
+	     but that the "small" ipa passes do not.  This is false.  Any
+	     new function created by a "small" ipa pass *must* have the
+	     early local passes run so that (at least) init_datastructures
+	     gets executed.  Failure to do so results in an immediate crash
+	     once we get to pass_all_optimizations.  */
+	  if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
 	    execute_pass_list (pass_early_local_passes.pass.sub);
+
 	  free_dominance_info (CDI_POST_DOMINATORS);
 	  free_dominance_info (CDI_DOMINATORS);
 	  pop_cfun ();
@@ -2064,7 +2069,9 @@  cgraph_build_static_cdtor (char which, tree body, int priority)
 
   cgraph_add_new_function (decl, false);
   cgraph_mark_needed_node (cgraph_node (decl));
+
   set_cfun (NULL);
+  current_function_decl = NULL;
 }
 
 void