forked from OSchip/llvm-project
[IR] Set name when inserting 'llvm::Value*'
Summary: I noticed a small regression in a toy project of mine after applying D73835, in which instruction names weren't being set properly. In the example test case included with this patch, `llvm::IRBuilderBase::CreateAdd` returns an `llvm::Value *` that is then passed as an argument to `llvm::IRBuilderBase::Insert`. The overloaded function that is selected for that call then ignores the `Name` parameter that is given. This patch addresses that issue. Reviewers: nikic, Meinersbur, nhaehnle, fhahn, thakis, teemperor Reviewed By: nikic, fhahn Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74754
This commit is contained in:
parent
b3cd44f80b
commit
c30d8f7c91
|
@ -134,9 +134,9 @@ public:
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *Insert(Value *V, const Twine& = "") const {
|
Value *Insert(Value *V, const Twine &Name = "") const {
|
||||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||||
return Insert(I);
|
return Insert(I, Name);
|
||||||
assert(isa<Constant>(V));
|
assert(isa<Constant>(V));
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
|
|
|
@ -929,4 +929,11 @@ TEST_F(IRBuilderTest, DIBuilderMacro) {
|
||||||
EXPECT_EQ(MN2, MF2->getRawElements());
|
EXPECT_EQ(MN2, MF2->getRawElements());
|
||||||
EXPECT_TRUE(verifyModule(*M));
|
EXPECT_TRUE(verifyModule(*M));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(IRBuilderTest, NoFolderNames) {
|
||||||
|
IRBuilder<NoFolder> Builder(BB);
|
||||||
|
auto *Add =
|
||||||
|
Builder.CreateAdd(Builder.getInt32(1), Builder.getInt32(2), "add");
|
||||||
|
EXPECT_EQ(Add->getName(), "add");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue