llvm.org GIT mirror llvm / 4000afe
I noticed in passing that the Metadata getIfExists method was creating a new node and returning it if one didn't exist. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153798 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 8 years ago
2 changed file(s) with 11 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
204204 ID.AddPointer(Vals[i]);
205205
206206 void *InsertPoint;
207 MDNode *N = NULL;
208
209 if ((N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint)))
207 MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
208
209 if (N || !Insert)
210210 return N;
211
211
212212 bool isFunctionLocal = false;
213213 switch (FL) {
214214 case FL_Unknown:
8989 MDNode *n1 = MDNode::get(Context, V);
9090 Value *const c1 = n1;
9191 MDNode *n2 = MDNode::get(Context, c1);
92 Value *const c2 = n2;
9293 MDNode *n3 = MDNode::get(Context, V);
94 MDNode *n4 = MDNode::getIfExists(Context, V);
95 MDNode *n5 = MDNode::getIfExists(Context, c1);
96 MDNode *n6 = MDNode::getIfExists(Context, c2);
9397 EXPECT_NE(n1, n2);
9498 #ifdef ENABLE_MDNODE_UNIQUING
9599 EXPECT_EQ(n1, n3);
96100 #else
97101 (void) n3;
98102 #endif
103 EXPECT_EQ(n4, n1);
104 EXPECT_EQ(n5, n2);
105 EXPECT_EQ(n6, (Value*)0);
99106
100107 EXPECT_EQ(3u, n1->getNumOperands());
101108 EXPECT_EQ(s1, n1->getOperand(0));