From 0181303087b3b341e32e8b9a4abd38e9af812318 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 27 Feb 2014 01:24:56 +0000 Subject: [PATCH] Add a debug info code generation level to the compile unit metadata 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 | 4 +++- include/llvm/DebugInfo.h | 1 + lib/IR/DIBuilder.cpp | 7 +++++-- lib/IR/DebugInfo.cpp | 2 +- test/DebugInfo/2010-03-19-DbgDeclare.ll | 2 +- test/Transforms/StripSymbols/2010-08-25-crash.ll | 2 +- test/Transforms/StripSymbols/strip-dead-debug-info.ll | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 0afa9ab5800..d47bae5fc60 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -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. diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index ccf62ffb815..930f7eba672 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -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; diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index fc80ba9e64a..4bb75bdb0df 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -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); diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 0617f672e61..506f2dd926e 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -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. diff --git a/test/DebugInfo/2010-03-19-DbgDeclare.ll b/test/DebugInfo/2010-03-19-DbgDeclare.ll index d1afade4ad9..0c0a4dcb63e 100644 --- a/test/DebugInfo/2010-03-19-DbgDeclare.ll +++ b/test/DebugInfo/2010-03-19-DbgDeclare.ll @@ -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"} diff --git a/test/Transforms/StripSymbols/2010-08-25-crash.ll b/test/Transforms/StripSymbols/2010-08-25-crash.ll index 28784686bb6..b55ac3c0824 100644 --- a/test/Transforms/StripSymbols/2010-08-25-crash.ll +++ b/test/Transforms/StripSymbols/2010-08-25-crash.ll @@ -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 ] diff --git a/test/Transforms/StripSymbols/strip-dead-debug-info.ll b/test/Transforms/StripSymbols/strip-dead-debug-info.ll index 2d687ae6547..8ce7b87c825 100644 --- a/test/Transforms/StripSymbols/strip-dead-debug-info.ll +++ b/test/Transforms/StripSymbols/strip-dead-debug-info.ll @@ -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]