From: Duncan P. N. Exon Smith <dexonsmith@apple.com>
Date: Tue, 24 Mar 2015 17:18:03 +0000 (+0000)
Subject: Verifier: !llvm.dbg.cu must point at compile units
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eeb2ba6d46e4da9af22dc715f82adae058378aa2;p=oota-llvm.git

Verifier: !llvm.dbg.cu must point at compile units

Duplicate this check from `verifyDebugInfo()`.

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

diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 4f0e3388d58..d5a5afa0c40 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -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);
   }
 }