This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix optimization options for -fprofile-generate ctors
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 Nov 2019 10:07:26 +0100
- Subject: 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