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
