aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2014-12-18 14:32:18 +0100
committerMartin Liska <marxin@gcc.gnu.org>2014-12-18 13:32:18 +0000
commit09cb9532c4c56979b1d9b105e5608ba22b66c5ac (patch)
tree952f9315fd36a116ea1d1690fd78c402efe9005d
parent2ddeb89bf572908b3c5432f86c87fde80b58586b (diff)
downloadgcc-09cb9532c4c56979b1d9b105e5608ba22b66c5ac.zip
gcc-09cb9532c4c56979b1d9b105e5608ba22b66c5ac.tar.gz
gcc-09cb9532c4c56979b1d9b105e5608ba22b66c5ac.tar.bz2
re PR tree-optimization/64330 (IPA-ICF merges const exported vars that could be addressable in other TUs)
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
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/ipa-icf.c10
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7b85cbc..1bb6944 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 91878b2..244edaa 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -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);