[llvm] Fix crash in `CodeGenPrepare.cpp` and `Verifier.cpp` (PR #112772)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 13:30:00 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: None (abhishek-kaushik22)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/112772.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp (+6-1)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/112772
More information about the llvm-commits
mailing list