From ab15115ee02063ffc74c67da8d4f41dbec06fe47 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 4 Nov 2014 08:03:31 +0000 Subject: [PATCH] CodeGen: Enable DWARF emission for MS ABI targets This is experimental, just barely enough to get things to not immediately combust. A note for those who are curious: Only lld can successfully link the object files, other linkers truncate the section names making the debug sections illegible to debuggers. Even with this in mind, we believe we are having trouble with SECREL relocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221245 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 8 ++- test/DebugInfo/COFF/asm.ll | 20 +++---- test/DebugInfo/COFF/multifile.ll | 26 +++++----- test/DebugInfo/COFF/multifunction.ll | 52 +++++++++++-------- test/DebugInfo/COFF/simple.ll | 16 +++--- .../COFF/tail-call-without-lexical-scopes.ll | 2 +- 6 files changed, 67 insertions(+), 57 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 260f39cebf6..e8bff7c6de5 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -222,14 +222,12 @@ bool AsmPrinter::doInitialization(Module &M) { } if (MAI->doesSupportDebugInformation()) { - if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) { + if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this), DbgTimerName, CodeViewLineTablesGroupName)); - } else { - DD = new DwarfDebug(this, &M); - Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); - } + DD = new DwarfDebug(this, &M); + Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); } EHStreamer *ES = nullptr; diff --git a/test/DebugInfo/COFF/asm.ll b/test/DebugInfo/COFF/asm.ll index e5b9771137c..278717d8bda 100644 --- a/test/DebugInfo/COFF/asm.ll +++ b/test/DebugInfo/COFF/asm.ll @@ -13,13 +13,14 @@ ; 6 } ; X86-LABEL: _f: -; X86-NEXT: # BB +; X86: # BB ; X86-NEXT: [[ASM_LINE:^L.*]]:{{$}} ; X86: [[CALL_LINE:^L.*]]:{{$}} -; X86-NEXT: calll _g +; X86: calll _g ; X86-NEXT: [[RETURN_STMT:.*]]: -; X86-NEXT: ret -; X86-NEXT: [[END_OF_F:.*]]: +; X86: ret +; X86-NEXT: L{{.*}}: +; X86-NEXT: [[END_OF_F:^L.*]]: ; ; X86-LABEL: .section .debug$S,"rd" ; X86-NEXT: .long 4 @@ -115,14 +116,15 @@ ; X64-LABEL: f: ; X64-NEXT: [[START:.*]]:{{$}} -; X64-NEXT: # BB -; X64-NEXT: subq $40, %rsp +; X64: # BB +; X64: subq $40, %rsp ; X64-NEXT: [[ASM_LINE:.*]]:{{$}} ; X64: [[CALL_LINE:.*]]:{{$}} -; X64-NEXT: callq g +; X64: callq g ; X64-NEXT: [[EPILOG_AND_RET:.*]]: -; X64-NEXT: addq $40, %rsp +; X64: addq $40, %rsp ; X64-NEXT: ret +; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; ; X64-LABEL: .section .debug$S,"rd" @@ -239,7 +241,7 @@ attributes #2 = { nounwind } !0 = metadata !{metadata !"0x11\0012\00clang version 3.5 \000\00\000\00\000", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [D:\/] [DW_LANG_C99] !1 = metadata !{metadata !"", metadata !"D:\5C"} -!2 = metadata !{i32 0} +!2 = metadata !{} !3 = metadata !{metadata !4} !4 = metadata !{metadata !"0x2e\00f\00f\00\003\000\001\000\006\00256\000\003", metadata !5, metadata !6, metadata !7, null, void ()* @f, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 3] [def] [f] !5 = metadata !{metadata !"asm.c", metadata !"D:\5C"} diff --git a/test/DebugInfo/COFF/multifile.ll b/test/DebugInfo/COFF/multifile.ll index 181166fdf5a..1cb4c7c48d6 100644 --- a/test/DebugInfo/COFF/multifile.ll +++ b/test/DebugInfo/COFF/multifile.ll @@ -17,15 +17,16 @@ ; 10 } ; X86-LABEL: _f: -; X86-NEXT: # BB +; X86: # BB ; X86-NEXT: [[CALL_LINE_1:.*]]:{{$}} -; X86-NEXT: calll _g +; X86: calll _g ; X86-NEXT: [[CALL_LINE_2:.*]]:{{$}} -; X86-NEXT: calll _g +; X86: calll _g ; X86-NEXT: [[CALL_LINE_3:.*]]:{{$}} -; X86-NEXT: calll _g +; X86: calll _g ; X86-NEXT: [[RETURN_STMT:.*]]: -; X86-NEXT: ret +; X86: ret +; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:.*]]: ; ; X86-LABEL: .section .debug$S,"rd" @@ -144,17 +145,18 @@ ; X64-LABEL: f: ; X64-NEXT: [[START:.*]]:{{$}} -; X64-NEXT: # BB -; X64-NEXT: subq $40, %rsp +; X64: # BB +; X64: subq $40, %rsp ; X64-NEXT: [[CALL_LINE_1:.*]]:{{$}} -; X64-NEXT: callq g +; X64: callq g ; X64-NEXT: [[CALL_LINE_2:.*]]:{{$}} -; X64-NEXT: callq g +; X64: callq g ; X64-NEXT: [[CALL_LINE_3:.*]]:{{$}} -; X64-NEXT: callq g +; X64: callq g ; X64-NEXT: [[EPILOG_AND_RET:.*]]: -; X64-NEXT: addq $40, %rsp +; X64: addq $40, %rsp ; X64-NEXT: ret +; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; ; X64-LABEL: .section .debug$S,"rd" @@ -307,7 +309,7 @@ attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" " !0 = metadata !{metadata !"0x11\0012\00clang version 3.5 \000\00\000\00\000", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [D:\/] [DW_LANG_C99] !1 = metadata !{metadata !"", metadata !"D:\5C"} -!2 = metadata !{i32 0} +!2 = metadata !{} !3 = metadata !{metadata !4} !4 = metadata !{metadata !"0x2e\00f\00f\00\003\000\001\000\006\00256\000\003", metadata !5, metadata !6, metadata !7, null, void ()* @f, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 3] [def] [f] !5 = metadata !{metadata !"input.c", metadata !"D:\5C"} diff --git a/test/DebugInfo/COFF/multifunction.ll b/test/DebugInfo/COFF/multifunction.ll index 0cd7da0ec2a..d436d8271dd 100644 --- a/test/DebugInfo/COFF/multifunction.ll +++ b/test/DebugInfo/COFF/multifunction.ll @@ -23,31 +23,34 @@ ; X86-LABEL: _x: -; X86-NEXT: # BB +; X86: # BB ; X86-NEXT: [[X_CALL:.*]]:{{$}} -; X86-NEXT: calll _z +; X86: calll _z ; X86-NEXT: [[X_RETURN:.*]]: -; X86-NEXT: ret +; X86: ret +; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_X:.*]]: ; ; X86-LABEL: _y: -; X86-NEXT: # BB +; X86: # BB ; X86-NEXT: [[Y_CALL:.*]]:{{$}} -; X86-NEXT: calll _z +; X86: calll _z ; X86-NEXT: [[Y_RETURN:.*]]: -; X86-NEXT: ret +; X86: ret +; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_Y:.*]]: ; ; X86-LABEL: _f: -; X86-NEXT: # BB +; X86: # BB ; X86-NEXT: [[F_CALLS_X:.*]]:{{$}} -; X86-NEXT: calll _x +; X86: calll _x ; X86-NEXT: [[F_CALLS_Y:.*]]: -; X86-NEXT: calll _y +; X86: calll _y ; X86-NEXT: [[F_CALLS_Z:.*]]: -; X86-NEXT: calll _z +; X86: calll _z ; X86-NEXT: [[F_RETURN:.*]]: -; X86-NEXT: ret +; X86: ret +; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:.*]]: ; ; X86-LABEL: .section .debug$S,"rd" @@ -276,39 +279,42 @@ ; X64-LABEL: x: ; X64-NEXT: [[X_START:.*]]:{{$}} -; X64-NEXT: # BB -; X64-NEXT: subq $40, %rsp +; X64: # BB +; X64: subq $40, %rsp ; X64-NEXT: [[X_CALL_LINE:.*]]:{{$}} ; X64-NEXT: callq z ; X64-NEXT: [[X_EPILOG_AND_RET:.*]]: -; X64-NEXT: addq $40, %rsp +; X64: addq $40, %rsp ; X64-NEXT: ret +; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_X:.*]]: ; ; X64-LABEL: y: ; X64-NEXT: [[Y_START:.*]]:{{$}} -; X64-NEXT: # BB -; X64-NEXT: subq $40, %rsp +; X64: # BB +; X64: subq $40, %rsp ; X64-NEXT: [[Y_CALL_LINE:.*]]:{{$}} ; X64-NEXT: callq z ; X64-NEXT: [[Y_EPILOG_AND_RET:.*]]: -; X64-NEXT: addq $40, %rsp +; X64: addq $40, %rsp ; X64-NEXT: ret +; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_Y:.*]]: ; ; X64-LABEL: f: ; X64-NEXT: [[F_START:.*]]:{{$}} -; X64-NEXT: # BB -; X64-NEXT: subq $40, %rsp +; X64: # BB +; X64: subq $40, %rsp ; X64-NEXT: [[F_CALLS_X:.*]]:{{$}} ; X64-NEXT: callq x ; X64-NEXT: [[F_CALLS_Y:.*]]: -; X64-NEXT: callq y +; X64: callq y ; X64-NEXT: [[F_CALLS_Z:.*]]: -; X64-NEXT: callq z +; X64: callq z ; X64-NEXT: [[F_EPILOG_AND_RET:.*]]: -; X64-NEXT: addq $40, %rsp +; X64: addq $40, %rsp ; X64-NEXT: ret +; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; ; X64-LABEL: .section .debug$S,"rd" @@ -578,7 +584,7 @@ attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" " !0 = metadata !{metadata !"0x11\0012\00clang version 3.5 \000\00\000\00\000", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [D:\/] [DW_LANG_C99] !1 = metadata !{metadata !"", metadata !"D:\5C"} -!2 = metadata !{i32 0} +!2 = metadata !{} !3 = metadata !{metadata !4, metadata !9, metadata !10} !4 = metadata !{metadata !"0x2e\00x\00x\00\003\000\001\000\006\00256\000\003", metadata !5, metadata !6, metadata !7, null, void ()* @x, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 3] [def] [x] !5 = metadata !{metadata !"source.c", metadata !"D:\5C"} diff --git a/test/DebugInfo/COFF/simple.ll b/test/DebugInfo/COFF/simple.ll index e7898859b59..e8c50058f28 100644 --- a/test/DebugInfo/COFF/simple.ll +++ b/test/DebugInfo/COFF/simple.ll @@ -12,11 +12,12 @@ ; 5 } ; X86-LABEL: _f: -; X86-NEXT: # BB +; X86: # BB ; X86-NEXT: [[CALL_LINE:^L.*]]:{{$}} -; X86-NEXT: calll _g +; X86: calll _g ; X86-NEXT: [[RETURN_STMT:.*]]: -; X86-NEXT: ret +; X86: ret +; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:.*]]: ; ; X86-LABEL: .section .debug$S,"rd" @@ -107,13 +108,14 @@ ; X64-LABEL: f: ; X64-NEXT: [[START:.*]]:{{$}} -; X64-NEXT: # BB -; X64-NEXT: subq $40, %rsp +; X64: # BB +; X64: subq $40, %rsp ; X64-NEXT: [[CALL_LINE:.*]]:{{$}} ; X64-NEXT: callq g ; X64-NEXT: [[EPILOG_AND_RET:.*]]: -; X64-NEXT: addq $40, %rsp +; X64: addq $40, %rsp ; X64-NEXT: ret +; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; ; X64-LABEL: .section .debug$S,"rd" @@ -223,7 +225,7 @@ attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" " !0 = metadata !{metadata !"0x11\0012\00clang version 3.5 \000\00\000\00\000", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [D:\/] [DW_LANG_C99] !1 = metadata !{metadata !"", metadata !"D:\5C"} -!2 = metadata !{i32 0} +!2 = metadata !{} !3 = metadata !{metadata !4} !4 = metadata !{metadata !"0x2e\00f\00f\00\003\000\001\000\006\00256\000\003", metadata !5, metadata !6, metadata !7, null, void ()* @f, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 3] [def] [f] !5 = metadata !{metadata !"test.c", metadata !"D:\5C"} diff --git a/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll b/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll index 92fe3eb28ff..8db2fd0b2f4 100644 --- a/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll +++ b/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll @@ -18,7 +18,7 @@ ; X86-LABEL: {{^}}"?bar@@YAXHZZ": ; X86-NEXT: # BB ; X86-NEXT: [[JMP_LINE:^L.*]]:{{$}} -; X86-NEXT: jmp "?foo@@YAXXZ" +; X86: jmp "?foo@@YAXXZ" ; X86-NEXT: [[END_OF_BAR:^L.*]]:{{$}} ; X86-NOT: ret -- 2.34.1