re PR target/79041 (aarch64 backend emits R_AARCH64_ADR_PREL_PG_HI21 relocation despi...
authorWilco Dijkstra <wdijkstr@arm.com>
Mon, 24 Jul 2017 18:06:37 +0000 (18:06 +0000)
committerWilco Dijkstra <wilco@gcc.gnu.org>
Mon, 24 Jul 2017 18:06:37 +0000 (18:06 +0000)
Fix PR79041

As described in PR79041, -mcmodel=large -mpc-relative-literal-loads
may be used to avoid generating ADRP/ADD or ADRP/LDR.  However both
trunk and GCC7 may still emit ADRP for some constant pool literals.
Fix this by adding a aarch64_pcrelative_literal_loads check.

gcc/
PR target/79041
* config/aarch64/aarch64.c (aarch64_classify_symbol):
Avoid SYMBOL_SMALL_ABSOLUTE for literals with pc-relative literals
gcc/testsuite/
* gcc.target/aarch64/pr79041-2.c: New test.

From-SVN: r250478

gcc/ChangeLog
gcc/config/aarch64/aarch64.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/pr79041-2.c [new file with mode: 0644]

index c77ba24254c186175a41663e7e0533d0e6ac919a..e929c4d50d94bf1b25907ddf8958ffc4a791269c 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-24  Wilco Dijkstra  <wdijkstr@arm.com>
+
+       PR target/79041
+       * config/aarch64/aarch64.c (aarch64_classify_symbol):
+       Avoid SYMBOL_SMALL_ABSOLUTE for literals with pc-relative literals.
+
 2017-07-24  Carl Love  <cel@us.ibm.com>
 
        * config/rs6000/rs6000-c.c: Add support for built-in functions
index b8a4160d9de8e689ccd26cb9f0ce046ee65e0ef4..d753666ef67fc524260c41f36743df3649a0a98a 100644 (file)
@@ -10193,7 +10193,7 @@ aarch64_classify_symbol (rtx x, rtx offset)
          /* This is alright even in PIC code as the constant
             pool reference is always PC relative and within
             the same translation unit.  */
-         if (CONSTANT_POOL_ADDRESS_P (x))
+         if (!aarch64_pcrelative_literal_loads && CONSTANT_POOL_ADDRESS_P (x))
            return SYMBOL_SMALL_ABSOLUTE;
          else
            return SYMBOL_FORCE_TO_MEM;
index bb4302f0541af27a7f453cbb7d72aeff8c5bd18b..de46deffdcfb30ff6660594002799eef723bc111 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-24  Wilco Dijkstra  <wdijkstr@arm.com>
+
+       PR target/79041
+       * gcc.target/aarch64/pr79041-2.c: New test.
+
 2017-07-24  Carl Love  <cel@us.ibm.com>
 
        * gcc.target/powerpc/builtins-3-p9-runnable.c: Add new test file for
diff --git a/gcc/testsuite/gcc.target/aarch64/pr79041-2.c b/gcc/testsuite/gcc.target/aarch64/pr79041-2.c
new file mode 100644 (file)
index 0000000..e789972
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcmodel=large -mpc-relative-literal-loads" } */
+
+__int128
+t (void)
+{
+  return (__int128)1 << 80;
+}
+
+/* { dg-final { scan-assembler "adr" } } */