aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2015-12-23 14:47:39 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-12-23 14:47:39 +0000
commit7ec4f3438cd3fc7a83a32d6c9b910b26a220376e (patch)
tree23ff2500b938c7cf94d14dd55668e27574e466b8 /gcc
parent986e29bc6a3df0269268d7045058049beb26e1cb (diff)
downloadgcc-7ec4f3438cd3fc7a83a32d6c9b910b26a220376e.zip
gcc-7ec4f3438cd3fc7a83a32d6c9b910b26a220376e.tar.gz
gcc-7ec4f3438cd3fc7a83a32d6c9b910b26a220376e.tar.bz2
alias.c (compare_base_decls): Simplify in-symtab check.
gcc/ * alias.c (compare_base_decls): Simplify in-symtab check. * cgraph.h (decl_in_symtab_p): Check DECL_IN_CONSTANT_POOL. testsuite/ * gcc.dg/alias-15.c: New. From-SVN: r231928
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/alias.c7
-rw-r--r--gcc/cgraph.h8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/alias-15.c15
5 files changed, 34 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d01894a..e789c11 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-23 Nathan Sidwell <nathan@acm.org>
+
+ * alias.c (compare_base_decls): Simplify in-symtab check.
+ * cgraph.h (decl_in_symtab_p): Check DECL_IN_CONSTANT_POOL.
+
2015-12-23 Dominik Vogt <vogt@linux.vnet.ibm.com>
* config/s390/predicates.md ("larl_operand"): Remove now superfluous
diff --git a/gcc/alias.c b/gcc/alias.c
index 1ab9600..42a974a 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2038,13 +2038,12 @@ compare_base_decls (tree base1, tree base2)
if (base1 == base2)
return 1;
- bool in_symtab1 = decl_in_symtab_p (base1);
- bool in_symtab2 = decl_in_symtab_p (base2);
-
/* Declarations of non-automatic variables may have aliases. All other
decls are unique. */
- if (in_symtab1 != in_symtab2 || !in_symtab1)
+ if (!decl_in_symtab_p (base1)
+ || !decl_in_symtab_p (base2))
return 0;
+
ret = symtab_node::get_create (base1)->equal_address_to
(symtab_node::get_create (base2), true);
if (ret == 2)
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index ba14215..fe7c194 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -2294,13 +2294,19 @@ symtab_node::real_symbol_p (void)
}
/* Return true if DECL should have entry in symbol table if used.
- Those are functions and static & external veriables*/
+ Those are functions and static & external non-constpool variables.
+ We do not expect constant pool variables in the varpool, as they're
+ not related to other variables, and simply lazily inserting them
+ using the regular interface results in varpool thinking they are
+ externally provided -- which results in erroneous assembly emission
+ as an undefined decl. */
static inline bool
decl_in_symtab_p (const_tree decl)
{
return (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == VAR_DECL
+ && !DECL_IN_CONSTANT_POOL (decl)
&& (TREE_STATIC (decl) || DECL_EXTERNAL (decl))));
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1924c24..79a1827 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-23 Nathan Sidwell <nathan@acm.org>
+
+ * gcc.dg/alias-15.c: New.
+
2015-12-23 Thomas Schwinge <thomas@codesourcery.com>
* g++.dg/dg.exp (tests): Prune "goacc/*" and "goacc-gomp/*" files.
diff --git a/gcc/testsuite/gcc.dg/alias-15.c b/gcc/testsuite/gcc.dg/alias-15.c
new file mode 100644
index 0000000..0a8e69b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/alias-15.c
@@ -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" } } */