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
This commit is contained in:
David Majnemer 2014-11-04 08:03:31 +00:00
parent 60234de3b5
commit ab15115ee0
6 changed files with 67 additions and 57 deletions

View File

@ -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;

View File

@ -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:\/<unknown>] [DW_LANG_C99]
!1 = metadata !{metadata !"<unknown>", 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"}

View File

@ -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:\/<unknown>] [DW_LANG_C99]
!1 = metadata !{metadata !"<unknown>", 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"}

View File

@ -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:\/<unknown>] [DW_LANG_C99]
!1 = metadata !{metadata !"<unknown>", 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"}

View File

@ -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:\/<unknown>] [DW_LANG_C99]
!1 = metadata !{metadata !"<unknown>", 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"}

View File

@ -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