From 6f9ed17a2897be6a26e2c64f8e581771c216e41b Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Wed, 17 Dec 2014 19:11:48 +0100
Subject: [PATCH] Fix for PR64330.
gcc/ChangeLog:
2014-12-17 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.
---
gcc/ipa-icf.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -1131,10 +1131,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);
--
2.1.2