mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +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
40 lines
1.8 KiB
LLVM
40 lines
1.8 KiB
LLVM
; RUN: opt -analyze -module-debuginfo < %s | FileCheck %s
|
|
|
|
; Produced from linking:
|
|
; /tmp/test1.c containing f()
|
|
; /tmp/test2.c containing g()
|
|
|
|
; Verify that both compile units and both their contained functions are
|
|
; listed by DebugInfoFinder:
|
|
;CHECK: Compile unit: DW_LANG_C99 from /tmp/test1.c
|
|
;CHECK: Compile unit: DW_LANG_C99 from /tmp/test2.c
|
|
;CHECK: Subprogram: f from /tmp/test1.c:1
|
|
;CHECK: Subprogram: g from /tmp/test2.c:1
|
|
|
|
define void @f() !dbg !4 {
|
|
ret void, !dbg !14
|
|
}
|
|
|
|
define void @g() !dbg !11 {
|
|
ret void, !dbg !15
|
|
}
|
|
|
|
!llvm.dbg.cu = !{!0, !8}
|
|
!llvm.module.flags = !{!13, !16}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (192092)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
|
|
!1 = !DIFile(filename: "test1.c", directory: "/tmp")
|
|
!2 = !{}
|
|
!4 = distinct !DISubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
|
|
!5 = !DIFile(filename: "test1.c", directory: "/tmp")
|
|
!6 = !DISubroutineType(types: !7)
|
|
!7 = !{null}
|
|
!8 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (192092)", isOptimized: false, emissionKind: FullDebug, file: !9, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
|
|
!9 = !DIFile(filename: "test2.c", directory: "/tmp")
|
|
!11 = distinct !DISubprogram(name: "g", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !8, scopeLine: 1, file: !9, scope: !12, type: !6, retainedNodes: !2)
|
|
!12 = !DIFile(filename: "test2.c", directory: "/tmp")
|
|
!13 = !{i32 2, !"Dwarf Version", i32 4}
|
|
!14 = !DILocation(line: 1, scope: !4)
|
|
!15 = !DILocation(line: 1, scope: !11)
|
|
!16 = !{i32 1, !"Debug Info Version", i32 3}
|