Fix optimization options for -fprofile-generate ctors
diff mbox series

Message ID 20191113090726.o2m3m6xit4y2fspu@kam.mff.cuni.cz
State New
Headers show
Series
  • Fix optimization options for -fprofile-generate ctors
Related show

Commit Message

Jan Hubicka Nov. 13, 2019, 9:07 a.m. UTC
Hi,
this patch fixes another ada lto profiledbootstrap issue uncovered by
the summary allocation changes.  -fprofile-generate produces cdtors
after free_lang_data and those gets streamed without optimization/target
option nodes which ends up in the options silently changing from compile
time to link-time eventually triggering ice in ipa-cp due to missing
summary when -O0 -fprofile-genereate unit is built (which is bit
pointless anyway).

Testing this I also noticed another problem with asan as described in
FIXME comment.

Bootstrapped/regtested x86_64-linux, comitted.

	* ipa.c (cgraph_build_static_cdtor): Pass optimization_default_node
	and target_option_default_node to get -fprofile-generate ctors working
	right with LTO.

Patch
diff mbox series

Index: ipa.c
===================================================================
--- ipa.c	(revision 278094)
+++ ipa.c	(working copy)
@@ -914,7 +914,14 @@  cgraph_build_static_cdtor_1 (char which,
 void
 cgraph_build_static_cdtor (char which, tree body, int priority)
 {
-  cgraph_build_static_cdtor_1 (which, body, priority, false, NULL, NULL);
+  /* FIXME: We should be able to
+     gcc_assert (!in_lto_p);
+     because at LTO time the global options are not safe to use.
+     Unfortunately ASAN finish_file will produce constructors late and they
+     may lead to surprises.  */
+  cgraph_build_static_cdtor_1 (which, body, priority, false,
+			       optimization_default_node,
+			       target_option_default_node);
 }
 
 /* When target does not have ctors and dtors, we call all constructor