Debug Info: enable verifying by default and disable testing cases that fail.
authorManman Ren <mren@apple.com>
Fri, 19 Jul 2013 00:31:03 +0000 (00:31 +0000)
committerManman Ren <mren@apple.com>
Fri, 19 Jul 2013 00:31:03 +0000 (00:31 +0000)
1> Use DebugInfoFinder to find debug info MDNodes.
2> Add disable-debug-info-verifier to disable verifying debug info.
3> Disable verifying for testing cases that fail (will update the testing cases
   later on).
4> MDNodes generated by clang can have empty filename for TAG_inheritance and
   TAG_friend, so DIType::Verify is modified accordingly.

Note that DebugInfoFinder does not list all debug info MDNode.
For example, clang can generate:
metadata !{i32 786468}, which will fail to verify.
This MDNode is used by debug info but not included in DebugInfoFinder.
This MDNode is generated as a temporary node in DIBuilder::createFunction
  Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
  MDNode::getTemporary(VMContext, TElts)

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

17 files changed:
lib/IR/DebugInfo.cpp
lib/IR/Verifier.cpp
test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
test/CodeGen/X86/2010-08-04-StackVariable.ll
test/CodeGen/X86/dbg-i128-const.ll
test/CodeGen/X86/dbg-subrange.ll
test/CodeGen/X86/dbg-value-dag-combine.ll
test/CodeGen/X86/dbg-value-isel.ll
test/CodeGen/X86/dbg-value-location.ll
test/DebugInfo/2010-04-06-NestedFnDbgInfo.ll
test/DebugInfo/2010-04-19-FramePtr.ll
test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll
test/DebugInfo/X86/2011-12-16-BadStructRef.ll
test/DebugInfo/X86/dbg-value-inlined-parameter.ll
test/DebugInfo/X86/linkage-name.ll
test/DebugInfo/X86/low-pc-cu.ll
test/DebugInfo/X86/multiple-at-const-val.ll

index 25d4ea4fc2aa38ee37b832430586b9a06d20afa7..19de7811773d60f21ab2b93e94a9897974ae3bc8 100644 (file)
@@ -459,6 +459,8 @@ bool DIType::Verify() const {
       Tag != dwarf::DW_TAG_array_type &&
       Tag != dwarf::DW_TAG_enumeration_type &&
       Tag != dwarf::DW_TAG_subroutine_type &&
+      Tag != dwarf::DW_TAG_inheritance &&
+      Tag != dwarf::DW_TAG_friend &&
       getFilename().empty())
     return false;
   return true;
index 420bc1507e6681c5f4820db50e2edb8c32d915a1..6a7f45f6287f2d346e634333b0e10c146de0fb79 100644 (file)
@@ -53,6 +53,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Assembly/Writer.h"
+#include "llvm/DebugInfo.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
@@ -66,6 +67,7 @@
 #include "llvm/PassManager.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/CallSite.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConstantRange.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -74,6 +76,9 @@
 #include <cstdarg>
 using namespace llvm;
 
+static cl::opt<bool> DisableDebugInfoVerifier("disable-debug-info-verifier",
+                                              cl::init(false));
+
 namespace {  // Anonymous namespace for class
   struct PreVerifier : public FunctionPass {
     static char ID; // Pass ID, replacement for typeid
@@ -202,6 +207,9 @@ namespace {
 
       visitModuleFlags(M);
 
+      // Verify Debug Info.
+      verifyDebugInfo(M);
+
       // If the module is broken, abort at this time.
       return abortIfBroken();
     }
@@ -309,6 +317,8 @@ namespace {
     void VerifyFunctionAttrs(FunctionType *FT, AttributeSet Attrs,
                              const Value *V);
 
+    void verifyDebugInfo(Module &M);
+
     void WriteValue(const Value *V) {
       if (!V) return;
       if (isa<Instruction>(V)) {
@@ -2185,6 +2195,28 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
   }
 }
 
+void Verifier::verifyDebugInfo(Module &M) {
+  // Verify Debug Info.
+  if (!DisableDebugInfoVerifier) {
+    DebugInfoFinder Finder;
+    Finder.processModule(M);
+
+    for (DebugInfoFinder::iterator I = Finder.compile_unit_begin(),
+         E = Finder.compile_unit_end(); I != E; ++I)
+      Assert1(DICompileUnit(*I).Verify(), "DICompileUnit does not Verify!", *I);
+    for (DebugInfoFinder::iterator I = Finder.subprogram_begin(),
+         E = Finder.subprogram_end(); I != E; ++I)
+      Assert1(DISubprogram(*I).Verify(), "DISubprogram does not Verify!", *I);
+    for (DebugInfoFinder::iterator I = Finder.global_variable_begin(),
+         E = Finder.global_variable_end(); I != E; ++I)
+      Assert1(DIGlobalVariable(*I).Verify(),
+              "DIGlobalVariable does not Verify!", *I);
+    for (DebugInfoFinder::iterator I = Finder.type_begin(),
+         E = Finder.type_end(); I != E; ++I)
+      Assert1(DIType(*I).Verify(), "DIType does not Verify!", *I);
+  }
+}
+
 //===----------------------------------------------------------------------===//
 //  Implement the public interfaces to this file...
 //===----------------------------------------------------------------------===//
index 6510ff17f7bb7672c95b4a7001dbad27c198a7b5..7bfea2bcb5f2e915f426385d787c383c5e71893f 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llc -O2 < %s | FileCheck %s
-; RUN: llc -O2 -regalloc=basic < %s | FileCheck %s
+; RUN: llc -O2 -disable-debug-info-verifier < %s | FileCheck %s
+; RUN: llc -O2 -disable-debug-info-verifier -regalloc=basic < %s | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-apple-darwin10"
 
index 5b5377cd53a9b86d40da2d349e4fae09dac6d56b..e285f5d3024f0f4bcb5b805e5afdbac0afc24012 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s | grep DW_OP_breg7
+; RUN: llc -O0 -mtriple=x86_64-apple-darwin -disable-debug-info-verifier < %s | grep DW_OP_breg7
 ; Use DW_OP_breg7 in variable's location expression if the variable is in a stack slot.
 
 %struct.SVal = type { i8*, i32 }
index cc612b2ca53e547eb3da03912fbbc6dfbe799f6a..8deec3509d3ffaa3d2292da7fcc77cfa45b2c5ed 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-linux -disable-debug-info-verifier < %s | FileCheck %s
 
 ; CHECK: DW_AT_const_value
 ; CHECK-NEXT: 42
index b08d68a6643d314766fb0ce5a33ca30b3c16636c..0dc97525290201ea63c5a4b5742f9e45e1366b5e 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -O0 < %s | FileCheck %s
+; RUN: llc -O0 -disable-debug-info-verifier < %s | FileCheck %s
 ; Radar 10464995
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.7.2"
index 7c3c361bae14f1bfac657eb7d07a1692c906f453..babc2164d7a04fabc98cf6bc153455e6cfc3791f 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -disable-debug-info-verifier < %s | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-apple-darwin10.0.0"
 ; PR 9817
index acc360e90cd23e4985354b0de145a9fc5fdcd7b4..16d9f891dbd77b2923ade1e1541d3cc754d2390e 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -disable-debug-info-verifier < %s | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-apple-darwin10.0.0"
 ; PR 9879
index a6c3e13621c90bb51ad18d73d8d5c54b2bd6ee74..b6bee596e145ff54e4fa176c85664a473acbd0a3 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llc < %s | FileCheck %s
-; RUN: llc < %s -regalloc=basic | FileCheck %s
+; RUN: llc -disable-debug-info-verifier < %s | FileCheck %s
+; RUN: llc -disable-debug-info-verifier < %s -regalloc=basic | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-apple-darwin10.0.0"
 ;Radar 8950491
index 7f8e418c9bd7b879d724ad386e3a1abe8a450012..9ca4616849caf93d55b511f52f972a15943108ff 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc -asm-verbose -O0 | grep AT_specification | count 2
+; RUN: llvm-as -disable-debug-info-verifier < %s | llc -asm-verbose -O0 -disable-debug-info-verifier | grep AT_specification | count 2
 ; Radar 7833483
 ; Do not emit AT_specification for nested function foo.
 
index 81e34d1b70d0bd4395a00f93e1e41e2d83c83b7c..5344ed4ce7b29fa3e330a3c268664adda0a3ebe6 100644 (file)
@@ -1,6 +1,6 @@
-; RUN: llc -asm-verbose -O1 -o %t < %s 
+; RUN: llc -disable-debug-info-verifier -asm-verbose -O1 -o %t < %s 
 ; RUN: grep DW_AT_APPLE_omit_frame_ptr %t
-; RUN: llc -disable-fp-elim -asm-verbose -O1 -o %t < %s 
+; RUN: llc -disable-debug-info-verifier -disable-fp-elim -asm-verbose -O1 -o %t < %s 
 ; RUN: grep -v DW_AT_APPLE_omit_frame_ptr %t
 
 
index 7b8d91456a54b82a112ca593210050fe9e3d7419..71bb650a0d81b657f20f5864f2fe2f45832f3991 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64-pc-linux-gnu %s -o %t -filetype=obj
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -disable-debug-info-verifier %s -o %t -filetype=obj
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
 
 ; ModuleID = 'test.c'
index 187a0f5abf9d17212b1d29fdd44cecaa2f8f6db0..a6b7811f8d8aadb32e39f05e184b19134bdb6c51 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64-apple-macosx10.7 %s -o %t -filetype=obj
+; RUN: llc -mtriple=x86_64-apple-macosx10.7 -disable-debug-info-verifier %s -o %t -filetype=obj
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
 
 ; CHECK: b_ref
index 6f4d3ab09da4b27f9263c6a05dfe391929868531..2ccb897f5781d28df8585c58cb47c7ed8383845f 100644 (file)
@@ -1,6 +1,6 @@
-; RUN: llc -mtriple=x86_64-apple-darwin %s -filetype=obj -o %t
+; RUN: llc -mtriple=x86_64-apple-darwin -disable-debug-info-verifier %s -filetype=obj -o %t
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
-; RUN: llc -mtriple=x86_64-apple-darwin -regalloc=basic %s -filetype=obj -o %t
+; RUN: llc -mtriple=x86_64-apple-darwin -disable-debug-info-verifier -regalloc=basic %s -filetype=obj -o %t
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
 
 ;CHECK: DW_TAG_inlined_subroutine
index c9bd2cfb5e8ef4ba516273512b654058e037b1c6..5ee4a604c416aa24be757272b29dca6a508a9cf4 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64-macosx -darwin-gdb-compat=Disable %s -o %t -filetype=obj
+; RUN: llc -mtriple=x86_64-macosx -disable-debug-info-verifier -darwin-gdb-compat=Disable %s -o %t -filetype=obj
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
 
 ; CHECK: DW_TAG_subprogram [9] *
index c080555193a1fb84f61019ead79c23a2d4b9547f..ee33e4be8c5c7b2f7edf462e310853d6e4dbd420 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
+; RUN: llc -mtriple=x86_64-apple-darwin -disable-debug-info-verifier %s -o %t -filetype=obj
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
 
 ; Check that we use DW_AT_low_pc
index 7779d1efe917d75c5a58d30e16337e3090460eff..a2dc94017db731f5e3cbc7246c22910ce3c1d8c7 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t
+; RUN: llc -O0 -disable-debug-info-verifier %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t
 ; RUN: llvm-dwarfdump %t | FileCheck %s
 
 ; rdar://13071590