Add a debug info code generation level to the compile unit metadata
authorEric Christopher <echristo@gmail.com>
Thu, 27 Feb 2014 01:24:56 +0000 (01:24 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 27 Feb 2014 01:24:56 +0000 (01:24 +0000)
and update everything accordingly. This can be used to conditionalize
the amount of output in the backend based on the amount of debug
requested/metadata emission scheme by a front end (e.g. clang).

Paired with a commit to clang.

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

include/llvm/DIBuilder.h
include/llvm/DebugInfo.h
lib/IR/DIBuilder.cpp
lib/IR/DebugInfo.cpp
test/DebugInfo/2010-03-19-DbgDeclare.ll
test/Transforms/StripSymbols/2010-08-25-crash.ll
test/Transforms/StripSymbols/strip-dead-debug-info.ll

index 0afa9ab58005fa8d1ae1ac910903c975d8f2a8a5..d47bae5fc60569f8ae4f3d4d674abae14e3e925d 100644 (file)
@@ -87,6 +87,7 @@ namespace llvm {
     public:
     explicit DIBuilder(Module &M);
     enum ComplexAddrKind { OpPlus=1, OpDeref };
+    enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
 
     /// finalize - Construct any deferred debug info descriptors.
     void finalize();
@@ -111,7 +112,8 @@ namespace llvm {
                                     StringRef Dir, StringRef Producer,
                                     bool isOptimized, StringRef Flags,
                                     unsigned RV,
-                                    StringRef SplitName = StringRef());
+                                    StringRef SplitName = StringRef(),
+                                    DebugEmissionKind Kind = FullDebug);
 
     /// createFile - Create a file descriptor to hold debugging information
     /// for a file.
index ccf62ffb8157a4b04acc3494caf0616b8ea7bb84..930f7eba6724151cd1ef6076cbb452965e996069 100644 (file)
@@ -427,6 +427,7 @@ public:
   DIArray getImportedEntities() const;
 
   StringRef getSplitDebugFilename() const { return getStringField(12); }
+  unsigned getEmissionKind() const { return getUnsignedField(13); }
 
   /// Verify - Verify that a compile unit is well formed.
   bool Verify() const;
index fc80ba9e64a9a5d868abac280891a966bbd9936b..4bb75bdb0dfb4c20e31b255bc0016918bb65788c 100644 (file)
@@ -97,7 +97,9 @@ DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
                                            StringRef Directory,
                                            StringRef Producer, bool isOptimized,
                                            StringRef Flags, unsigned RunTimeVer,
-                                           StringRef SplitName) {
+                                           StringRef SplitName,
+                                           DebugEmissionKind Kind) {
+
   assert(((Lang <= dwarf::DW_LANG_Python && Lang >= dwarf::DW_LANG_C89) ||
           (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
          "Invalid Language tag");
@@ -127,7 +129,8 @@ DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
     TempSubprograms,
     TempGVs,
     TempImportedModules,
-    MDString::get(VMContext, SplitName)
+    MDString::get(VMContext, SplitName),
+    ConstantInt::get(Type::getInt32Ty(VMContext), Kind)
   };
 
   MDNode *CUNode = MDNode::get(VMContext, Elts);
index 0617f672e611c1acb9492585e03f7c8763b634fd..506f2dd926e7616893c27a041d798ef1d94fe779 100644 (file)
@@ -382,7 +382,7 @@ bool DICompileUnit::Verify() const {
   if (getFilename().empty())
     return false;
 
-  return DbgNode->getNumOperands() == 13;
+  return DbgNode->getNumOperands() == 14;
 }
 
 /// Verify - Verify that an ObjC property is well formed.
index d1afade4ad9f3a09dcf442c61310a6f1db676cb0..0c0a4dcb63e8743c49feabd3ee1ba2fa0c2bd686 100644 (file)
@@ -9,7 +9,7 @@ entry:
 }
 !llvm.dbg.cu = !{!2}
 !llvm.module.flags = !{!5}
-!2 = metadata !{i32 786449, metadata !4, i32 32769, metadata !"clang version 3.3 ", i1 false, metadata !"", i32 0, metadata !3, metadata !3, metadata !3, metadata !3,  metadata !3, metadata !""} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/scratch/scratch.cpp] [lang 0x8001]
+!2 = metadata !{i32 786449, metadata !4, i32 32769, metadata !"clang version 3.3 ", i1 false, metadata !"", i32 0, metadata !3, metadata !3, metadata !3, metadata !3,  metadata !3, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/scratch/scratch.cpp] [lang 0x8001]
 !3 = metadata !{}
 !0 = metadata !{i32 662302, i32 26, metadata !1, null}
 !1 = metadata !{i32 4, metadata !"foo"}
index 28784686bb68c8e1aa794eee7e528c0165014e04..b55ac3c08245eb8b0ce019081ee821fb141ed9d5 100644 (file)
@@ -9,7 +9,7 @@ entry:
 
 !0 = metadata !{i32 524334, metadata !10, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", i32 3, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, i32 ()* @foo, null, null, null, i32 0} ; [ DW_TAG_subprogram ]
 !1 = metadata !{i32 524329, metadata !10} ; [ DW_TAG_file_type ]
-!2 = metadata !{i32 524305, metadata !10, i32 12, metadata !"clang version 2.8 (trunk 112062)", i1 true, metadata !"", i32 0, metadata !11, metadata !11, metadata !12, metadata !13, null, metadata !""} ; [ DW_TAG_compile_unit ]
+!2 = metadata !{i32 524305, metadata !10, i32 12, metadata !"clang version 2.8 (trunk 112062)", i1 true, metadata !"", i32 0, metadata !11, metadata !11, metadata !12, metadata !13, null, metadata !"", i32 1} ; [ DW_TAG_compile_unit ]
 !3 = metadata !{i32 524309, metadata !10, metadata !1, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
 !4 = metadata !{metadata !5}
 !5 = metadata !{i32 524324, metadata !10, metadata !1, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
index 2d687ae6547004e4b41883a0a9bcbf2d10d9c15d..8ce7b87c825038c7ad559fae93966c0488d22ecb 100644 (file)
@@ -30,7 +30,7 @@ attributes #2 = { nounwind readonly ssp }
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!25}
 
-!0 = metadata !{i32 524305, metadata !1, i32 1, metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !23, metadata !24, null, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp//g.c] [DW_LANG_C89]
+!0 = metadata !{i32 524305, metadata !1, i32 1, metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !23, metadata !24, null, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/tmp//g.c] [DW_LANG_C89]
 !1 = metadata !{metadata !"g.c", metadata !"/tmp/"}
 !2 = metadata !{null}
 !3 = metadata !{i32 524334, metadata !1, null, metadata !"bar", metadata !"bar", metadata !"", i32 5, metadata !4, i1 true, i1 true, i32 0, i32 0, null, i1 false, i1 true, null, null, null, null, i32 0} ; [ DW_TAG_subprogram ] [line 5] [local] [def] [scope 0] [bar]