aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/thread-local.c10
-rw-r--r--test/thread-local.qbe23
2 files changed, 33 insertions, 0 deletions
diff --git a/test/thread-local.c b/test/thread-local.c
new file mode 100644
index 0000000..3086699
--- /dev/null
+++ b/test/thread-local.c
@@ -0,0 +1,10 @@
+thread_local int a = 1;
+static thread_local int b = 2;
+extern thread_local int c = 3;
+thread_local int d;
+static thread_local int e;
+extern thread_local int f;
+int main(void) {
+ static thread_local int x = 6;
+ return a + b + c + d + e - x;
+}
diff --git a/test/thread-local.qbe b/test/thread-local.qbe
new file mode 100644
index 0000000..0e9ba83
--- /dev/null
+++ b/test/thread-local.qbe
@@ -0,0 +1,23 @@
+thread export data $a = align 4 { w 1, }
+thread data $b = align 4 { w 2, }
+thread export data $c = align 4 { w 3, }
+thread export data $d = align 4 { z 4 }
+thread data $e = align 4 { z 4 }
+thread data $.Lx.2 = align 4 { w 6, }
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =w loadw thread $a
+ %.2 =w loadw thread $b
+ %.3 =w add %.1, %.2
+ %.4 =w loadw thread $c
+ %.5 =w add %.3, %.4
+ %.6 =w loadw thread $d
+ %.7 =w add %.5, %.6
+ %.8 =w loadw thread $e
+ %.9 =w add %.7, %.8
+ %.10 =w loadw thread $.Lx.2
+ %.11 =w sub %.9, %.10
+ ret %.11
+}