PR target/24475
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Dec 2005 06:52:11 +0000 (06:52 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Dec 2005 06:52:11 +0000 (06:52 +0000)
* lib/target-supports.exp (check_effective_target_tls): New.
(check_effective_target_tls_runtime): New.
* gcc.dg/tls/tls.exp, g++.dg/tls/tls.exp: Remove check
for TLS support.
* gcc.dg/tls/opt-1.c, gcc.dg/tls/opt-2.c, gcc.dg/tls/opt-3.c,
gcc.dg/tls/opt-4.c, gcc.dg/tls/opt-5.c, gcc.dg/tls/opt-6.c,
gcc.dg/tls/opt-7.c, gcc.dg/tls/opt-8.c, gcc.dg/tls/opt-9.c,
gcc.dg/tls/opt-10.c, gcc.dg/tls/diag-1.c, gcc.dg/tls/diag-2.c,
gcc.dg/tls/diag-3.c, gcc.dg/tls/diag-4.c, gcc.dg/tls/diag-5.c,
gcc.dg/tls/alias-1.c, gcc.dg/tls/alpha-1.c, gcc.dg/tls/asm-1.c,
gcc.dg/tls/debug-1.c, gcc.dg/tls/init-1.c, gcc.dg/tls/nonpic-1.c,
gcc.dg/tls/pic-1.c, gcc.dg/tls/section-1.c, gcc.dg/tls/struct-1.c,
gcc.dg/tls/trivial.c, g++.dg/tls/diag-1.C, g++.dg/tls/diag-2.C,
g++.dg/tls/diag-3.C, g++.dg/tls/diag-4.C, g++.dg/tls/init-1.C,
g++.dg/tls/init-2.C, g++.dg/tls/trivial.C: Require
effective-target TLS.
* gcc.dg/tls/pr24428-2.c, gcc.dg/tls/pr24428.c, gcc.dg/tls/opt-11.c,
g++.dg/tls/static-1a.cc, g++.dg/tls/static-1.C: Require
effective-target TLS runtime.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107804 138bc75d-0d04-0410-961f-82ee72b054a4

41 files changed:
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tls/diag-1.C
gcc/testsuite/g++.dg/tls/diag-2.C
gcc/testsuite/g++.dg/tls/diag-3.C
gcc/testsuite/g++.dg/tls/diag-4.C
gcc/testsuite/g++.dg/tls/init-1.C
gcc/testsuite/g++.dg/tls/init-2.C
gcc/testsuite/g++.dg/tls/static-1.C
gcc/testsuite/g++.dg/tls/static-1a.cc
gcc/testsuite/g++.dg/tls/tls.exp
gcc/testsuite/g++.dg/tls/trivial.C
gcc/testsuite/gcc.dg/tls/alias-1.c
gcc/testsuite/gcc.dg/tls/alpha-1.c
gcc/testsuite/gcc.dg/tls/asm-1.c
gcc/testsuite/gcc.dg/tls/debug-1.c
gcc/testsuite/gcc.dg/tls/diag-1.c
gcc/testsuite/gcc.dg/tls/diag-2.c
gcc/testsuite/gcc.dg/tls/diag-3.c
gcc/testsuite/gcc.dg/tls/diag-4.c
gcc/testsuite/gcc.dg/tls/diag-5.c
gcc/testsuite/gcc.dg/tls/init-1.c
gcc/testsuite/gcc.dg/tls/nonpic-1.c
gcc/testsuite/gcc.dg/tls/opt-1.c
gcc/testsuite/gcc.dg/tls/opt-10.c
gcc/testsuite/gcc.dg/tls/opt-11.c
gcc/testsuite/gcc.dg/tls/opt-2.c
gcc/testsuite/gcc.dg/tls/opt-3.c
gcc/testsuite/gcc.dg/tls/opt-4.c
gcc/testsuite/gcc.dg/tls/opt-5.c
gcc/testsuite/gcc.dg/tls/opt-6.c
gcc/testsuite/gcc.dg/tls/opt-7.c
gcc/testsuite/gcc.dg/tls/opt-8.c
gcc/testsuite/gcc.dg/tls/opt-9.c
gcc/testsuite/gcc.dg/tls/pic-1.c
gcc/testsuite/gcc.dg/tls/pr24428-2.c
gcc/testsuite/gcc.dg/tls/pr24428.c
gcc/testsuite/gcc.dg/tls/section-1.c
gcc/testsuite/gcc.dg/tls/struct-1.c
gcc/testsuite/gcc.dg/tls/tls.exp
gcc/testsuite/gcc.dg/tls/trivial.c
gcc/testsuite/lib/target-supports.exp

index ce4d728..d55401d 100644 (file)
@@ -1,5 +1,28 @@
 2005-12-01  Uros Bizjak  <uros@kss-loka.si>
 
+       PR target/24475
+       * lib/target-supports.exp (check_effective_target_tls): New.
+       (check_effective_target_tls_runtime): New.
+       * gcc.dg/tls/tls.exp, g++.dg/tls/tls.exp: Remove check
+       for TLS support.
+       * gcc.dg/tls/opt-1.c, gcc.dg/tls/opt-2.c, gcc.dg/tls/opt-3.c,
+       gcc.dg/tls/opt-4.c, gcc.dg/tls/opt-5.c, gcc.dg/tls/opt-6.c,
+       gcc.dg/tls/opt-7.c, gcc.dg/tls/opt-8.c, gcc.dg/tls/opt-9.c,
+       gcc.dg/tls/opt-10.c, gcc.dg/tls/diag-1.c, gcc.dg/tls/diag-2.c,
+       gcc.dg/tls/diag-3.c, gcc.dg/tls/diag-4.c, gcc.dg/tls/diag-5.c,
+       gcc.dg/tls/alias-1.c, gcc.dg/tls/alpha-1.c, gcc.dg/tls/asm-1.c,
+       gcc.dg/tls/debug-1.c, gcc.dg/tls/init-1.c, gcc.dg/tls/nonpic-1.c,
+       gcc.dg/tls/pic-1.c, gcc.dg/tls/section-1.c, gcc.dg/tls/struct-1.c,
+       gcc.dg/tls/trivial.c, g++.dg/tls/diag-1.C, g++.dg/tls/diag-2.C,
+       g++.dg/tls/diag-3.C, g++.dg/tls/diag-4.C, g++.dg/tls/init-1.C,
+       g++.dg/tls/init-2.C, g++.dg/tls/trivial.C: Require
+       effective-target TLS.
+       * gcc.dg/tls/pr24428-2.c, gcc.dg/tls/pr24428.c, gcc.dg/tls/opt-11.c, 
+       g++.dg/tls/static-1a.cc, g++.dg/tls/static-1.C: Require
+       effective-target TLS runtime.
+
+2005-12-01  Uros Bizjak  <uros@kss-loka.si>
+
        * lib/gcov.exp (clean-gcov): Also remove $base.h.gcov files.
 
 2005-12-01  Hans-Peter Nilsson  <hp@axis.com>
index 697d0b1..af53871 100644 (file)
@@ -1,4 +1,5 @@
-/* Valid __thread specifiers.  */
+// Valid __thread specifiers.
+// { dg-require-effective-target tls }
 
 __thread int g1;
 extern __thread int g2;
index 293409d..484b188 100644 (file)
@@ -1,4 +1,5 @@
 /* Invalid __thread specifiers.  */
+/* { dg-require-effective-target tls } */
 
 __thread extern int g1;                /* { dg-error "'__thread' before 'extern'" } */
 __thread static int g2;                /* { dg-error "'__thread' before 'static'" } */
index ae2b6ce..ea5158b 100644 (file)
@@ -1,4 +1,5 @@
 // Report invalid extern and __thread combinations.
+// { dg-require-effective-target tls }
 
 extern int j;          // { dg-error "previously declared here" }
 __thread int j;                // { dg-error "follows non-thread-local" }
index 3b840f1..55e985e 100644 (file)
@@ -1,4 +1,5 @@
 /* Invalid __thread specifiers.  */
+/* { dg-require-effective-target tls } */
 
 __thread typedef int g4;       /* { dg-error "multiple storage classes" } */
 
index 74f7641..9786712 100644 (file)
@@ -1,4 +1,5 @@
 /* Valid initializations.  */
+/* { dg-require-effective-target tls } */
 
 __thread int i = 42;
 
index 4cc31c9..c9f646d 100644 (file)
@@ -1,4 +1,5 @@
 /* Invalid initializations.  */
+/* { dg-require-effective-target tls } */
 
 extern __thread int i;
 __thread int *p = &i;  /* { dg-error "dynamically initialized" } */
index 3cbcbec..2392c63 100644 (file)
@@ -1,6 +1,7 @@
 // { dg-do run }
 // { dg-options "-O2" }
 // { dg-additional-sources "static-1a.cc" }
+// { dg-require-effective-target tls_runtime }
 
 extern "C" void abort ();
 extern int test ();
index c87efdb..636f935 100644 (file)
@@ -1,6 +1,7 @@
 // { dg-do run }
 // { dg-options "-O2" }
 // { dg-additional-sources "static-1a.cc" }
+// { dg-require-effective-target tls_runtime }
 
 struct A
 {
index 20c2bd3..85e7a36 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 2002 Free Software Foundation, Inc.
+#   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # Load support procs.
 load_lib g++-dg.exp
 
-# Test for thread-local data supported by the platform.  If it
-# isn't, everything will fail with the "not supported" message.
-
-set comp_output [g++_target_compile \
-               "$srcdir/$subdir/trivial.C" "trivialx.S" assembly ""]
-remove-build-file "trivialx.S"
-if { [string match "*not supported*" $comp_output] } {
-  return 0
-}
-
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CXXFLAGS
 if ![info exists DEFAULT_CXXFLAGS] then {
index 1fd7063..e2b8f45 100644 (file)
@@ -1 +1,3 @@
+// { dg-require-effective-target tls }
+
 __thread int i;
index 1098190..28cb47e 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do link } */
 /* { dg-require-alias "" } */
 /* { dg-require-visibility "" } */
+/* { dg-require-effective-target tls } */
 /* Test that encode_section_info handles the change from externally
    defined to locally defined (via hidden).   Extracted from glibc.  */
 
index 4bb911f..1d15cb1 100644 (file)
@@ -1,6 +1,7 @@
 /* Make sure that we honor initial-exec.  */
 /* { dg-do compile { target alpha*-*-* } } */
 /* { dg-options "" } */
+/* { dg-require-effective-target tls } */
 
 static __thread int xyzzy __attribute__ ((tls_model ("initial-exec")));
 int foo(void) { return xyzzy; }
index 476fe7c..b77e550 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-options "-Werror" } */
+/* { dg-require-effective-target tls } */
 __thread int i;
 
 int foo ()
index 719f064..67d7be6 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do assemble } */
 /* { dg-options "-g" } */
+/* { dg-require-effective-target tls } */
 
 __thread int i;
index ae4f3d4..56b570c 100644 (file)
@@ -1,4 +1,5 @@
 /* Valid __thread specifiers.  */
+/* { dg-require-effective-target tls } */
 
 __thread int g1;
 extern __thread int g2;
index 5e7e17b..8276cb3 100644 (file)
@@ -1,4 +1,5 @@
 /* Invalid __thread specifiers.  */
+/* { dg-require-effective-target tls } */
 
 __thread extern int g1;                /* { dg-error "'__thread' before 'extern'" } */
 __thread static int g2;                /* { dg-error "'__thread' before 'static'" } */
index f1ce06b..45d89b4 100644 (file)
@@ -1,4 +1,5 @@
 /* Report invalid extern and __thread combinations.  */
+/* { dg-require-effective-target tls } */
 
 extern int j;          /* { dg-error "previous declaration" } */
 __thread int j;                /* { dg-error "follows non-thread-local" } */
index df3705d..fed2f3a 100644 (file)
@@ -1,5 +1,6 @@
 /* Invalid __thread specifiers.  As diag-4.c but some cases in
    different orders.  */
+/* { dg-require-effective-target tls } */
 
 __thread typedef int g4;       /* { dg-error "'__thread' used with 'typedef'" } */
 
index 623832c..219396d 100644 (file)
@@ -1,3 +1,4 @@
 /* __thread specifiers on empty declarations.  */
+/* { dg-require-effective-target tls } */
 
 __thread struct foo; /* { dg-warning "warning: useless '__thread' in empty declaration" } */
index 9725864..fa4208d 100644 (file)
@@ -1,4 +1,5 @@
 /* Invalid initializations.  */
+/* { dg-require-effective-target tls } */
 
 extern __thread int i;
 int *p = &i;   /* { dg-error "initializer element is not constant" } */
index 0896df6..9c592a9 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -ftls-model=initial-exec" } */
+/* { dg-require-effective-target tls } */
 
 extern __thread long e1;
 extern __thread int e2;
index f7dccee..5bada6e 100644 (file)
@@ -2,6 +2,7 @@
 /* { dg-options "-O2 -fPIC" } */
 /* { dg-options "-O2 -fPIC -mtune=i686" { target { i?86-*-* && ilp32 } } } */
 /* { dg-options "-O2 -fPIC -mtune=i686" { target { x86_64-*-* && ilp32 } } } */
+/* { dg-require-effective-target tls } */
 
 extern __thread int thr;
 
index f31c1ff..a710a06 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O3 -fpic" } */
+/* { dg-require-effective-target tls } */
 
 /* The web pass was creating unrecognisable pic_load_dot_plus_four insns
    on ARM.  */
index 5b2cd5c..3739645 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do run } */
+/* { dg-require-effective-target tls_runtime } */
 
 extern void abort (void);
 extern void *memset (void *, int, __SIZE_TYPE__);
index dde54f0..fd781eb 100644 (file)
@@ -6,6 +6,7 @@
 /* { dg-options "-O2 -ftls-model=initial-exec" } */
 /* { dg-options "-O2 -ftls-model=initial-exec -march=i686" { target { i?86-*-* && ilp32 } } } */
 /* { dg-options "-O2 -ftls-model=initial-exec -march=i686" { target { x86_64-*-* && ilp32 } } } */
+/* { dg-require-effective-target tls } */
 
 __thread int thr;
 
index 8e476f6..e59e511 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fpic" } */
 /* { dg-options "-O2 -fpic -mregparm=3" { target i?86-*-* } } */
+/* { dg-require-effective-target tls } */
 
 extern __thread int i, j, k;
 extern void bar(int *, int *, int *);
index 3a95688..aa59ee7 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target tls } */
 
 struct A
 {
index d8a686d..0604f32 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target tls } */
 /* Sched1 moved {load_tp} pattern between strlen call and the copy
    of the hard return value to its pseudo.  This resulted in a
    reload abort, since the hard register was not spillable.  */
index de04c1c..8a01c01 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target tls } */
 
 extern void abort (void);
 extern void exit (int);
index beb2c26..c345068 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fPIC" } */
+/* { dg-require-effective-target tls } */
 
 static __thread void *baz [4] __attribute__((tls_model ("initial-exec")));
 void foo (void)
index dec0eab..a733111 100644 (file)
@@ -1,6 +1,7 @@
 /* PR 18910 */
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target tls } */
 
 static __thread void *foo [2];
 void
index 3829c66..cc62ef5 100644 (file)
@@ -1,6 +1,7 @@
 /* PR 21412 */
 /* { dg-do compile */
 /* { dg-options "-O2 -fPIC" } */
+/* { dg-require-effective-target tls } */
 
 struct S { int x[10]; };
 extern __thread struct S s;
index f5b020b..bcd42bd 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fpic -ftls-model=global-dynamic" } */
+/* { dg-require-effective-target tls } */
 
 extern __thread long e1;
 extern __thread int e2;
index 828943c..a0ceecc 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target tls_runtime } */
 
 __thread double thrtest[81];
 int main ()
index 53b1245..ecb747e 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target tls_runtime } */
 
 __thread double thrtest[81];
 int main ()
index 741eadb..4fc5066 100644 (file)
@@ -1,5 +1,6 @@
 /* Verify that we get errors for trying to put TLS data in 
    sections which can't work.  */
+/* { dg-require-effective-target tls } */
 
 #define A(X)   __attribute__((section(X)))
 
index 1115123..5fd6be4 100644 (file)
@@ -2,6 +2,7 @@
    to allow addends for @dtpoff relocs or not.  */
 /* { dg-do compile } */
 /* { dg-options "-O2 -fpic" } */
+/* { dg-require-effective-target tls } */
 
 struct S {
   int s0, s1, s2, s3;
index b168a1e..cd86231 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 2002 Free Software Foundation, Inc.
+#   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # Load support procs.
 load_lib gcc-dg.exp
 
-# Test for thread-local data supported by the platform.  If it
-# isn't, everything will fail with the "not supported" message.
-
-set comp_output [gcc_target_compile \
-               "$srcdir/$subdir/trivial.c" "trivial.S" assembly ""]
-remove-build-file "trivial.S"
-if { [string match "*not supported*" $comp_output] } {
-  return 0
-}
-
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
index 1fd7063..96b8e49 100644 (file)
@@ -1 +1,3 @@
+/* { dg-require-effective-target tls } */
+
 __thread int i;
index bb6352f..d240095 100644 (file)
@@ -384,6 +384,84 @@ proc check_effective_target_pcc_bitfield_type_matters { } {
     return $et_pcc_bitfield_type_matters_saved
 }
 
+# Return 1 if thread local storage (TLS) is supported, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_tls {} {
+    global et_tls_saved
+
+    if [info exists et_tls_saved] {
+       verbose "check_effective_target_tls: using cached result" 2
+    } else {
+       set et_tls_saved 1
+
+       set src tls[pid].c
+       set asm tls[pid].S
+       verbose "check_effective_target_tls: compiling testfile $src" 2
+       set f [open $src "w"]
+       # Compile a small test program.
+       puts $f "__thread int i;\n"
+       close $f
+
+       # Test for thread-local data supported by the platform.
+       set comp_output \
+           [target_compile $src $asm assembly ""]
+       file delete $src
+       if { [string match "*not supported*" $comp_output] } {
+           set et_tls_saved 0
+       }
+       remove-build-file $asm
+    }
+    verbose "check_effective_target_tls: returning $et_tls_saved" 2
+    return $et_tls_saved
+}
+
+# Return 1 if TLS executables can run correctly, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_tls_runtime {} {
+    global et_tls_runtime_saved
+
+    if [info exists et_tls_runtime_saved] {
+       verbose "check_effective_target_tls_runtime: using cached result" 2
+    } else {
+       set et_tls_runtime_saved 0
+
+       set src tls_runtime[pid].c
+       set exe tls_runtime[pid].x
+       verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
+       set f [open $src "w"]
+       # Compile a small test program.
+       puts $f "__thread int thr = 0;\n"
+       puts $f "int main(void)\n {\n return thr;\n}"
+       close $f
+
+       set comp_output \
+           [target_compile $src $exe executable ""]
+       file delete $src
+
+       if [string match "" $comp_output] then {
+           # No error messages, everything is OK.
+
+           set result [remote_load target "./$exe" "" ""]
+           set status [lindex $result 0]
+           remote_file build delete $exe
+
+           verbose "check_effective_target_tls_runtime status is <$status>" 2
+
+           if { $status == "pass" } {
+               set et_tls_runtime_saved 1
+           }
+
+           verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
+       }
+    }
+
+    return $et_tls_runtime_saved
+}
+
 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
 # emitted, 0 otherwise.  Whether a shared library can actually be built is
 # out of scope for this test.