Skip to content

Commit f8018bf

Browse files
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.
1 parent e2d07fc commit f8018bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,13 @@ bool TLSVariableHoistPass::tryReplaceTLSCandidate(Function &Fn,
238238
auto *CastInst = genBitCastInst(Fn, GV);
239239

240240
// to replace the uses of TLS Candidate
241-
for (auto &User : Cand.Users)
241+
for (auto &User : Cand.Users) {
242+
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(User.Inst)) {
243+
if (II->getIntrinsicID() == Intrinsic::threadlocal_address)
244+
continue;
245+
}
242246
User.Inst->setOperand(User.OpndIdx, CastInst);
247+
}
243248

244249
return true;
245250
}

0 commit comments

Comments
 (0)