File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -289,6 +289,19 @@ class CoalesceFeaturesAndStripAtomics final : public ModulePass {
289
289
290
290
bool stripThreadLocals (Module &M) {
291
291
bool Stripped = false ;
292
+ for (auto &F : M) {
293
+ for (auto &B : F) {
294
+ for (auto &I : make_early_inc_range (B)) {
295
+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I)) {
296
+ if (II->getIntrinsicID () == Intrinsic::threadlocal_address) {
297
+ II->replaceAllUsesWith (II->getArgOperand (0 ));
298
+ II->eraseFromParent ();
299
+ Stripped = true ;
300
+ }
301
+ }
302
+ }
303
+ }
304
+ }
292
305
for (auto &GV : M.globals ()) {
293
306
if (GV.isThreadLocal ()) {
294
307
Stripped = true ;
Original file line number Diff line number Diff line change
1
+ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2
+ ; RUN: llc -o - %s -mattr=-bulk-memory | FileCheck --check-prefix=NOTLS %s
3
+ ; RUN: llc -o - %s -mattr=+bulk-memory,+atomics | FileCheck --check-prefix=TLS %s
4
+
5
+ target triple = "wasm32--"
6
+
7
+ @tls = internal thread_local global i32 0
8
+
9
+ define i32 @func () {
10
+ ; NOTLS-LABEL: func:
11
+ ; NOTLS: .functype func () -> (i32)
12
+ ; NOTLS-NEXT: # %bb.0:
13
+ ; NOTLS-NEXT: i32.const 0
14
+ ; NOTLS-NEXT: i32.load tls
15
+ ; NOTLS-NEXT: # fallthrough-return
16
+ ;
17
+ ; TLS-LABEL: func:
18
+ ; TLS: .functype func () -> (i32)
19
+ ; TLS-NEXT: # %bb.0:
20
+ ; TLS-NEXT: global.get __tls_base
21
+ ; TLS-NEXT: i32.const tls@TLSREL
22
+ ; TLS-NEXT: i32.add
23
+ ; TLS-NEXT: i32.load 0
24
+ ; TLS-NEXT: # fallthrough-return
25
+ %p = call ptr @llvm.threadlocal.address.p0 (ptr @tls )
26
+ %v = load i32 , ptr %p
27
+ ret i32 %v
28
+ }
You can’t perform that action at this time.
0 commit comments