mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
a2029fa58e
In order to set breakpoints on labels and list source code around labels, we need collect debug information for labels, i.e., label name, the function label belong, line number in the file, and the address label located. In order to keep these information in LLVM IR and to allow backend to generate debug information correctly. We create a new kind of metadata for labels, DILabel. The format of DILabel is !DILabel(scope: !1, name: "foo", file: !2, line: 3) We hope to keep debug information as much as possible even the code is optimized. So, we create a new kind of intrinsic for label metadata to avoid the metadata is eliminated with basic block. The intrinsic will keep existing if we keep it from optimized out. The format of the intrinsic is llvm.dbg.label(metadata !1) It has only one argument, that is the DILabel metadata. The intrinsic will follow the label immediately. Backend could get the label metadata through the intrinsic's parameter. We also create DIBuilder API for labels to be used by Frontend. Frontend could use createLabel() to allocate DILabel objects, and use insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR. Differential Revision: https://reviews.llvm.org/D45024 Patch by Hsiangkai Wang. llvm-svn: 331841
38 lines
1.7 KiB
LLVM
38 lines
1.7 KiB
LLVM
; RUN: llc -mtriple=x86_64-pc-linux-gnu -split-dwarf-file=foo.dwo %s -o - | FileCheck %s
|
|
; Derived from:
|
|
|
|
; int main (void) {
|
|
; return 0;
|
|
; }
|
|
|
|
; Check that we get a symbol off of the debug_info section when using split dwarf and pubnames.
|
|
|
|
; CHECK: .LpubTypes_begin0:
|
|
; CHECK-NEXT: .short 2 # DWARF Version
|
|
; CHECK-NEXT: .long .Lcu_begin0 # Offset of Compilation Unit Info
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
define i32 @main() #0 !dbg !4 {
|
|
entry:
|
|
%retval = alloca i32, align 4
|
|
store i32 0, i32* %retval
|
|
ret i32 0, !dbg !10
|
|
}
|
|
|
|
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!9, !11}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (trunk 189287) (llvm/trunk 189296)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
|
|
!1 = !DIFile(filename: "foo.c", directory: "/usr/local/google/home/echristo/tmp")
|
|
!2 = !{}
|
|
!4 = distinct !DISubprogram(name: "main", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
|
|
!5 = !DIFile(filename: "foo.c", directory: "/usr/local/google/home/echristo/tmp")
|
|
!6 = !DISubroutineType(types: !7)
|
|
!7 = !{!8}
|
|
!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!9 = !{i32 2, !"Dwarf Version", i32 3}
|
|
!10 = !DILocation(line: 2, scope: !4)
|
|
!11 = !{i32 1, !"Debug Info Version", i32 3}
|