summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-19 20:36:39 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-19 20:36:39 +0000
commit946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae (patch)
tree0e036a4f09e4072d6ae5ab6faac355df0b5862b5 /llvm/unittests
parent0ee02fc9fea7107898390680d925238fa5cc0924 (diff)
downloadbcm5719-llvm-946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae.tar.gz
bcm5719-llvm-946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae.zip
IR: Remove MDNodeFwdDecl
Remove `MDNodeFwdDecl` (as promised in r226481). Aside from API changes, there's no real functionality change here. `MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`, which returns a tuple with `isTemporary()` equal to true. The main point is that we can now add temporaries of other `MDNode` subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the first place because I didn't recognize this need, and thought they were only needed to handle forward references). A few things left out of (or highlighted by) this commit: - I've had to remove the (few) uses of `std::unique_ptr<>` to deal with temporaries, since the destructor is no longer public. `getTemporary()` should probably return the equivalent of `std::unique_ptr<T, MDNode::deleteTemporary>`. - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually does exist, but does the wrong thing: `MDNode::getTemporary()` is inherited and returns an `MDTuple`). - `MDNode` now only has one subclass, `UniquableMDNode`, and the distinction between them is actually somewhat confusing. I'll fix those up next. llvm-svn: 226501
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 2de1f06aef7..9515f0de4ff 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -167,10 +167,6 @@ TEST_F(MDNodeTest, Delete) {
delete I;
}
-TEST_F(MDNodeTest, DeleteMDNodeFwdDecl) {
- delete MDNode::getTemporary(Context, None);
-}
-
TEST_F(MDNodeTest, SelfReference) {
// !0 = !{!0}
// !1 = !{!0}
@@ -343,7 +339,7 @@ TEST_F(MDNodeTest, isTemporary) {
TEST_F(MDNodeTest, getDistinctWithUnresolvedOperands) {
// temporary !{}
- MDNodeFwdDecl *Temp = MDNode::getTemporary(Context, None);
+ MDTuple *Temp = MDTuple::getTemporary(Context, None);
ASSERT_FALSE(Temp->isResolved());
// distinct !{temporary !{}}
@@ -364,18 +360,19 @@ TEST_F(MDNodeTest, handleChangedOperandRecursion) {
MDNode *N0 = MDNode::get(Context, None);
// !1 = !{!3, null}
- std::unique_ptr<MDNodeFwdDecl> Temp3(MDNode::getTemporary(Context, None));
- Metadata *Ops1[] = {Temp3.get(), nullptr};
+ MDTuple *Temp3 = MDTuple::getTemporary(Context, None);
+ Metadata *Ops1[] = {Temp3, nullptr};
MDNode *N1 = MDNode::get(Context, Ops1);
// !2 = !{!3, !0}
- Metadata *Ops2[] = {Temp3.get(), N0};
+ Metadata *Ops2[] = {Temp3, N0};
MDNode *N2 = MDNode::get(Context, Ops2);
// !3 = !{!2}
Metadata *Ops3[] = {N2};
MDNode *N3 = MDNode::get(Context, Ops3);
Temp3->replaceAllUsesWith(N3);
+ MDNode::deleteTemporary(Temp3);
// !4 = !{!1}
Metadata *Ops4[] = {N1};
@@ -428,8 +425,8 @@ TEST_F(MDNodeTest, replaceResolvedOperand) {
// a global value that gets RAUW'ed.
//
// Use a temporary node to keep N from being resolved.
- std::unique_ptr<MDNodeFwdDecl> Temp(MDNodeFwdDecl::get(Context, None));
- Metadata *Ops[] = {nullptr, Temp.get()};
+ MDTuple *Temp = MDTuple::getTemporary(Context, None);
+ Metadata *Ops[] = {nullptr, Temp};
MDNode *Empty = MDTuple::get(Context, ArrayRef<Metadata *>());
MDNode *N = MDTuple::get(Context, Ops);
@@ -441,11 +438,12 @@ TEST_F(MDNodeTest, replaceResolvedOperand) {
EXPECT_EQ(Empty, N->getOperand(0));
// Check code for adding another unresolved operand.
- N->replaceOperandWith(0, Temp.get());
- EXPECT_EQ(Temp.get(), N->getOperand(0));
+ N->replaceOperandWith(0, Temp);
+ EXPECT_EQ(Temp, N->getOperand(0));
// Remove the references to Temp; required for teardown.
Temp->replaceAllUsesWith(nullptr);
+ MDNode::deleteTemporary(Temp);
}
typedef MetadataTest MDLocationTest;
@@ -551,11 +549,11 @@ TEST_F(ValueAsMetadataTest, CollidingDoubleUpdates) {
ConstantInt::get(getGlobalContext(), APInt(8, 0)));
// Create a temporary to prevent nodes from resolving.
- std::unique_ptr<MDNodeFwdDecl> Temp(MDNode::getTemporary(Context, None));
+ MDTuple *Temp = MDTuple::getTemporary(Context, None);
// When the first operand of N1 gets reset to nullptr, it'll collide with N2.
- Metadata *Ops1[] = {CI, CI, Temp.get()};
- Metadata *Ops2[] = {nullptr, CI, Temp.get()};
+ Metadata *Ops1[] = {CI, CI, Temp};
+ Metadata *Ops2[] = {nullptr, CI, Temp};
auto *N1 = MDTuple::get(Context, Ops1);
auto *N2 = MDTuple::get(Context, Ops2);
@@ -567,10 +565,11 @@ TEST_F(ValueAsMetadataTest, CollidingDoubleUpdates) {
ValueAsMetadata::handleDeletion(CI->getValue());
EXPECT_EQ(nullptr, N2->getOperand(0));
EXPECT_EQ(nullptr, N2->getOperand(1));
- EXPECT_EQ(Temp.get(), N2->getOperand(2));
+ EXPECT_EQ(Temp, N2->getOperand(2));
// Clean up Temp for teardown.
Temp->replaceAllUsesWith(nullptr);
+ MDNode::deleteTemporary(Temp);
}
typedef MetadataTest TrackingMDRefTest;
OpenPOWER on IntegriCloud