File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
llvm/lib/Target/WebAssembly Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -289,21 +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 ));
292
+ for (auto &GV : M.globals ()) {
293
+ if (GV.isThreadLocal ()) {
294
+ // replace `@llvm.threadlocal.address.pX(GV)` with `GV`.
295
+ for (Use &U : make_early_inc_range (GV.uses ())) {
296
+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(U.getUser ())) {
297
+ if (II->getIntrinsicID () == Intrinsic::threadlocal_address &&
298
+ II->getArgOperand (0 ) == &GV) {
299
+ II->replaceAllUsesWith (&GV);
298
300
II->eraseFromParent ();
299
- Stripped = true ;
300
301
}
301
302
}
302
303
}
303
- }
304
- }
305
- for (auto &GV : M.globals ()) {
306
- if (GV.isThreadLocal ()) {
304
+
307
305
Stripped = true ;
308
306
GV.setThreadLocal (false );
309
307
}
You can’t perform that action at this time.
0 commit comments