aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2024-04-10 16:24:02 -0700
committerGitHub <noreply@github.com>2024-04-10 16:24:02 -0700
commitacb7ddc5cf2f23416f65dcdc6c7fd08850ad961d (patch)
treee64e8a895fb9b6d6079274a55679e4ac1e43b711 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
parent8136ac1c42dcfdd070f0bcba0f06424093df22db (diff)
downloadllvm-acb7ddc5cf2f23416f65dcdc6c7fd08850ad961d.zip
llvm-acb7ddc5cf2f23416f65dcdc6c7fd08850ad961d.tar.gz
llvm-acb7ddc5cf2f23416f65dcdc6c7fd08850ad961d.tar.bz2
[WebAssembly] Remove threadlocal.address when disabling TLS (#88209)
Remove `llvm.threadlocal.address` intrinsic usage when disabling TLS. This fixes errors revealed by the stricter IR verification introduced in PR #87841.
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);
}