1
0
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:
Brian Gesiak 2020-02-17 23:10:30 -05:00
parent 38b58c28d1
commit 1c9c59e475
2 changed files with 9 additions and 2 deletions

View File

@ -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;
}

View File

@ -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");
}
}