Verifier: !llvm.dbg.cu must point at compile units
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 24 Mar 2015 17:18:03 +0000 (17:18 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 24 Mar 2015 17:18:03 +0000 (17:18 +0000)
Duplicate this check from `verifyDebugInfo()`.

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

lib/IR/Verifier.cpp

index 4f0e3388d58a39154dfe2b05a4fe934f945d45c8..d5a5afa0c402d8ce23d81a0cc79709bc773a5c55 100644 (file)
@@ -111,6 +111,13 @@ private:
     OS << '\n';
   }
 
+  void Write(const NamedMDNode *NMD) {
+    if (!NMD)
+      return;
+    NMD->print(OS);
+    OS << '\n';
+  }
+
   void Write(Type *T) {
     if (!T)
       return;
@@ -562,6 +569,10 @@ void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
     if (!MD)
       continue;
 
+    if (NMD.getName() == "llvm.dbg.cu") {
+      Assert(isa<MDCompileUnit>(MD), "invalid compile unit", &NMD, MD);
+    }
+
     visitMDNode(*MD);
   }
 }