[llvm] Revert "[IRBuilder] Handle constexpr-bitcast for IRBuilder::CreateThreadLocalAddress" (PR #72434)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 12:41:52 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Youngsuk Kim (JOE1994)

<details>
<summary>Changes</summary>

This reverts ce1b24cca886eb9f05e252f399059167473d0ba3.

Since opaque pointers are enabled, we can safely revert the patch now. Opaque ptr cleanup effort (NFC).

---
Full diff: https://github.com/llvm/llvm-project/pull/72434.diff


2 Files Affected:

- (modified) llvm/lib/IR/IRBuilder.cpp (+1-12) 
- (modified) llvm/unittests/IR/IRBuilderTest.cpp (-15) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/72434


More information about the llvm-commits mailing list