[ARC] Use TARGET_USE_ANCHORS_FOR_SYMBOL_P.
authorClaudiu Zissulescu <claziss@synopsys.com>
Fri, 1 Sep 2017 11:43:17 +0000 (13:43 +0200)
committerClaudiu Zissulescu <claziss@gcc.gnu.org>
Fri, 1 Sep 2017 11:43:17 +0000 (13:43 +0200)
We don't want to use anchors for small data: the GP register acts as an anchor in that
case.  We also don't want to use them for PC-relative accesses,
where the PC acts as an anchor.  TLS symbols require special accesses as well, don't use
anchors for such symbols.

gcc/
2017-04-28  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc.c (arc_use_anchors_for_symbol_p): New function.
(TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define.

gcc/testsuite
2017-04-28  Claudiu Zissulescu  <claziss@synopsys.com>

* gcc.target/arc/pr9001184797.c: New test.

From-SVN: r251586

gcc/ChangeLog
gcc/config/arc/arc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arc/pr9001184797.c [new file with mode: 0644]

index 288c2a0bc07218838ea6446293650c34676c3439..70e5aedaca5ad75dcae06027085e5bda8047f9ce 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-01  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * config/arc/arc.c (arc_use_anchors_for_symbol_p): New function.
+       (TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define.
+
 2017-08-31  Olivier Hainque  <hainque@adacore.com>
 
        * config.gcc (powerpc-wrs-vxworks|vxworksae|vxworksmils): Now
index bc73a591fa479042e28067d5dad22ca94a3d09a0..5410d6b8788f55c65f61662c6161983f0ebc8110 100644 (file)
@@ -10566,6 +10566,30 @@ compact_memory_operand_p (rtx op, machine_mode mode,
   return false;
 }
 
+/* Implement TARGET_USE_ANCHORS_FOR_SYMBOL_P.  We don't want to use
+   anchors for small data: the GP register acts as an anchor in that
+   case.  We also don't want to use them for PC-relative accesses,
+   where the PC acts as an anchor.  Prohibit also TLS symbols to use
+   anchors.  */
+
+static bool
+arc_use_anchors_for_symbol_p (const_rtx symbol)
+{
+  if (SYMBOL_REF_TLS_MODEL (symbol))
+    return false;
+
+  if (flag_pic)
+    return false;
+
+  if (SYMBOL_REF_SMALL_P (symbol))
+    return false;
+
+  return default_use_anchors_for_symbol_p (symbol);
+}
+
+#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P
+#define TARGET_USE_ANCHORS_FOR_SYMBOL_P arc_use_anchors_for_symbol_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-arc.h"
index 5600d2c6bf9248de4c59811a13a7ec660a895a09..f38f8669020d2194bbe19ba72e0e8caeb5e1cfce 100644 (file)
@@ -1,3 +1,7 @@
+2017-09-01  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * gcc.target/arc/pr9001184797.c: New test.
+
 2017-09-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/81887
diff --git a/gcc/testsuite/gcc.target/arc/pr9001184797.c b/gcc/testsuite/gcc.target/arc/pr9001184797.c
new file mode 100644 (file)
index 0000000..e76c676
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target tls } */
+/* { dg-options "-Os -w -mno-ll64" } */
+
+/* This test studies the use of anchors and tls symbols. */
+
+struct a b;
+struct a {
+  long c;
+  long d
+} e() {
+  static __thread struct a f;
+  static __thread g;
+  g = 5;
+  h();
+  if (f.c)
+    g = g & 5;
+  f = b;
+}