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
92 lines
4.1 KiB
LLVM
92 lines
4.1 KiB
LLVM
; RUN: llc -generate-arange-section < %s | FileCheck %s
|
|
|
|
; CHECK: .short 2 # DWARF Arange version number
|
|
; CHECK: # Segment Size
|
|
; CHECK-NOT: debug_loc
|
|
; CHECK: .quad global
|
|
; CHECK-NOT: debug_loc
|
|
; CHECK: # ARange terminator
|
|
|
|
; --- Source code ---
|
|
; Generated with "clang -g -O1 -S -emit-llvm"
|
|
|
|
; int global = 2;
|
|
; int foo(int bar) { return bar; }
|
|
; int foo2(int bar2) { return bar2; }
|
|
|
|
; int main() {
|
|
; return foo(2) + foo2(1) + global;
|
|
; }
|
|
|
|
; ModuleID = 'tmp/debug_ranges/a.cc'
|
|
source_filename = "test/DebugInfo/X86/dwarf-aranges-no-dwarf-labels.ll"
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
@global = global i32 2, align 4, !dbg !0
|
|
|
|
; Function Attrs: nounwind readnone uwtable
|
|
define i32 @_Z3fooi(i32 %bar) #0 !dbg !9 {
|
|
entry:
|
|
tail call void @llvm.dbg.value(metadata i32 %bar, metadata !13, metadata !14), !dbg !15
|
|
ret i32 %bar, !dbg !15
|
|
}
|
|
|
|
; Function Attrs: nounwind readnone uwtable
|
|
define i32 @_Z4foo2i(i32 %bar2) #0 !dbg !16 {
|
|
entry:
|
|
tail call void @llvm.dbg.value(metadata i32 %bar2, metadata !18, metadata !14), !dbg !19
|
|
ret i32 %bar2, !dbg !19
|
|
}
|
|
|
|
; Function Attrs: nounwind readonly uwtable
|
|
define i32 @main() #1 !dbg !20 {
|
|
entry:
|
|
%call = tail call i32 @_Z3fooi(i32 2), !dbg !23
|
|
%call1 = tail call i32 @_Z4foo2i(i32 1), !dbg !23
|
|
%add = add nsw i32 %call1, %call, !dbg !23
|
|
%0 = load i32, i32* @global, align 4, !dbg !23, !tbaa !24
|
|
%add2 = add nsw i32 %add, %0, !dbg !23
|
|
ret i32 %add2, !dbg !23
|
|
}
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare void @llvm.dbg.value(metadata, metadata, metadata) #2
|
|
|
|
attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
attributes #1 = { nounwind readonly uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
attributes #2 = { nounwind readnone }
|
|
|
|
!llvm.dbg.cu = !{!4}
|
|
!llvm.module.flags = !{!7, !8}
|
|
|
|
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
|
!1 = !DIGlobalVariable(name: "global", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
|
|
!2 = !DIFile(filename: "tmp/debug_ranges/a.cc", directory: "/")
|
|
!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.4 (191881)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
|
|
!5 = !{}
|
|
!6 = !{!0}
|
|
!7 = !{i32 2, !"Dwarf Version", i32 4}
|
|
!8 = !{i32 1, !"Debug Info Version", i32 3}
|
|
!9 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !2, file: !2, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !4, retainedNodes: !12)
|
|
!10 = !DISubroutineType(types: !11)
|
|
!11 = !{!3, !3}
|
|
!12 = !{!13}
|
|
!13 = !DILocalVariable(name: "bar", arg: 1, scope: !9, file: !2, line: 2, type: !3)
|
|
!14 = !DIExpression()
|
|
!15 = !DILocation(line: 2, scope: !9)
|
|
!16 = distinct !DISubprogram(name: "foo2", linkageName: "_Z4foo2i", scope: !2, file: !2, line: 3, type: !10, isLocal: false, isDefinition: true, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !4, retainedNodes: !17)
|
|
!17 = !{!18}
|
|
!18 = !DILocalVariable(name: "bar2", arg: 1, scope: !16, file: !2, line: 3, type: !3)
|
|
!19 = !DILocation(line: 3, scope: !16)
|
|
!20 = distinct !DISubprogram(name: "main", scope: !2, file: !2, line: 5, type: !21, isLocal: false, isDefinition: true, scopeLine: 5, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !4, retainedNodes: !5)
|
|
!21 = !DISubroutineType(types: !22)
|
|
!22 = !{!3}
|
|
!23 = !DILocation(line: 6, scope: !20)
|
|
!24 = !{!25, !25, i64 0}
|
|
!25 = !{!"int", !26}
|
|
!26 = !{!"omnipotent char", !27}
|
|
!27 = !{!"Simple C/C++ TBAA"}
|
|
|