run-gd.c: New test.
authorUros Bizjak <ubizjak@gmail.com>
Tue, 24 May 2011 14:32:47 +0000 (16:32 +0200)
committerRainer Orth <ro@gcc.gnu.org>
Tue, 24 May 2011 14:32:47 +0000 (14:32 +0000)
2011-05-24  Uros Bizjak <ubizjak@gmail.com>
    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

* gcc.dg/torture/tls/run-gd.c: New test.
* gcc.dg/torture/tls/run-ie.c: New test.
* gcc.dg/torture/tls/run-ld.c: New test.
* gcc.dg/torture/tls/run-le.c: New test.
* lib/target-supports.exp (check_effective_target_tls_runtime):
Build testcase with TLS options.

Co-Authored-By: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
From-SVN: r174117

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/tls/run-gd.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/tls/run-ie.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/tls/run-ld.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/tls/run-le.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp

index 6481ead9cdfd61a7c12bbf1c9aae9538f464b000..48fb7202685bcfb938c19988ac2bd8f5cde7dba1 100644 (file)
@@ -1,3 +1,13 @@
+2011-05-24  Uros Bizjak <ubizjak@gmail.com>
+           Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * gcc.dg/torture/tls/run-gd.c: New test.
+       * gcc.dg/torture/tls/run-ie.c: New test.
+       * gcc.dg/torture/tls/run-ld.c: New test.
+       * gcc.dg/torture/tls/run-le.c: New test.
+       * lib/target-supports.exp (check_effective_target_tls_runtime):
+       Build testcase with TLS options.
+
 2011-05-24  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gcc.dg/vect/pr48172.c: Remove dg-do run.
diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-gd.c b/gcc/testsuite/gcc.dg/torture/tls/run-gd.c
new file mode 100644 (file)
index 0000000..6335e73
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-add-options tls } */
+
+extern void abort (void);
+
+__thread int tls_gd __attribute__((tls_model("global-dynamic"))) = 0;
+
+int get_gd (void)
+{
+  return tls_gd;
+}
+
+int *get_gdp (void)
+{
+  return &tls_gd;
+}
+
+int main (void)
+{
+  int val;
+
+  val = get_gd ();
+  if (val != 0)
+    abort ();
+
+  val = *get_gdp ();
+  if (val != 0)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-ie.c b/gcc/testsuite/gcc.dg/torture/tls/run-ie.c
new file mode 100644 (file)
index 0000000..ec07a44
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-add-options tls } */
+
+extern void abort (void);
+
+__thread int tls_ie __attribute__((tls_model("initial-exec"))) = 4;
+
+int get_ie (void)
+{
+  return tls_ie;
+}
+
+int *get_iep (void)
+{
+  return &tls_ie;
+}
+
+int main (void)
+{
+  int val;
+
+  val = get_ie ();
+  if (val != 4)
+    abort ();
+
+  val = *get_iep ();
+  if (val != 4)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-ld.c b/gcc/testsuite/gcc.dg/torture/tls/run-ld.c
new file mode 100644 (file)
index 0000000..cabfaf7
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-add-options tls } */
+
+extern void abort (void);
+
+__thread int tls_ld __attribute__((tls_model("local-dynamic"))) = 1;
+__thread int tls_ld2 __attribute__((tls_model("local-dynamic"))) = 2;
+
+int get_ld (void)
+{
+  return tls_ld + tls_ld2;
+}
+
+int *get_ldp (void)
+{
+  return &tls_ld;
+}
+
+int main (void)
+{
+  int val;
+
+  val = get_ld ();
+  if (val != 1 + 2)
+    abort ();
+
+  val = *get_ldp ();
+  if (val != 1)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-le.c b/gcc/testsuite/gcc.dg/torture/tls/run-le.c
new file mode 100644 (file)
index 0000000..0c340f3
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-add-options tls } */
+
+extern void abort (void);
+
+__thread int tls_le __attribute__((tls_model("local-exec"))) = 3;
+
+int get_le (void)
+{
+  return tls_le;
+}
+
+int *get_lep (void)
+{
+  return &tls_le;
+}
+
+int main (void)
+{
+  int val;
+
+  val = get_le ();
+  if (val != 3)
+    abort ();
+
+  val = *get_lep ();
+  if (val != 3)
+    abort ();
+
+  return 0;
+}
index d3d7f75a5545117716164f65e7556c73dfec53d7..6ede07494df79b259191379620f56a84390911b6 100644 (file)
@@ -687,7 +687,7 @@ proc check_effective_target_tls_runtime {} {
     return [check_runtime tls_runtime {
        __thread int thr = 0;
        int main (void) { return thr; }
-    }]
+    } [add_options_for_tls ""]]
 }
 
 # Return 1 if -ffunction-sections is supported, 0 otherwise.