Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[IRBuilder] Handle constexpr-bitcast for IRBuilder::CreateThreadLocalAddress" #72434

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

JOE1994
Copy link
Member

@JOE1994 JOE1994 commented Nov 15, 2023

This reverts ce1b24c.

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

…eadLocalAddress"

This reverts ce1b24c.

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

llvmbot commented Nov 15, 2023

@llvm/pr-subscribers-llvm-ir

Author: Youngsuk Kim (JOE1994)

Changes

This reverts ce1b24c.

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

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JOE1994 JOE1994 merged commit f00bade into llvm:main Nov 15, 2023
3 of 4 checks passed
@JOE1994 JOE1994 deleted the llvm_revert_typedptrsafetypatch branch November 15, 2023 21:29
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
…eadLocalAddress" (llvm#72434)

This reverts ce1b24c.

Since opaque pointers are enabled, we can safely revert the patch now.
Opaque ptr cleanup effort (NFC).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants