PING: [PATCH, LTO] add externally_visible attribute when necessary with -fwhole-program and resolution file.

Jan Hubicka hubicka@ucw.cz
Fri Jun 18 16:46:00 GMT 2010


Index: ipa.c
===================================================================
--- ipa.c	(revision 160529)
+++ ipa.c	(working copy)
@@ -665,13 +665,12 @@
 	}
       gcc_assert ((!DECL_WEAK (node->decl) && !DECL_COMDAT (node->decl))
       	          || TREE_PUBLIC (node->decl) || DECL_EXTERNAL (node->decl));
-      if (cgraph_externally_visible_p (node, whole_program))
+      if (!node->local.externally_visible
+          && cgraph_externally_visible_p (node, whole_program))
         {
 	  gcc_assert (!node->global.inlined_to);
 	  node->local.externally_visible = true;
 	}
-      else
-	node->local.externally_visible = false;

This is not correct: the externally visible attribute is computed twice; once
in pass_ipa_function_and_variable_visibility and second time in
pass_ipa_whole_program_visibility.

This is so to allow output from early IPA passes and early local optimization
to be used by both at the compile time and link time.  So variables/functions
are externally visible per their visiblities first and then in
pass_ipa_whole_program_visibility they might become static.

This is why the conditional sets externally_visible to false.  Not doing so you
effectively disbale -fwhole-program.

We might get around by not streaming externally_visible flag and not clearling
it when in LTO mode (since it would not be set for other reasons) but this is
bit fragile.

We already have flag used_from_other_partition, this situation is similar, just
it is not used from other partition but externally.  Perhaps we can just add specific
flag for this purpose and update cgraph_externally_visible_p to test for it?

Honza



More information about the Gcc-patches mailing list