[llvm] Fix crash in `CodeGenPrepare.cpp` and `Verifier.cpp` (PR #112772)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 13:29:24 PDT 2024
https://github.com/abhishek-kaushik22 created https://github.com/llvm/llvm-project/pull/112772
The method `AddressingModeMatcher::matchOperationAddr` and `Verifier::visitIntrinsicCall` expect a `GlobalValue` as the operand of the `llvm.threadlocal.address.p0` intrinsic. The hoist TLS pass replaces them with a bitcast instruction, causing a crash.
Fixes #112771
>From f8018bf3a86a14e1495d76f7315a2a9fd410b5b0 Mon Sep 17 00:00:00 2001
From: abhishek-kaushik22 <abhishek.kaushik at intel.com>
Date: Fri, 18 Oct 2024 01:58:33 +0530
Subject: [PATCH] Fix crash in `CodeGenPrepare.cpp` and `Verifier.cpp`
The method `AddressingModeMatcher::matchOperationAddr` and `Verifier::visitIntrinsicCall` expect a `GlobalValue` as the operand of the `llvm.threadlocal.address.p0` intrinsic.
The hoist TLS pass replaces them with a bitcast instruction, causing a crash.
---
llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp b/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
index 58ea5b68d5488b..93cd736945aace 100644
--- a/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
@@ -238,8 +238,13 @@ bool TLSVariableHoistPass::tryReplaceTLSCandidate(Function &Fn,
auto *CastInst = genBitCastInst(Fn, GV);
// to replace the uses of TLS Candidate
- for (auto &User : Cand.Users)
+ for (auto &User : Cand.Users) {
+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(User.Inst)) {
+ if (II->getIntrinsicID() == Intrinsic::threadlocal_address)
+ continue;
+ }
User.Inst->setOperand(User.OpndIdx, CastInst);
+ }
return true;
}
More information about the llvm-commits
mailing list