Skip to content

Commit f00bade

Browse files
authored
Revert "[IRBuilder] Handle constexpr-bitcast for IRBuilder::CreateThreadLocalAddress" (#72434)
This reverts ce1b24c. Since opaque pointers are enabled, we can safely revert the patch now. Opaque ptr cleanup effort (NFC).
1 parent c70f6fc commit f00bade

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

llvm/lib/IR/IRBuilder.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,19 +536,8 @@ static MaybeAlign getAlign(Value *Ptr) {
536536
}
537537

538538
CallInst *IRBuilderBase::CreateThreadLocalAddress(Value *Ptr) {
539-
#ifndef NDEBUG
540-
// Handle specially for constexpr cast. This is possible when
541-
// opaque pointers not enabled since constant could be sinked
542-
// directly by the design of llvm. This could be eliminated
543-
// after we eliminate the abuse of constexpr.
544-
auto *V = Ptr;
545-
if (auto *CE = dyn_cast<ConstantExpr>(V))
546-
if (CE->isCast())
547-
V = CE->getOperand(0);
548-
549-
assert(isa<GlobalValue>(V) && cast<GlobalValue>(V)->isThreadLocal() &&
539+
assert(isa<GlobalValue>(Ptr) && cast<GlobalValue>(Ptr)->isThreadLocal() &&
550540
"threadlocal_address only applies to thread local variables.");
551-
#endif
552541
CallInst *CI = CreateIntrinsic(llvm::Intrinsic::threadlocal_address,
553542
{Ptr->getType()}, {Ptr});
554543
if (MaybeAlign A = getAlign(Ptr)) {

llvm/unittests/IR/IRBuilderTest.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,21 +1042,6 @@ TEST_F(IRBuilderTest, CreateGlobalStringPtr) {
10421042
EXPECT_TRUE(String3->getType()->getPointerAddressSpace() == 2);
10431043
}
10441044

1045-
TEST_F(IRBuilderTest, CreateThreadLocalAddress) {
1046-
IRBuilder<> Builder(BB);
1047-
1048-
GlobalVariable *G = new GlobalVariable(*M, Builder.getInt64Ty(), /*isConstant*/true,
1049-
GlobalValue::ExternalLinkage, nullptr, "", nullptr,
1050-
GlobalValue::GeneralDynamicTLSModel);
1051-
1052-
Constant *CEBC = ConstantExpr::getBitCast(G, Builder.getInt8PtrTy());
1053-
// Tests that IRBuilder::CreateThreadLocalAddress wouldn't crash if its operand
1054-
// is BitCast ConstExpr. The case should be eliminated after we eliminate the
1055-
// abuse of constexpr.
1056-
CallInst *CI = Builder.CreateThreadLocalAddress(CEBC);
1057-
EXPECT_NE(CI, nullptr);
1058-
}
1059-
10601045
TEST_F(IRBuilderTest, DebugLoc) {
10611046
auto CalleeTy = FunctionType::get(Type::getVoidTy(Ctx),
10621047
/*isVarArg=*/false);

0 commit comments

Comments
 (0)