
We can simply use the `__tls_base` global for this which is guaranteed to be non-zero and unique per thread. Fixes: #117433
22 lines
768 B
LLVM
22 lines
768 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=wasm32-unknown-unknown | FileCheck %s --check-prefix=WASM32
|
|
; RUN: llc < %s -mtriple=wasm64-unknown-unknown | FileCheck %s --check-prefix=WASM64
|
|
|
|
declare ptr @llvm.thread.pointer()
|
|
|
|
define ptr @thread_pointer() nounwind {
|
|
; WASM32-LABEL: thread_pointer:
|
|
; WASM32: .functype thread_pointer () -> (i32)
|
|
; WASM32-NEXT: # %bb.0:
|
|
; WASM32-NEXT: global.get __tls_base
|
|
; WASM32-NEXT: # fallthrough-return
|
|
;
|
|
; WASM64-LABEL: thread_pointer:
|
|
; WASM64: .functype thread_pointer () -> (i64)
|
|
; WASM64-NEXT: # %bb.0:
|
|
; WASM64-NEXT: global.get __tls_base
|
|
; WASM64-NEXT: # fallthrough-return
|
|
%1 = tail call ptr @llvm.thread.pointer()
|
|
ret ptr %1
|
|
}
|