[llvm] Revert "[IRBuilder] Handle constexpr-bitcast for IRBuilder::CreateThreadLocalAddress" (PR #72434)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 12:41:24 PST 2023
https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/72434
This reverts ce1b24cca886eb9f05e252f399059167473d0ba3.
Since opaque pointers are enabled, we can safely revert the patch now. Opaque ptr cleanup effort (NFC).
>From f80a65970213c7939d0e2001618795d9fbc8b077 Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <youngsuk.kim at hpe.com>
Date: Wed, 15 Nov 2023 14:14:33 -0600
Subject: [PATCH] Revert "[IRBuilder] Handle constexpr-bitcast for
IRBuilder::CreateThreadLocalAddress"
This reverts ce1b24cca886eb9f05e252f399059167473d0ba3.
Since opaque pointers are enabled, we can safely revert the patch now.
Opaque ptr cleanup effort (NFC).
---
llvm/lib/IR/IRBuilder.cpp | 13 +------------
llvm/unittests/IR/IRBuilderTest.cpp | 15 ---------------
2 files changed, 1 insertion(+), 27 deletions(-)
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index b321d8b325fe0be..b09b80f95871a1c 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -536,19 +536,8 @@ static MaybeAlign getAlign(Value *Ptr) {
}
CallInst *IRBuilderBase::CreateThreadLocalAddress(Value *Ptr) {
-#ifndef NDEBUG
- // Handle specially for constexpr cast. This is possible when
- // opaque pointers not enabled since constant could be sinked
- // directly by the design of llvm. This could be eliminated
- // after we eliminate the abuse of constexpr.
- auto *V = Ptr;
- if (auto *CE = dyn_cast<ConstantExpr>(V))
- if (CE->isCast())
- V = CE->getOperand(0);
-
- assert(isa<GlobalValue>(V) && cast<GlobalValue>(V)->isThreadLocal() &&
+ assert(isa<GlobalValue>(Ptr) && cast<GlobalValue>(Ptr)->isThreadLocal() &&
"threadlocal_address only applies to thread local variables.");
-#endif
CallInst *CI = CreateIntrinsic(llvm::Intrinsic::threadlocal_address,
{Ptr->getType()}, {Ptr});
if (MaybeAlign A = getAlign(Ptr)) {
diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp
index bda57176daeba81..d15ff9dd51a4c44 100644
--- a/llvm/unittests/IR/IRBuilderTest.cpp
+++ b/llvm/unittests/IR/IRBuilderTest.cpp
@@ -1042,21 +1042,6 @@ TEST_F(IRBuilderTest, CreateGlobalStringPtr) {
EXPECT_TRUE(String3->getType()->getPointerAddressSpace() == 2);
}
-TEST_F(IRBuilderTest, CreateThreadLocalAddress) {
- IRBuilder<> Builder(BB);
-
- GlobalVariable *G = new GlobalVariable(*M, Builder.getInt64Ty(), /*isConstant*/true,
- GlobalValue::ExternalLinkage, nullptr, "", nullptr,
- GlobalValue::GeneralDynamicTLSModel);
-
- Constant *CEBC = ConstantExpr::getBitCast(G, Builder.getInt8PtrTy());
- // Tests that IRBuilder::CreateThreadLocalAddress wouldn't crash if its operand
- // is BitCast ConstExpr. The case should be eliminated after we eliminate the
- // abuse of constexpr.
- CallInst *CI = Builder.CreateThreadLocalAddress(CEBC);
- EXPECT_NE(CI, nullptr);
-}
-
TEST_F(IRBuilderTest, DebugLoc) {
auto CalleeTy = FunctionType::get(Type::getVoidTy(Ctx),
/*isVarArg=*/false);
More information about the llvm-commits
mailing list