1 //===- llvm/unittest/IR/Metadata.cpp - Metadata unit tests ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/IR/Constants.h"
12 #include "llvm/IR/Instructions.h"
13 #include "llvm/IR/LLVMContext.h"
14 #include "llvm/IR/Metadata.h"
15 #include "llvm/IR/Module.h"
16 #include "llvm/IR/Type.h"
17 #include "llvm/Support/raw_ostream.h"
18 #include "gtest/gtest.h"
23 TEST(ContextAndReplaceableUsesTest, FromContext) {
25 ContextAndReplaceableUses CRU(Context);
26 EXPECT_EQ(&Context, &CRU.getContext());
27 EXPECT_FALSE(CRU.hasReplaceableUses());
28 EXPECT_FALSE(CRU.getReplaceableUses());
31 TEST(ContextAndReplaceableUsesTest, FromReplaceableUses) {
33 ContextAndReplaceableUses CRU(make_unique<ReplaceableMetadataImpl>(Context));
34 EXPECT_EQ(&Context, &CRU.getContext());
35 EXPECT_TRUE(CRU.hasReplaceableUses());
36 EXPECT_TRUE(CRU.getReplaceableUses());
39 TEST(ContextAndReplaceableUsesTest, makeReplaceable) {
41 ContextAndReplaceableUses CRU(Context);
42 CRU.makeReplaceable(make_unique<ReplaceableMetadataImpl>(Context));
43 EXPECT_EQ(&Context, &CRU.getContext());
44 EXPECT_TRUE(CRU.hasReplaceableUses());
45 EXPECT_TRUE(CRU.getReplaceableUses());
48 TEST(ContextAndReplaceableUsesTest, takeReplaceableUses) {
50 auto ReplaceableUses = make_unique<ReplaceableMetadataImpl>(Context);
51 auto *Ptr = ReplaceableUses.get();
52 ContextAndReplaceableUses CRU(std::move(ReplaceableUses));
53 ReplaceableUses = CRU.takeReplaceableUses();
54 EXPECT_EQ(&Context, &CRU.getContext());
55 EXPECT_FALSE(CRU.hasReplaceableUses());
56 EXPECT_FALSE(CRU.getReplaceableUses());
57 EXPECT_EQ(Ptr, ReplaceableUses.get());
60 class MetadataTest : public testing::Test {
63 MDNode *getNode() { return MDNode::get(Context, None); }
64 MDNode *getNode(Metadata *MD) { return MDNode::get(Context, MD); }
65 MDNode *getNode(Metadata *MD1, Metadata *MD2) {
66 Metadata *MDs[] = {MD1, MD2};
67 return MDNode::get(Context, MDs);
70 typedef MetadataTest MDStringTest;
72 // Test that construction of MDString with different value produces different
73 // MDString objects, even with the same string pointer and nulls in the string.
74 TEST_F(MDStringTest, CreateDifferent) {
75 char x[3] = { 'f', 0, 'A' };
76 MDString *s1 = MDString::get(Context, StringRef(&x[0], 3));
78 MDString *s2 = MDString::get(Context, StringRef(&x[0], 3));
82 // Test that creation of MDStrings with the same string contents produces the
83 // same MDString object, even with different pointers.
84 TEST_F(MDStringTest, CreateSame) {
85 char x[4] = { 'a', 'b', 'c', 'X' };
86 char y[4] = { 'a', 'b', 'c', 'Y' };
88 MDString *s1 = MDString::get(Context, StringRef(&x[0], 3));
89 MDString *s2 = MDString::get(Context, StringRef(&y[0], 3));
93 // Test that MDString prints out the string we fed it.
94 TEST_F(MDStringTest, PrintingSimple) {
95 char *str = new char[13];
96 strncpy(str, "testing 1 2 3", 13);
97 MDString *s = MDString::get(Context, StringRef(str, 13));
98 strncpy(str, "aaaaaaaaaaaaa", 13);
102 raw_string_ostream oss(Str);
104 EXPECT_STREQ("!\"testing 1 2 3\"", oss.str().c_str());
107 // Test printing of MDString with non-printable characters.
108 TEST_F(MDStringTest, PrintingComplex) {
109 char str[5] = {0, '\n', '"', '\\', (char)-1};
110 MDString *s = MDString::get(Context, StringRef(str+0, 5));
112 raw_string_ostream oss(Str);
114 EXPECT_STREQ("!\"\\00\\0A\\22\\5C\\FF\"", oss.str().c_str());
117 typedef MetadataTest MDNodeTest;
119 // Test the two constructors, and containing other Constants.
120 TEST_F(MDNodeTest, Simple) {
121 char x[3] = { 'a', 'b', 'c' };
122 char y[3] = { '1', '2', '3' };
124 MDString *s1 = MDString::get(Context, StringRef(&x[0], 3));
125 MDString *s2 = MDString::get(Context, StringRef(&y[0], 3));
126 ConstantAsMetadata *CI = ConstantAsMetadata::get(
127 ConstantInt::get(getGlobalContext(), APInt(8, 0)));
129 std::vector<Metadata *> V;
134 MDNode *n1 = MDNode::get(Context, V);
135 Metadata *const c1 = n1;
136 MDNode *n2 = MDNode::get(Context, c1);
137 Metadata *const c2 = n2;
138 MDNode *n3 = MDNode::get(Context, V);
139 MDNode *n4 = MDNode::getIfExists(Context, V);
140 MDNode *n5 = MDNode::getIfExists(Context, c1);
141 MDNode *n6 = MDNode::getIfExists(Context, c2);
146 EXPECT_EQ(n6, (Metadata *)nullptr);
148 EXPECT_EQ(3u, n1->getNumOperands());
149 EXPECT_EQ(s1, n1->getOperand(0));
150 EXPECT_EQ(CI, n1->getOperand(1));
151 EXPECT_EQ(s2, n1->getOperand(2));
153 EXPECT_EQ(1u, n2->getNumOperands());
154 EXPECT_EQ(n1, n2->getOperand(0));
157 TEST_F(MDNodeTest, Delete) {
158 Constant *C = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 1);
159 Instruction *I = new BitCastInst(C, Type::getInt32Ty(getGlobalContext()));
161 Metadata *const V = LocalAsMetadata::get(I);
162 MDNode *n = MDNode::get(Context, V);
163 TrackingMDRef wvh(n);
170 TEST_F(MDNodeTest, DeleteMDNodeFwdDecl) {
171 delete MDNode::getTemporary(Context, None);
174 TEST_F(MDNodeTest, SelfReference) {
178 MDNode *Temp = MDNode::getTemporary(Context, None);
179 Metadata *Args[] = {Temp};
180 MDNode *Self = MDNode::get(Context, Args);
181 Self->replaceOperandWith(0, Self);
182 MDNode::deleteTemporary(Temp);
183 ASSERT_EQ(Self, Self->getOperand(0));
185 // Self-references should be distinct, so MDNode::get() should grab a
186 // uniqued node that references Self, not Self.
188 MDNode *Ref1 = MDNode::get(Context, Args);
189 MDNode *Ref2 = MDNode::get(Context, Args);
190 EXPECT_NE(Self, Ref1);
191 EXPECT_EQ(Ref1, Ref2);
197 MDNode *Temp = MDNode::getTemporary(Context, None);
198 Metadata *Args[] = {Temp, MDNode::get(Context, None)};
199 MDNode *Self = MDNode::get(Context, Args);
200 Self->replaceOperandWith(0, Self);
201 MDNode::deleteTemporary(Temp);
202 ASSERT_EQ(Self, Self->getOperand(0));
204 // Self-references should be distinct, so MDNode::get() should grab a
205 // uniqued node that references Self, not Self itself.
207 MDNode *Ref1 = MDNode::get(Context, Args);
208 MDNode *Ref2 = MDNode::get(Context, Args);
209 EXPECT_NE(Self, Ref1);
210 EXPECT_EQ(Ref1, Ref2);
214 TEST_F(MDNodeTest, Print) {
215 Constant *C = ConstantInt::get(Type::getInt32Ty(Context), 7);
216 MDString *S = MDString::get(Context, "foo");
217 MDNode *N0 = getNode();
218 MDNode *N1 = getNode(N0);
219 MDNode *N2 = getNode(N0, N1);
221 Metadata *Args[] = {ConstantAsMetadata::get(C), S, nullptr, N0, N1, N2};
222 MDNode *N = MDNode::get(Context, Args);
224 std::string Expected;
226 raw_string_ostream OS(Expected);
228 C->printAsOperand(OS);
230 S->printAsOperand(OS);
232 MDNode *Nodes[] = {N0, N1, N2};
233 for (auto *Node : Nodes)
234 OS << ", <" << (void *)Node << ">";
240 raw_string_ostream OS(Actual);
244 EXPECT_EQ(Expected, Actual);
247 TEST_F(MDNodeTest, NullOperand) {
249 MDNode *Empty = MDNode::get(Context, None);
251 // metadata !{metadata !{}}
252 Metadata *Ops[] = {Empty};
253 MDNode *N = MDNode::get(Context, Ops);
254 ASSERT_EQ(Empty, N->getOperand(0));
256 // metadata !{metadata !{}} => metadata !{null}
257 N->replaceOperandWith(0, nullptr);
258 ASSERT_EQ(nullptr, N->getOperand(0));
262 MDNode *NullOp = MDNode::get(Context, Ops);
263 ASSERT_EQ(nullptr, NullOp->getOperand(0));
264 EXPECT_EQ(N, NullOp);
267 TEST_F(MDNodeTest, DistinctOnUniquingCollision) {
269 MDNode *Empty = MDNode::get(Context, None);
270 ASSERT_TRUE(Empty->isResolved());
271 EXPECT_FALSE(Empty->isDistinct());
274 Metadata *Wrapped1Ops[] = {Empty};
275 MDNode *Wrapped1 = MDNode::get(Context, Wrapped1Ops);
276 ASSERT_EQ(Empty, Wrapped1->getOperand(0));
277 ASSERT_TRUE(Wrapped1->isResolved());
278 EXPECT_FALSE(Wrapped1->isDistinct());
281 Metadata *Wrapped2Ops[] = {Wrapped1};
282 MDNode *Wrapped2 = MDNode::get(Context, Wrapped2Ops);
283 ASSERT_EQ(Wrapped1, Wrapped2->getOperand(0));
284 ASSERT_TRUE(Wrapped2->isResolved());
285 EXPECT_FALSE(Wrapped2->isDistinct());
287 // !{!{!{}}} => !{!{}}
288 Wrapped2->replaceOperandWith(0, Empty);
289 ASSERT_EQ(Empty, Wrapped2->getOperand(0));
290 EXPECT_TRUE(Wrapped2->isDistinct());
291 EXPECT_FALSE(Wrapped1->isDistinct());
294 TEST_F(MDNodeTest, getDistinct) {
296 MDNode *Empty = MDNode::get(Context, None);
297 ASSERT_TRUE(Empty->isResolved());
298 ASSERT_FALSE(Empty->isDistinct());
299 ASSERT_EQ(Empty, MDNode::get(Context, None));
302 MDNode *Distinct1 = MDNode::getDistinct(Context, None);
303 MDNode *Distinct2 = MDNode::getDistinct(Context, None);
304 EXPECT_TRUE(Distinct1->isResolved());
305 EXPECT_TRUE(Distinct2->isDistinct());
306 EXPECT_NE(Empty, Distinct1);
307 EXPECT_NE(Empty, Distinct2);
308 EXPECT_NE(Distinct1, Distinct2);
311 ASSERT_EQ(Empty, MDNode::get(Context, None));
314 TEST_F(MDNodeTest, isUniqued) {
315 MDNode *U = MDTuple::get(Context, None);
316 MDNode *D = MDTuple::getDistinct(Context, None);
317 MDNode *T = MDTuple::getTemporary(Context, None);
318 EXPECT_TRUE(U->isUniqued());
319 EXPECT_FALSE(D->isUniqued());
320 EXPECT_FALSE(T->isUniqued());
321 MDNode::deleteTemporary(T);
324 TEST_F(MDNodeTest, isDistinct) {
325 MDNode *U = MDTuple::get(Context, None);
326 MDNode *D = MDTuple::getDistinct(Context, None);
327 MDNode *T = MDTuple::getTemporary(Context, None);
328 EXPECT_FALSE(U->isDistinct());
329 EXPECT_TRUE(D->isDistinct());
330 EXPECT_FALSE(T->isDistinct());
331 MDNode::deleteTemporary(T);
334 TEST_F(MDNodeTest, isTemporary) {
335 MDNode *U = MDTuple::get(Context, None);
336 MDNode *D = MDTuple::getDistinct(Context, None);
337 MDNode *T = MDTuple::getTemporary(Context, None);
338 EXPECT_FALSE(U->isTemporary());
339 EXPECT_FALSE(D->isTemporary());
340 EXPECT_TRUE(T->isTemporary());
341 MDNode::deleteTemporary(T);
344 TEST_F(MDNodeTest, getDistinctWithUnresolvedOperands) {
346 MDNodeFwdDecl *Temp = MDNode::getTemporary(Context, None);
347 ASSERT_FALSE(Temp->isResolved());
349 // distinct !{temporary !{}}
350 Metadata *Ops[] = {Temp};
351 MDNode *Distinct = MDNode::getDistinct(Context, Ops);
352 EXPECT_TRUE(Distinct->isResolved());
353 EXPECT_EQ(Temp, Distinct->getOperand(0));
355 // temporary !{} => !{}
356 MDNode *Empty = MDNode::get(Context, None);
357 Temp->replaceAllUsesWith(Empty);
358 MDNode::deleteTemporary(Temp);
359 EXPECT_EQ(Empty, Distinct->getOperand(0));
362 TEST_F(MDNodeTest, handleChangedOperandRecursion) {
364 MDNode *N0 = MDNode::get(Context, None);
367 std::unique_ptr<MDNodeFwdDecl> Temp3(MDNode::getTemporary(Context, None));
368 Metadata *Ops1[] = {Temp3.get(), nullptr};
369 MDNode *N1 = MDNode::get(Context, Ops1);
372 Metadata *Ops2[] = {Temp3.get(), N0};
373 MDNode *N2 = MDNode::get(Context, Ops2);
376 Metadata *Ops3[] = {N2};
377 MDNode *N3 = MDNode::get(Context, Ops3);
378 Temp3->replaceAllUsesWith(N3);
381 Metadata *Ops4[] = {N1};
382 MDNode *N4 = MDNode::get(Context, Ops4);
384 // Confirm that the cycle prevented RAUW from getting dropped.
385 EXPECT_TRUE(N0->isResolved());
386 EXPECT_FALSE(N1->isResolved());
387 EXPECT_FALSE(N2->isResolved());
388 EXPECT_FALSE(N3->isResolved());
389 EXPECT_FALSE(N4->isResolved());
391 // Create a couple of distinct nodes to observe what's going on.
393 // !5 = distinct !{!2}
394 // !6 = distinct !{!3}
395 Metadata *Ops5[] = {N2};
396 MDNode *N5 = MDNode::getDistinct(Context, Ops5);
397 Metadata *Ops6[] = {N3};
398 MDNode *N6 = MDNode::getDistinct(Context, Ops6);
400 // Mutate !2 to look like !1, causing a uniquing collision (and an RAUW).
401 // This will ripple up, with !3 colliding with !4, and RAUWing. Since !2
402 // references !3, this can cause a re-entry of handleChangedOperand() when !3
403 // is not ready for it.
405 // !2->replaceOperandWith(1, nullptr)
406 // !2: !{!3, !0} => !{!3, null}
407 // !2->replaceAllUsesWith(!1)
408 // !3: !{!2] => !{!1}
409 // !3->replaceAllUsesWith(!4)
410 N2->replaceOperandWith(1, nullptr);
412 // If all has gone well, N2 and N3 will have been RAUW'ed and deleted from
413 // under us. Just check that the other nodes are sane.
417 // !5 = distinct !{!1}
418 // !6 = distinct !{!4}
419 EXPECT_EQ(N4, N1->getOperand(0));
420 EXPECT_EQ(N1, N4->getOperand(0));
421 EXPECT_EQ(N1, N5->getOperand(0));
422 EXPECT_EQ(N4, N6->getOperand(0));
425 TEST_F(MDNodeTest, replaceResolvedOperand) {
426 // Check code for replacing one resolved operand with another. If doing this
427 // directly (via replaceOperandWith()) becomes illegal, change the operand to
428 // a global value that gets RAUW'ed.
430 // Use a temporary node to keep N from being resolved.
431 std::unique_ptr<MDNodeFwdDecl> Temp(MDNodeFwdDecl::get(Context, None));
432 Metadata *Ops[] = {nullptr, Temp.get()};
434 MDNode *Empty = MDTuple::get(Context, ArrayRef<Metadata *>());
435 MDNode *N = MDTuple::get(Context, Ops);
436 EXPECT_EQ(nullptr, N->getOperand(0));
437 ASSERT_FALSE(N->isResolved());
439 // Check code for replacing resolved nodes.
440 N->replaceOperandWith(0, Empty);
441 EXPECT_EQ(Empty, N->getOperand(0));
443 // Check code for adding another unresolved operand.
444 N->replaceOperandWith(0, Temp.get());
445 EXPECT_EQ(Temp.get(), N->getOperand(0));
447 // Remove the references to Temp; required for teardown.
448 Temp->replaceAllUsesWith(nullptr);
451 typedef MetadataTest MDLocationTest;
453 TEST_F(MDLocationTest, Overflow) {
454 MDNode *N = MDNode::get(Context, None);
456 MDLocation *L = MDLocation::get(Context, 2, 7, N);
457 EXPECT_EQ(2u, L->getLine());
458 EXPECT_EQ(7u, L->getColumn());
460 unsigned U24 = 1u << 24;
461 unsigned U16 = 1u << 16;
463 MDLocation *L = MDLocation::get(Context, U24 - 1, U16 - 1, N);
464 EXPECT_EQ(U24 - 1, L->getLine());
465 EXPECT_EQ(U16 - 1, L->getColumn());
468 MDLocation *L = MDLocation::get(Context, U24, U16, N);
469 EXPECT_EQ(0u, L->getLine());
470 EXPECT_EQ(0u, L->getColumn());
473 MDLocation *L = MDLocation::get(Context, U24 + 1, U16 + 1, N);
474 EXPECT_EQ(0u, L->getLine());
475 EXPECT_EQ(0u, L->getColumn());
479 TEST_F(MDLocationTest, getDistinct) {
480 MDNode *N = MDNode::get(Context, None);
481 MDLocation *L0 = MDLocation::getDistinct(Context, 2, 7, N);
482 EXPECT_TRUE(L0->isDistinct());
483 MDLocation *L1 = MDLocation::get(Context, 2, 7, N);
484 EXPECT_FALSE(L1->isDistinct());
485 EXPECT_EQ(L1, MDLocation::get(Context, 2, 7, N));
488 typedef MetadataTest MetadataAsValueTest;
490 TEST_F(MetadataAsValueTest, MDNode) {
491 MDNode *N = MDNode::get(Context, None);
492 auto *V = MetadataAsValue::get(Context, N);
493 EXPECT_TRUE(V->getType()->isMetadataTy());
494 EXPECT_EQ(N, V->getMetadata());
496 auto *V2 = MetadataAsValue::get(Context, N);
500 TEST_F(MetadataAsValueTest, MDNodeMDNode) {
501 MDNode *N = MDNode::get(Context, None);
502 Metadata *Ops[] = {N};
503 MDNode *N2 = MDNode::get(Context, Ops);
504 auto *V = MetadataAsValue::get(Context, N2);
505 EXPECT_TRUE(V->getType()->isMetadataTy());
506 EXPECT_EQ(N2, V->getMetadata());
508 auto *V2 = MetadataAsValue::get(Context, N2);
511 auto *V3 = MetadataAsValue::get(Context, N);
512 EXPECT_TRUE(V3->getType()->isMetadataTy());
514 EXPECT_EQ(N, V3->getMetadata());
517 TEST_F(MetadataAsValueTest, MDNodeConstant) {
518 auto *C = ConstantInt::getTrue(Context);
519 auto *MD = ConstantAsMetadata::get(C);
520 Metadata *Ops[] = {MD};
521 auto *N = MDNode::get(Context, Ops);
523 auto *V = MetadataAsValue::get(Context, MD);
524 EXPECT_TRUE(V->getType()->isMetadataTy());
525 EXPECT_EQ(MD, V->getMetadata());
527 auto *V2 = MetadataAsValue::get(Context, N);
528 EXPECT_EQ(MD, V2->getMetadata());
532 typedef MetadataTest ValueAsMetadataTest;
534 TEST_F(ValueAsMetadataTest, UpdatesOnRAUW) {
535 Type *Ty = Type::getInt1PtrTy(Context);
536 std::unique_ptr<GlobalVariable> GV0(
537 new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
538 auto *MD = ValueAsMetadata::get(GV0.get());
539 EXPECT_TRUE(MD->getValue() == GV0.get());
540 ASSERT_TRUE(GV0->use_empty());
542 std::unique_ptr<GlobalVariable> GV1(
543 new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
544 GV0->replaceAllUsesWith(GV1.get());
545 EXPECT_TRUE(MD->getValue() == GV1.get());
548 TEST_F(ValueAsMetadataTest, CollidingDoubleUpdates) {
549 // Create a constant.
550 ConstantAsMetadata *CI = ConstantAsMetadata::get(
551 ConstantInt::get(getGlobalContext(), APInt(8, 0)));
553 // Create a temporary to prevent nodes from resolving.
554 std::unique_ptr<MDNodeFwdDecl> Temp(MDNode::getTemporary(Context, None));
556 // When the first operand of N1 gets reset to nullptr, it'll collide with N2.
557 Metadata *Ops1[] = {CI, CI, Temp.get()};
558 Metadata *Ops2[] = {nullptr, CI, Temp.get()};
560 auto *N1 = MDTuple::get(Context, Ops1);
561 auto *N2 = MDTuple::get(Context, Ops2);
564 // Tell metadata that the constant is getting deleted.
566 // After this, N1 will be invalid, so don't touch it.
567 ValueAsMetadata::handleDeletion(CI->getValue());
568 EXPECT_EQ(nullptr, N2->getOperand(0));
569 EXPECT_EQ(nullptr, N2->getOperand(1));
570 EXPECT_EQ(Temp.get(), N2->getOperand(2));
572 // Clean up Temp for teardown.
573 Temp->replaceAllUsesWith(nullptr);
576 typedef MetadataTest TrackingMDRefTest;
578 TEST_F(TrackingMDRefTest, UpdatesOnRAUW) {
579 Type *Ty = Type::getInt1PtrTy(Context);
580 std::unique_ptr<GlobalVariable> GV0(
581 new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
582 TypedTrackingMDRef<ValueAsMetadata> MD(ValueAsMetadata::get(GV0.get()));
583 EXPECT_TRUE(MD->getValue() == GV0.get());
584 ASSERT_TRUE(GV0->use_empty());
586 std::unique_ptr<GlobalVariable> GV1(
587 new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
588 GV0->replaceAllUsesWith(GV1.get());
589 EXPECT_TRUE(MD->getValue() == GV1.get());
591 // Reset it, so we don't inadvertently test deletion.
595 TEST_F(TrackingMDRefTest, UpdatesOnDeletion) {
596 Type *Ty = Type::getInt1PtrTy(Context);
597 std::unique_ptr<GlobalVariable> GV(
598 new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
599 TypedTrackingMDRef<ValueAsMetadata> MD(ValueAsMetadata::get(GV.get()));
600 EXPECT_TRUE(MD->getValue() == GV.get());
601 ASSERT_TRUE(GV->use_empty());
607 TEST(NamedMDNodeTest, Search) {
609 ConstantAsMetadata *C =
610 ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(Context), 1));
611 ConstantAsMetadata *C2 =
612 ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(Context), 2));
614 Metadata *const V = C;
615 Metadata *const V2 = C2;
616 MDNode *n = MDNode::get(Context, V);
617 MDNode *n2 = MDNode::get(Context, V2);
619 Module M("MyModule", Context);
620 const char *Name = "llvm.NMD1";
621 NamedMDNode *NMD = M.getOrInsertNamedMetadata(Name);
626 raw_string_ostream oss(Str);
628 EXPECT_STREQ("!llvm.NMD1 = !{!0, !1}\n",