mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[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
38b58c28d1
commit
1c9c59e475
@ -134,9 +134,9 @@ public:
|
||||
return C;
|
||||
}
|
||||
|
||||
Value *Insert(Value *V, const Twine& = "") const {
|
||||
Value *Insert(Value *V, const Twine &Name = "") const {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
return Insert(I);
|
||||
return Insert(I, Name);
|
||||
assert(isa<Constant>(V));
|
||||
return V;
|
||||
}
|
||||
|
@ -929,4 +929,11 @@ TEST_F(IRBuilderTest, DIBuilderMacro) {
|
||||
EXPECT_EQ(MN2, MF2->getRawElements());
|
||||
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
Block a user