[PATCH] D74754: [IR] Set name when inserting 'llvm::Value*'
Brian Gesiak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 20:14:58 PST 2020
modocache created this revision.
modocache added reviewers: nikic, Meinersbur, nhaehnle, fhahn, thakis, teemperor.
Herald added a project: LLVM.
I noticed a small regression in a toy project of mine after applying
D73835 <https://reviews.llvm.org/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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74754
Files:
llvm/include/llvm/IR/IRBuilder.h
llvm/unittests/IR/IRBuilderTest.cpp
Index: llvm/unittests/IR/IRBuilderTest.cpp
===================================================================
--- llvm/unittests/IR/IRBuilderTest.cpp
+++ llvm/unittests/IR/IRBuilderTest.cpp
@@ -929,4 +929,11 @@
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");
+}
}
Index: llvm/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -134,9 +134,9 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74754.245075.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200218/4fad4b3d/attachment.bin>
More information about the llvm-commits
mailing list