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]

Fix optimization options for -fprofile-generate ctors


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.

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


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