===================================================================
@@ -596,6 +596,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 {} {
===================================================================
@@ -0,0 +1,20 @@
+/* { 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 } } } } */