[llvm] r244158 - If the "CodeView" module flag is set, emit codeview instead of DWARF
Reid Kleckner
rnk at google.com
Wed Aug 5 15:26:21 PDT 2015
Author: rnk
Date: Wed Aug 5 17:26:20 2015
New Revision: 244158
URL: http://llvm.org/viewvc/llvm-project?rev=244158&view=rev
Log:
If the "CodeView" module flag is set, emit codeview instead of DWARF
Summary:
Emit both DWARF and CodeView if "CodeView" and "Dwarf Version" module
flags are set.
Reviewers: majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11756
Modified:
llvm/trunk/include/llvm/IR/Module.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/IR/Module.cpp
llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll
llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll
llvm/trunk/test/DebugInfo/COFF/asm.ll
llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll
llvm/trunk/test/DebugInfo/COFF/multifile.ll
llvm/trunk/test/DebugInfo/COFF/multifunction.ll
llvm/trunk/test/DebugInfo/COFF/simple.ll
llvm/trunk/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll
llvm/trunk/test/DebugInfo/X86/coff_debug_info_type.ll
llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll
Modified: llvm/trunk/include/llvm/IR/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Module.h?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Module.h (original)
+++ llvm/trunk/include/llvm/IR/Module.h Wed Aug 5 17:26:20 2015
@@ -666,6 +666,10 @@ public:
/// \brief Returns the Dwarf Version by checking module flags.
unsigned getDwarfVersion() const;
+ /// \brief Returns the CodeView Version by checking module flags.
+ /// Returns zero if not present in module.
+ unsigned getCodeViewFlag() const;
+
/// @}
/// @name Utility functions for querying and setting PIC level
/// @{
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Aug 5 17:26:20 2015
@@ -233,22 +233,13 @@ bool AsmPrinter::doInitialization(Module
}
if (MAI->doesSupportDebugInformation()) {
- bool skip_dwarf = false;
- if (TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) {
+ bool EmitCodeView = MMI->getModule()->getCodeViewFlag();
+ if (EmitCodeView && TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) {
Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this),
DbgTimerName,
CodeViewLineTablesGroupName));
- // FIXME: Don't emit DWARF debug info if there's at least one function
- // with AddressSanitizer instrumentation.
- // This is a band-aid fix for PR22032.
- for (auto &F : M.functions()) {
- if (F.hasFnAttribute(Attribute::SanitizeAddress)) {
- skip_dwarf = true;
- break;
- }
- }
}
- if (!skip_dwarf) {
+ if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) {
DD = new DwarfDebug(this, &M);
Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName));
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Aug 5 17:26:20 2015
@@ -252,6 +252,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo
unsigned DwarfVersionNumber = Asm->TM.Options.MCOptions.DwarfVersion;
DwarfVersion = DwarfVersionNumber ? DwarfVersionNumber
: MMI->getModule()->getDwarfVersion();
+ // Use dwarf 4 by default if nothing is requested.
+ DwarfVersion = DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION;
// Work around a GDB bug. GDB doesn't support the standard opcode;
// SCE doesn't support GNU's; LLDB prefers the standard opcode, which
Modified: llvm/trunk/lib/IR/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Module.cpp (original)
+++ llvm/trunk/lib/IR/Module.cpp Wed Aug 5 17:26:20 2015
@@ -458,7 +458,14 @@ void Module::dropAllReferences() {
unsigned Module::getDwarfVersion() const {
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Dwarf Version"));
if (!Val)
- return dwarf::DWARF_VERSION;
+ return 0;
+ return cast<ConstantInt>(Val->getValue())->getZExtValue();
+}
+
+unsigned Module::getCodeViewFlag() const {
+ auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("CodeView"));
+ if (!Val)
+ return 0;
return cast<ConstantInt>(Val->getValue())->getZExtValue();
}
Modified: llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/asan-module-ctor.ll Wed Aug 5 17:26:20 2015
@@ -89,7 +89,7 @@ attributes #0 = { nounwind sanitize_addr
!4 = !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !1, scope: !5, type: !6, function: i32 ()* @foo, variables: !2)
!5 = !DIFile(filename: "asan.c", directory: "D:C")
!6 = !DISubroutineType(types: !2)
-!7 = !{i32 2, !"Dwarf Version", i32 4}
+!7 = !{i32 2, !"CodeView", i32 1}
!8 = !{i32 1, !"Debug Info Version", i32 3}
!9 = !{!"clang version 3.5.0 "}
!10 = !DILocation(line: 2, scope: !4)
Modified: llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/asan-module-without-functions.ll Wed Aug 5 17:26:20 2015
@@ -48,6 +48,6 @@ define internal void @asan.module_dtor()
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 2, file: !1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2, imports: !2)
!1 = !DIFile(filename: "asan.c", directory: "D:\5C")
!2 = !{}
-!3 = !{i32 2, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"CodeView", i32 1}
!4 = !{i32 1, !"Debug Info Version", i32 3}
!5 = !{!"clang version 3.5.0 "}
Modified: llvm/trunk/test/DebugInfo/COFF/asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/asm.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/asm.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/asm.ll Wed Aug 5 17:26:20 2015
@@ -19,7 +19,6 @@
; X86: calll _g
; X86-NEXT: [[RETURN_STMT:.*]]:
; X86: ret
-; X86-NEXT: L{{.*}}:
; X86-NEXT: [[END_OF_F:^L.*]]:
;
; X86-LABEL: .section .debug$S,"dr"
@@ -138,7 +137,6 @@
; X64-NEXT: [[EPILOG_AND_RET:.*]]:
; X64: addq $40, %rsp
; X64-NEXT: ret
-; X64-NEXT: .L{{.*}}:
; X64-NEXT: [[END_OF_F:.*]]:
;
; X64-LABEL: .section .debug$S,"dr"
@@ -279,7 +277,7 @@ attributes #2 = { nounwind }
!6 = !DIFile(filename: "asm.c", directory: "D:C")
!7 = !DISubroutineType(types: !8)
!8 = !{null}
-!9 = !{i32 2, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"CodeView", i32 1}
!10 = !{i32 1, !"Debug Info Version", i32 3}
!11 = !{!"clang version 3.5 "}
!12 = !DILocation(line: 4, scope: !4)
Modified: llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll Wed Aug 5 17:26:20 2015
@@ -37,7 +37,7 @@ attributes #0 = { nounwind "less-precise
!5 = !DIFile(filename: "src.cpp", directory: "D:\5C")
!6 = !DIFile(filename: "src.cpp", directory: "D:C")
!7 = !DISubroutineType(types: !2)
-!8 = !{i32 2, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"CodeView", i32 1}
!9 = !{i32 2, !"Debug Info Version", i32 3}
!10 = !{!"clang version 3.6.0 "}
!11 = !DILocation(line: 3, scope: !4)
Modified: llvm/trunk/test/DebugInfo/COFF/multifile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/multifile.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/multifile.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/multifile.ll Wed Aug 5 17:26:20 2015
@@ -26,7 +26,6 @@
; X86: calll _g
; X86-NEXT: [[RETURN_STMT:.*]]:
; X86: ret
-; X86-NEXT: L{{.*}}:
; X86-NEXT: [[END_OF_F:.*]]:
;
; X86-LABEL: .section .debug$S,"dr"
@@ -174,7 +173,6 @@
; X64-NEXT: [[EPILOG_AND_RET:.*]]:
; X64: addq $40, %rsp
; X64-NEXT: ret
-; X64-NEXT: .L{{.*}}:
; X64-NEXT: [[END_OF_F:.*]]:
;
; X64-LABEL: .section .debug$S,"dr"
@@ -355,7 +353,7 @@ attributes #1 = { "less-precise-fpmad"="
!6 = !DIFile(filename: "input.c", directory: "D:C")
!7 = !DISubroutineType(types: !8)
!8 = !{null}
-!9 = !{i32 2, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"CodeView", i32 1}
!10 = !{i32 1, !"Debug Info Version", i32 3}
!11 = !{!"clang version 3.5 "}
!12 = !DILocation(line: 1, scope: !13)
Modified: llvm/trunk/test/DebugInfo/COFF/multifunction.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/multifunction.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/multifunction.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/multifunction.ll Wed Aug 5 17:26:20 2015
@@ -28,7 +28,6 @@
; X86: calll _z
; X86-NEXT: [[X_RETURN:.*]]:
; X86: ret
-; X86-NEXT: L{{.*}}:
; X86-NEXT: [[END_OF_X:.*]]:
;
; X86-LABEL: _y:
@@ -37,7 +36,6 @@
; X86: calll _z
; X86-NEXT: [[Y_RETURN:.*]]:
; X86: ret
-; X86-NEXT: L{{.*}}:
; X86-NEXT: [[END_OF_Y:.*]]:
;
; X86-LABEL: _f:
@@ -50,7 +48,6 @@
; X86: calll _z
; X86-NEXT: [[F_RETURN:.*]]:
; X86: ret
-; X86-NEXT: L{{.*}}:
; X86-NEXT: [[END_OF_F:.*]]:
;
; X86-LABEL: .section .debug$S,"dr"
@@ -322,7 +319,6 @@
; X64-NEXT: [[X_EPILOG_AND_RET:.*]]:
; X64: addq $40, %rsp
; X64-NEXT: ret
-; X64-NEXT: .L{{.*}}:
; X64-NEXT: [[END_OF_X:.*]]:
;
; X64-LABEL: y:
@@ -335,7 +331,6 @@
; X64-NEXT: [[Y_EPILOG_AND_RET:.*]]:
; X64: addq $40, %rsp
; X64-NEXT: ret
-; X64-NEXT: .L{{.*}}:
; X64-NEXT: [[END_OF_Y:.*]]:
;
; X64-LABEL: f:
@@ -352,7 +347,6 @@
; X64-NEXT: [[F_EPILOG_AND_RET:.*]]:
; X64: addq $40, %rsp
; X64-NEXT: ret
-; X64-NEXT: .L{{.*}}:
; X64-NEXT: [[END_OF_F:.*]]:
;
; X64-LABEL: .section .debug$S,"dr"
@@ -678,7 +672,7 @@ attributes #1 = { "less-precise-fpmad"="
!8 = !{null}
!9 = !DISubprogram(name: "y", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !5, scope: !6, type: !7, function: void ()* @y, variables: !2)
!10 = !DISubprogram(name: "f", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 11, file: !5, scope: !6, type: !7, function: void ()* @f, variables: !2)
-!11 = !{i32 2, !"Dwarf Version", i32 4}
+!11 = !{i32 2, !"CodeView", i32 1}
!12 = !{i32 1, !"Debug Info Version", i32 3}
!13 = !{!"clang version 3.5 "}
!14 = !DILocation(line: 4, column: 42, scope: !4)
Modified: llvm/trunk/test/DebugInfo/COFF/simple.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/simple.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/simple.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/simple.ll Wed Aug 5 17:26:20 2015
@@ -17,7 +17,6 @@
; X86: calll _g
; X86-NEXT: [[RETURN_STMT:.*]]:
; X86: ret
-; X86-NEXT: L{{.*}}:
; X86-NEXT: [[END_OF_F:.*]]:
;
; X86-LABEL: .section .debug$S,"dr"
@@ -125,7 +124,6 @@
; X64-NEXT: [[EPILOG_AND_RET:.*]]:
; X64: addq $40, %rsp
; X64-NEXT: ret
-; X64-NEXT: .L{{.*}}:
; X64-NEXT: [[END_OF_F:.*]]:
;
; X64-LABEL: .section .debug$S,"dr"
@@ -255,7 +253,7 @@ attributes #1 = { "less-precise-fpmad"="
!6 = !DIFile(filename: "test.c", directory: "D:C")
!7 = !DISubroutineType(types: !8)
!8 = !{null}
-!9 = !{i32 2, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"CodeView", i32 1}
!10 = !{i32 1, !"Debug Info Version", i32 3}
!11 = !{!"clang version 3.5 "}
!12 = !DILocation(line: 4, scope: !4)
Modified: llvm/trunk/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll Wed Aug 5 17:26:20 2015
@@ -70,7 +70,7 @@ attributes #2 = { nounwind }
!5 = !DIFile(filename: "test.cpp", directory: "D:C")
!6 = !DISubroutineType(types: !2)
!7 = !DISubprogram(name: "bar", line: 3, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 3, file: !1, scope: !5, type: !6, variables: !2)
-!8 = !{i32 2, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"CodeView", i32 1}
!9 = !{i32 1, !"Debug Info Version", i32 3}
!10 = !{!"clang version 3.5.0 "}
!11 = !DILocation(line: 8, scope: !4)
Modified: llvm/trunk/test/DebugInfo/X86/coff_debug_info_type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/coff_debug_info_type.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/coff_debug_info_type.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/coff_debug_info_type.ll Wed Aug 5 17:26:20 2015
@@ -5,7 +5,9 @@
; CHECK: .section .apple_names
; CHECK: .section .apple_types
-; RUN: llc -mtriple=i686-pc-win32 -filetype=asm -O0 < %s | FileCheck -check-prefix=WIN32 %s
+; RUN: sed -e 's/"Dwarf Version"/"CodeView"/' %s \
+; RUN: | llc -mtriple=i686-pc-win32 -filetype=asm -O0 \
+; RUN: | FileCheck -check-prefix=WIN32 %s
; WIN32: .section .debug$S,"dr"
; RUN: llc -mtriple=i686-pc-win32 -filetype=null -O0 < %s
Modified: llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll?rev=244158&r1=244157&r2=244158&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll (original)
+++ llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll Wed Aug 5 17:26:20 2015
@@ -1,7 +1,8 @@
; RUN: llc -mtriple thumbv7--windows-itanium -filetype obj -o - %s \
; RUN: | llvm-readobj -r - | FileCheck %s -check-prefix CHECK-ITANIUM
-; RUN: llc -mtriple thumbv7--windows-msvc -filetype obj -o - %s \
+; RUN: sed -e 's/"Dwarf Version"/"CodeView"/' %s \
+; RUN: | llc -mtriple thumbv7--windows-msvc -filetype obj -o - \
; RUN: | llvm-readobj -r - | FileCheck %s -check-prefix CHECK-MSVC
; ModuleID = '/Users/compnerd/work/llvm/test/MC/ARM/reduced.c'
More information about the llvm-commits
mailing list