From patchwork Fri Jun 18 14:48:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: PING: [PATCH, LTO] add externally_visible attribute when necessary with -fwhole-program and resolution file. From: Jan Hubicka X-Patchwork-Id: 56195 Message-Id: <20100618144840.GA18733@kam.mff.cuni.cz> To: Bingfeng Mei Cc: Jan Hubicka , "gcc-patches@gcc.gnu.org" , Richard Guenther Date: Fri, 18 Jun 2010 16:48:40 +0200 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 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