-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[LLVM][Transforms] Add unit test for resolved cloning bug #139223
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
Conversation
@llvm/pr-subscribers-backend-loongarch @llvm/pr-subscribers-llvm-transforms Author: Christian Ulmann (Dinistro) ChangesThis commit introduces a new unit test that covers a block address cloning bug. Specifically, this test covers the bug tracked in http://github.com/llvm/llvm-project/issues/47769 which has been resolved in the meantime. Full diff: https://github.com/llvm/llvm-project/pull/139223.diff 1 Files Affected:
diff --git a/llvm/unittests/Transforms/Utils/CloningTest.cpp b/llvm/unittests/Transforms/Utils/CloningTest.cpp
index 03769ff59e372..11ff1a88ee299 100644
--- a/llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ b/llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -1001,6 +1001,16 @@ class CloneModule : public ::testing::Test {
Function::Create(FuncType, GlobalValue::ExternalLinkage, "g", OldM);
G->addMetadata(LLVMContext::MD_type, *MDNode::get(C, {}));
+ auto *NonEntryBlock = BasicBlock::Create(C, "", F);
+ IBuilder.SetInsertPoint(NonEntryBlock);
+ IBuilder.CreateRetVoid();
+
+ // Create a global that contains the block address in its initializer.
+ auto *BlockAddress = BlockAddress::get(NonEntryBlock);
+ new GlobalVariable(*OldM, BlockAddress->getType(), /*isConstant=*/true,
+ GlobalVariable::ExternalLinkage, BlockAddress,
+ "blockaddr");
+
// Finalize the debug info
DBuilder.finalize();
}
@@ -1162,4 +1172,13 @@ declare i64 @foo(i32 noundef) local_unnamed_addr
auto NewM = llvm::CloneModule(*M);
EXPECT_FALSE(verifyModule(*NewM, &errs()));
}
+
+// Checks that block addresses in global initializers are properly cloned.
+TEST_F(CloneModule, GlobalWithBlockAddressesInitializer) {
+ auto *OriginalBa = cast<BlockAddress>(
+ OldM->getGlobalVariable("blockaddr")->getInitializer());
+ auto *ClonedBa = cast<BlockAddress>(
+ NewM->getGlobalVariable("blockaddr")->getInitializer());
+ ASSERT_NE(OriginalBa->getBasicBlock(), ClonedBa->getBasicBlock());
+}
} // namespace
|
b121d0c
to
842a8c6
Compare
842a8c6
to
6b02b3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This commit introduces a new unit test that covers a block address cloning bug. Specifically, this test covers the bug tracked in http://github.com/llvm/llvm-project/issues/47769 which has been resolved in the meantime.
6b02b3e
to
91b20ca
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/16499 Here is the relevant piece of the build log for the reference
|
This commit introduces a new unit test that covers a block address cloning bug. Specifically, this test covers the bug tracked in http://github.com/llvm/llvm-project/issues/47769 which has been resolved in the meantime.