My patch to stop constant pool objects accidentally ending up in the varpool
caused problems with (at least) powerpc.
(https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02100.html) Hence reverted.
This patch changes compare_base_decls to simply use the varpool getter, rather
than get_create. We still need the preceding decl_in_symtab_p to filter out
decls that should never be in the varpool (the getter has an assert to check
you're not trying to abuse it).
ok?
nathan
2016-01-04 Nathan Sidwell <nat...@acm.org>
gcc/
* alias.c (compare_base_decls): Use symtab_node::get.
gcc/testsuite/
* gcc.dg/alias-15.c: New.
Index: alias.c
===================================================================
--- alias.c (revision 232057)
+++ alias.c (working copy)
@@ -2044,8 +2044,15 @@ compare_base_decls (tree base1, tree bas
|| !decl_in_symtab_p (base2))
return 0;
- ret = symtab_node::get_create (base1)->equal_address_to
- (symtab_node::get_create (base2), true);
+ /* Don't cause symbols to be inserted by the act of checking. */
+ symtab_node *node1 = symtab_node::get (base1);
+ if (!node1)
+ return 0;
+ symtab_node *node2 = symtab_node::get (base2);
+ if (!node2)
+ return 0;
+
+ ret = node1->equal_address_to (node2, true);
if (ret == 2)
return -1;
return ret;
Index: testsuite/gcc.dg/alias-15.c
===================================================================
--- testsuite/gcc.dg/alias-15.c (revision 0)
+++ testsuite/gcc.dg/alias-15.c (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -fdump-ipa-cgraph" } */
+
+/* RTL-level CSE shouldn't introduce LCO (for the string) into varpool */
+char *p;
+
+void foo ()
+{
+ p = "abc\n";
+
+ while (*p != '\n')
+ p++;
+}
+
+/* { dg-final { scan-ipa-dump-not "LC0" "cgraph" } } */