aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-11-17 18:09:13 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2016-11-17 18:09:13 +0100
commit5fe353c893256a75c057a49af66fc4838fe82d7d (patch)
treed7ff133f39787e3034fdff6f690b143432da0ba3 /gcc
parent86a21121ace5a75de9d57b4b9bd691388e0367bc (diff)
downloadgcc-5fe353c893256a75c057a49af66fc4838fe82d7d.zip
gcc-5fe353c893256a75c057a49af66fc4838fe82d7d.tar.gz
gcc-5fe353c893256a75c057a49af66fc4838fe82d7d.tar.bz2
re PR middle-end/78201 (ICE in tree_to_shwi, at tree.h:4037 (seen both on ARM32 an AArch64))
PR middle-end/78201 * varasm.c (default_use_anchors_for_symbol_p): Fix a comment typo. Don't test decl != NULL. Don't look at DECL_SIZE, but DECL_SIZE_UNIT instead, return false if it is NULL, or doesn't fit into uhwi, or is larger or equal to targetm.max_anchor_offset. * g++.dg/opt/pr78201.C: New test. From-SVN: r242555
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/opt/pr78201.C13
-rw-r--r--gcc/varasm.c9
4 files changed, 31 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bc2b86c..0967e8d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-11-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/78201
+ * varasm.c (default_use_anchors_for_symbol_p): Fix a comment typo.
+ Don't test decl != NULL. Don't look at DECL_SIZE, but DECL_SIZE_UNIT
+ instead, return false if it is NULL, or doesn't fit into uhwi, or
+ is larger or equal to targetm.max_anchor_offset.
+
2016-11-17 Pip Cet <pipcet@gmail.com>
Eric Botcazou <ebotcazou@adacore.com>
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dc7ab84..cce390b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/78201
+ * g++.dg/opt/pr78201.C: New test.
+
2016-11-17 Christophe Lyon <christophe.lyon@linaro.org>
* gcc.dg/pr78333.c: Add empty implementations of
diff --git a/gcc/testsuite/g++.dg/opt/pr78201.C b/gcc/testsuite/g++.dg/opt/pr78201.C
new file mode 100644
index 0000000..82567bc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr78201.C
@@ -0,0 +1,13 @@
+// PR middle-end/78201
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct B { long d (); } *c;
+long e;
+
+void
+foo ()
+{
+ char a[e] = "";
+ c && c->d();
+}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6a7ffc2..1c711b1 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6804,11 +6804,12 @@ default_use_anchors_for_symbol_p (const_rtx symbol)
return false;
/* Don't use section anchors for decls that won't fit inside a single
- anchor range to reduce the amount of instructions require to refer
+ anchor range to reduce the amount of instructions required to refer
to the entire declaration. */
- if (decl && DECL_SIZE (decl)
- && tree_to_shwi (DECL_SIZE (decl))
- >= (targetm.max_anchor_offset * BITS_PER_UNIT))
+ if (DECL_SIZE_UNIT (decl) == NULL_TREE
+ || !tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))
+ || (tree_to_uhwi (DECL_SIZE_UNIT (decl))
+ >= (unsigned HOST_WIDE_INT) targetm.max_anchor_offset))
return false;
}