Add a unit test for r259973.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260111 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adrian Prantl 2016-02-08 17:02:34 +00:00
parent b21e2903ef
commit c44fb84ad0

View File

@ -2073,6 +2073,26 @@ TEST_F(ValueAsMetadataTest, UpdatesOnRAUW) {
EXPECT_TRUE(MD->getValue() == GV1.get());
}
TEST_F(ValueAsMetadataTest, TempTempReplacement) {
// Create a constant.
ConstantAsMetadata *CI = ConstantAsMetadata::get(
ConstantInt::get(getGlobalContext(), APInt(8, 0)));
Metadata *Ops1[] = {CI};
auto Temp1 = MDTuple::getTemporary(Context, None);
auto Temp2 = MDTuple::getTemporary(Context, Ops1);
Metadata *Ops2[] = {Temp1.get()};
auto *N = MDTuple::get(Context, Ops2);
// Test replacing a temporary node with another temporary node.
Temp1->replaceAllUsesWith(Temp2.get());
EXPECT_EQ(N->getOperand(0), Temp2.get());
// Clean up Temp2 for teardown.
Temp2->replaceAllUsesWith(nullptr);
}
TEST_F(ValueAsMetadataTest, CollidingDoubleUpdates) {
// Create a constant.
ConstantAsMetadata *CI = ConstantAsMetadata::get(