mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +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
52 lines
2.6 KiB
LLVM
52 lines
2.6 KiB
LLVM
; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s
|
|
; RUN: llc -mtriple=x86_64-apple-darwin -regalloc=basic < %s | FileCheck %s
|
|
; Test to check separate label for inlined function argument.
|
|
|
|
define i32 @foo(i32 %y) nounwind optsize ssp !dbg !1 {
|
|
entry:
|
|
tail call void @llvm.dbg.value(metadata i32 %y, i64 0, metadata !0, metadata !DIExpression()), !dbg !DILocation(scope: !1)
|
|
%0 = tail call i32 (...) @zoo(i32 %y) nounwind, !dbg !9 ; <i32> [#uses=1]
|
|
ret i32 %0, !dbg !9
|
|
}
|
|
|
|
declare i32 @zoo(...)
|
|
|
|
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
|
|
|
|
define i32 @bar(i32 %x) nounwind optsize ssp !dbg !8 {
|
|
entry:
|
|
tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !8)
|
|
tail call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !0, metadata !DIExpression()) nounwind, !dbg !DILocation(scope: !1, inlinedAt: !DILocation(scope: !8))
|
|
%0 = tail call i32 (...) @zoo(i32 1) nounwind, !dbg !12 ; <i32> [#uses=1]
|
|
%1 = add nsw i32 %0, %x, !dbg !13 ; <i32> [#uses=1]
|
|
ret i32 %1, !dbg !13
|
|
}
|
|
|
|
!llvm.dbg.cu = !{!3}
|
|
!llvm.module.flags = !{!20}
|
|
|
|
!0 = !DILocalVariable(name: "y", line: 2, arg: 1, scope: !1, file: !2, type: !6)
|
|
!1 = distinct !DISubprogram(name: "foo", linkageName: "foo", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !3, scopeLine: 2, file: !18, scope: !2, type: !4, retainedNodes: !15)
|
|
!2 = !DIFile(filename: "f.c", directory: "/tmp")
|
|
!3 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: FullDebug, file: !18, enums: !19, retainedTypes: !19, imports: null)
|
|
!4 = !DISubroutineType(types: !5)
|
|
!5 = !{!6, !6}
|
|
!6 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!7 = !DILocalVariable(name: "x", line: 6, arg: 1, scope: !8, file: !2, type: !6)
|
|
!8 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !3, scopeLine: 6, file: !18, scope: !2, type: !4, retainedNodes: !16)
|
|
!9 = !DILocation(line: 3, scope: !10)
|
|
!10 = distinct !DILexicalBlock(line: 2, column: 0, file: !18, scope: !1)
|
|
!11 = !{i32 1}
|
|
!12 = !DILocation(line: 3, scope: !10, inlinedAt: !13)
|
|
!13 = !DILocation(line: 7, scope: !14)
|
|
!14 = distinct !DILexicalBlock(line: 6, column: 0, file: !18, scope: !8)
|
|
!15 = !{!0}
|
|
!16 = !{!7}
|
|
!18 = !DIFile(filename: "f.c", directory: "/tmp")
|
|
!19 = !{}
|
|
|
|
;CHECK: DEBUG_VALUE: bar:x <- $e
|
|
;CHECK: Ltmp
|
|
;CHECK: DEBUG_VALUE: foo:y <- 1{{$}}
|
|
!20 = !{i32 1, !"Debug Info Version", i32 3}
|