aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Sandoe <iains@gcc.gnu.org>2010-08-18 09:01:22 +0000
committerIain Sandoe <iains@gcc.gnu.org>2010-08-18 09:01:22 +0000
commit63d90a96304b484a365e8411578413b40a2b1a35 (patch)
tree0f30579d079c3ee0ca03023cc8b962620ff7e8bd /gcc
parent618d48304d0fd942c77c9172f929f8c15574dec3 (diff)
downloadgcc-63d90a96304b484a365e8411578413b40a2b1a35.zip
gcc-63d90a96304b484a365e8411578413b40a2b1a35.tar.gz
gcc-63d90a96304b484a365e8411578413b40a2b1a35.tar.bz2
test cse for emulated TLS targets.
* lib/target-supports.exp (check_effective_target_tls_emulated): New. * gcc.dg/tls/thr-cse-1.c: New. From-SVN: r163330
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tls/thr-cse-1.c21
-rw-r--r--gcc/testsuite/lib/target-supports.exp17
3 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5b5fb1f..10a8aff 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2010-08-18 Iain Sandoe <iains@gcc.gnu.org>
+ * lib/target-supports.exp (check_effective_target_tls_emulated): New.
+ * gcc.dg/tls/thr-cse-1.c: New.
+
+2010-08-18 Iain Sandoe <iains@gcc.gnu.org>
+
PR debug/42487
* lib/target-supports.exp
(check_effective_target_function_sections): New.
diff --git a/gcc/testsuite/gcc.dg/tls/thr-cse-1.c b/gcc/testsuite/gcc.dg/tls/thr-cse-1.c
new file mode 100644
index 0000000..26f7ef8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tls/thr-cse-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+/* { dg-require-effective-target tls_emulated } */
+
+/* Test that we only get one call to emutls_get_address when CSE is
+ active. Note that the var _must_ be initialized for the scan asm
+ to work, since otherwise there will be an initializer which will,
+ correctly, call emutls_get_address. */
+int foo (int b, int c, int d)
+{
+ static __thread int a=1;
+ a += b;
+ a -= c;
+ a += d;
+ return a;
+}
+
+/* { dg-final { scan-assembler-not "emutls_get_address.*emutls_get_address.*" { target { { ! "*-wrs-vxworks" } && { ! "*-*-darwin8" } } } } } */
+/* { dg-final { scan-assembler-not "call\tL___emutls_get_address.stub.*call\tL___emutls_get_address.stub.*" { target "*-*-darwin8" } } } */
+/* { dg-final { scan-assembler-not "tls_lookup.*tls_lookup.*" { target *-wrs-vxworks } } } */
+
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 9cc9b60..1682d58 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -614,6 +614,23 @@ proc check_effective_target_tls_native {} {
}]
}
+# Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
+
+proc check_effective_target_tls_emulated {} {
+ # VxWorks uses emulated TLS machinery, but with non-standard helper
+ # functions, so we fail to automatically detect it.
+ global target_triplet
+ if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
+ return 1
+ }
+
+ return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
+ __thread int i;
+ int f (void) { return i; }
+ void g (int j) { i = j; }
+ }]
+}
+
# Return 1 if TLS executables can run correctly, 0 otherwise.
proc check_effective_target_tls_runtime {} {