aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 70685b2..769ee76 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -291,6 +291,17 @@ private:
bool Stripped = false;
for (auto &GV : M.globals()) {
if (GV.isThreadLocal()) {
+ // replace `@llvm.threadlocal.address.pX(GV)` with `GV`.
+ for (Use &U : make_early_inc_range(GV.uses())) {
+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(U.getUser())) {
+ if (II->getIntrinsicID() == Intrinsic::threadlocal_address &&
+ II->getArgOperand(0) == &GV) {
+ II->replaceAllUsesWith(&GV);
+ II->eraseFromParent();
+ }
+ }
+ }
+
Stripped = true;
GV.setThreadLocal(false);
}