re PR tree-optimization/64330 (IPA-ICF merges const exported vars that could be addre...
authorMartin Liska <mliska@suse.cz>
Thu, 18 Dec 2014 13:32:18 +0000 (14:32 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 18 Dec 2014 13:32:18 +0000 (13:32 +0000)
Fix for PR64330.

PR tree-optimization/64330
* ipa-icf.c (sem_variable::parse): Add checking
for externally visible symbols and do not introduce
an alias for an external declaration.

From-SVN: r218864

gcc/ChangeLog
gcc/ipa-icf.c

index 7b85cbc751b4510b44bb406493b4730d164edac3..1bb694447174d790c0f0c628c448d9c68c10eb0f 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-18  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/64330
+       * ipa-icf.c (sem_variable::parse): Add checking
+       for externally visible symbols and do not introduce
+       an alias for an external declaration.
+
 2014-12-18  Jan Hubicka  <hubicka@ucw.cz>
 
        PR bootstrap/63573
index 91878b2d3fce738aac550f81ffddf1eb604928e8..244edaa1bc4b784221ab3f88b62be60c92daa6bc 100644 (file)
@@ -1139,10 +1139,14 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack)
   tree decl = node->decl;
 
   bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl);
-  bool can_handle = readonly && (DECL_VIRTUAL_P (decl)
-                                || !TREE_ADDRESSABLE (decl));
+  if (!readonly)
+    return NULL;
+
+  bool can_handle = DECL_VIRTUAL_P (decl)
+                   || flag_merge_constants >= 2
+                   || (!TREE_ADDRESSABLE (decl) && !node->externally_visible);
 
-  if (!can_handle)
+  if (!can_handle || DECL_EXTERNAL (decl))
     return NULL;
 
   tree ctor = ctor_for_folding (decl);