Verifier: Start recursing into !dbg attachments
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 24 Mar 2015 17:32:19 +0000 (17:32 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 24 Mar 2015 17:32:19 +0000 (17:32 +0000)
The main verifier already recurses through the other entry points, so we
might as well descend here too.

This temporarily duplicates some work already done in
`verifyDebugInfo()`, but eventually I'll be removing the other side.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233095 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp
test/Verifier/dbg.ll

index d5a5afa0c402d8ce23d81a0cc79709bc773a5c55..5f25891f2b1ce47403813e040a56ff231176e769 100644 (file)
@@ -2567,11 +2567,9 @@ void Verifier::visitInstruction(Instruction &I) {
            &I);
   }
 
-  // Don't recurse into !dbg attachments (leave that for verifyDebugInfo()),
-  // but at least check that it's a legal type.
   if (MDNode *N = I.getDebugLoc().getAsMDNode()) {
-    Assert(isa<MDLocation>(N),
-           "invalid !dbg metadata attachment", &I, N);
+    Assert(isa<MDLocation>(N), "invalid !dbg metadata attachment", &I, N);
+    visitMDNode(*N);
   }
 
   InstsInThisBlock.insert(&I);
index 20b80ff2efe2f064bc8d531af6d1a1a2fa92e289..3cff1e0515767d3c0f3e7d1f3a826b49acfa01b1 100644 (file)
@@ -1,12 +1,18 @@
 ; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
 
 define void @foo() {
-  ret void, !dbg !{}
-}
+entry:
+  br label %exit, !dbg !MDLocation(scope: !MDSubprogram(), inlinedAt: !{})
+; CHECK: inlined-at should be a location
+; CHECK-NEXT: !{{[0-9]+}} = !MDLocation(line: 0, scope: !{{[0-9]+}}, inlinedAt: ![[IA:[0-9]+]])
+; CHECK-NEXT: ![[IA]] = !{}
 
+exit:
+  ret void, !dbg !{}
 ; CHECK: invalid !dbg metadata attachment
 ; CHECK-NEXT: ret void, !dbg ![[LOC:[0-9]+]]
 ; CHECK-NEXT: ![[LOC]] = !{}
+}
 
 !llvm.module.flags = !{!0}
 !0 = !{i32 2, !"Debug Info Version", i32 3}