diff options
| author | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-05 09:13:28 +0100 |
|---|---|---|
| committer | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-11 09:32:08 +0000 |
| commit | cf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch) | |
| tree | 40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/codegen/thread-local.rs | |
| parent | ca855e6e42787ecd062d81d53336fe6788ef51a9 (diff) | |
| download | rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip | |
Move /src/test to /tests
Diffstat (limited to 'tests/codegen/thread-local.rs')
| -rw-r--r-- | tests/codegen/thread-local.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/codegen/thread-local.rs b/tests/codegen/thread-local.rs new file mode 100644 index 00000000000..0f1b29ca79b --- /dev/null +++ b/tests/codegen/thread-local.rs @@ -0,0 +1,49 @@ +// compile-flags: -O +// aux-build:thread_local_aux.rs +// ignore-windows FIXME(#84933) +// ignore-wasm globals are used instead of thread locals +// ignore-emscripten globals are used instead of thread locals +// ignore-android does not use #[thread_local] + +#![crate_type = "lib"] + +extern crate thread_local_aux as aux; + +use std::cell::Cell; + +thread_local!(static A: Cell<u32> = const { Cell::new(1) }); + +// CHECK: [[TLS_AUX:@.+]] = external thread_local local_unnamed_addr global i64 +// CHECK: [[TLS:@.+]] = internal thread_local unnamed_addr global + +// CHECK-LABEL: @get +#[no_mangle] +fn get() -> u32 { + // CHECK: %0 = load i32, {{.*}}[[TLS]]{{.*}} + // CHECK-NEXT: ret i32 %0 + A.with(|a| a.get()) +} + +// CHECK-LABEL: @set +#[no_mangle] +fn set(v: u32) { + // CHECK: store i32 %0, {{.*}}[[TLS]]{{.*}} + // CHECK-NEXT: ret void + A.with(|a| a.set(v)) +} + +// CHECK-LABEL: @get_aux +#[no_mangle] +fn get_aux() -> u64 { + // CHECK: %0 = load i64, {{.*}}[[TLS_AUX]] + // CHECK-NEXT: ret i64 %0 + aux::A.with(|a| a.get()) +} + +// CHECK-LABEL: @set_aux +#[no_mangle] +fn set_aux(v: u64) { + // CHECK: store i64 %0, {{.*}}[[TLS_AUX]] + // CHECK-NEXT: ret void + aux::A.with(|a| a.set(v)) +} |
