mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +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
56 lines
2.1 KiB
LLVM
56 lines
2.1 KiB
LLVM
; RUN: opt -S -consthoist < %s | FileCheck %s
|
|
; ModuleID = 'test-hoist-debug.cpp'
|
|
source_filename = "test-hoist-debug.cpp"
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
; Function Attrs: noinline nounwind optnone uwtable
|
|
define i32 @_Z3foov() !dbg !7 {
|
|
; CHECK: bitcast
|
|
; CHECK-NOT: !dbg !11
|
|
; CHECK: inttoptr
|
|
entry:
|
|
%a0 = inttoptr i64 4646526064 to i32*
|
|
%v0 = load i32, i32* %a0, align 16, !dbg !11
|
|
%c = alloca i32, align 4
|
|
store i32 1, i32* %c, align 4
|
|
%0 = load i32, i32* %c, align 4
|
|
%cmp = icmp eq i32 %0, 0
|
|
br i1 %cmp, label %if.then, label %if.else
|
|
|
|
if.then: ; preds = %entry
|
|
%a1 = inttoptr i64 4646526080 to i32*
|
|
%v1 = load i32, i32* %a1, align 16, !dbg !11
|
|
br label %return
|
|
|
|
if.else: ; preds = %entry
|
|
%a2 = inttoptr i64 4646526096 to i32*
|
|
%v2 = load i32, i32* %a2, align 16, !dbg !11
|
|
br label %return
|
|
|
|
return: ; preds = %if.else, %if.then
|
|
%vx = phi i32 [%v1, %if.then], [%v2, %if.else]
|
|
%r0 = add i32 %vx, %v0
|
|
|
|
ret i32 %r0
|
|
}
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!3, !4, !5}
|
|
!llvm.ident = !{!6}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 313291)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
|
|
!1 = !DIFile(filename: "test-hoist-debug.cpp", directory: "/tmp")
|
|
!2 = !{}
|
|
!3 = !{i32 2, !"Dwarf Version", i32 4}
|
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
!5 = !{i32 1, !"wchar_size", i32 4}
|
|
!6 = !{!"clang version 6.0.0 (trunk 313291)"}
|
|
!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
|
|
!8 = !DISubroutineType(types: !9)
|
|
!9 = !{!10}
|
|
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
!11 = !DILocation(line: 2, column: 3, scope: !7)
|
|
!12 = !DILocation(line: 3, column: 3, scope: !7)
|
|
!13 = !DILocation(line: 4, column: 3, scope: !7)
|