2017-04-20 01:10:43 +02:00
|
|
|
; RUN: llc -o - %s | FileCheck %s
|
2017-09-12 01:05:20 +02:00
|
|
|
; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s --check-prefix=DWARF
|
2017-04-20 01:10:43 +02:00
|
|
|
; This test checks that parameters on the stack pointer are correctly
|
|
|
|
; referenced by debug info.
|
|
|
|
target triple = "x86_64--"
|
|
|
|
|
|
|
|
@glob = external global i64
|
|
|
|
@ptr = external global i32*
|
|
|
|
%struct.s = type { i32, i32, i32, i32, i32 }
|
|
|
|
|
2017-05-09 18:02:20 +02:00
|
|
|
; Simple case: no FP, use offset from RSP.
|
|
|
|
|
2017-04-20 01:10:43 +02:00
|
|
|
; CHECK-LABEL: f0:
|
2017-05-09 18:02:20 +02:00
|
|
|
; CHECK-NOT: pushq
|
|
|
|
; CHECK: movl $42, %eax
|
|
|
|
; CHECK: retq
|
2017-04-20 01:10:43 +02:00
|
|
|
define i32 @f0(%struct.s* byval align 8 %input) !dbg !8 {
|
|
|
|
call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !4, metadata !17), !dbg !18
|
2017-05-09 18:02:20 +02:00
|
|
|
ret i32 42, !dbg !18
|
2017-04-20 01:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF-LABEL: .debug_info contents:
|
|
|
|
|
|
|
|
; DWARF-LABEL: DW_TAG_subprogram
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 23:41:21 +02:00
|
|
|
; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg7 RSP)
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f0")
|
|
|
|
; DWARF: DW_TAG_formal_parameter
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 23:41:21 +02:00
|
|
|
; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg +8)
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input")
|
|
|
|
|
|
|
|
|
|
|
|
; Dynamic alloca forces the use of RBP as the base pointer
|
|
|
|
|
2017-04-20 01:10:43 +02:00
|
|
|
; CHECK-LABEL: f1:
|
2017-05-09 18:02:20 +02:00
|
|
|
; CHECK: pushq %rbp
|
|
|
|
; CHECK: movl $42, %eax
|
|
|
|
; CHECK: popq %rbp
|
|
|
|
; CHECK: retq
|
2017-05-04 18:24:31 +02:00
|
|
|
define i32 @f1(%struct.s* byval align 8 %input) !dbg !19 {
|
2017-04-20 01:10:43 +02:00
|
|
|
%val = load i64, i64* @glob
|
|
|
|
; this alloca should force FP usage.
|
|
|
|
%stackspace = alloca i32, i64 %val, align 1
|
|
|
|
store i32* %stackspace, i32** @ptr
|
2017-05-04 18:24:31 +02:00
|
|
|
call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !20, metadata !17), !dbg !21
|
2017-05-09 18:02:20 +02:00
|
|
|
ret i32 42, !dbg !21
|
2017-04-20 01:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF-LABEL: DW_TAG_subprogram
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 23:41:21 +02:00
|
|
|
; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP)
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f1")
|
|
|
|
; DWARF: DW_TAG_formal_parameter
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 23:41:21 +02:00
|
|
|
; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg +16)
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input")
|
|
|
|
|
2017-04-20 01:10:43 +02:00
|
|
|
; CHECK-LABEL: f2:
|
|
|
|
; Just check that we are indeed aligning the stack and setting up a base pointer
|
|
|
|
; in RBX.
|
|
|
|
; CHECK: pushq %rbp
|
|
|
|
; CHECK: movq %rsp, %rbp
|
|
|
|
; CHECK: pushq %rbx
|
|
|
|
; CHECK: andq $-64, %rsp
|
|
|
|
; CHECK: subq $64, %rsp
|
|
|
|
; CHECK: movq %rsp, %rbx
|
2017-05-04 18:24:31 +02:00
|
|
|
define i32 @f2(%struct.s* byval align 8 %input) !dbg !22 {
|
2017-04-20 01:10:43 +02:00
|
|
|
%val = load i64, i64* @glob
|
|
|
|
%stackspace = alloca i32, i64 %val, align 64
|
|
|
|
store i32* %stackspace, i32** @ptr
|
2017-05-04 18:24:31 +02:00
|
|
|
call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !23, metadata !17), !dbg !24
|
2017-05-09 18:02:20 +02:00
|
|
|
ret i32 42, !dbg !24
|
2017-04-20 01:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-05-09 18:02:20 +02:00
|
|
|
; "input" should still be referred to through RBP.
|
|
|
|
; DWARF-LABEL: DW_TAG_subprogram
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 23:41:21 +02:00
|
|
|
; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP)
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f2")
|
|
|
|
; DWARF: DW_TAG_formal_parameter
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 23:41:21 +02:00
|
|
|
; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg +16)
|
2017-05-09 18:02:20 +02:00
|
|
|
; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input")
|
|
|
|
|
2017-04-20 01:10:43 +02:00
|
|
|
declare void @llvm.dbg.declare(metadata, metadata, metadata)
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!2}
|
|
|
|
!llvm.module.flags = !{!0, !1}
|
|
|
|
|
|
|
|
!0 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!1 = !{i32 2, !"Debug Info Version", i32 3}
|
2017-05-09 18:02:20 +02:00
|
|
|
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug)
|
2017-04-20 01:10:43 +02:00
|
|
|
!3 = !DIFile(filename: "dbg-baseptr.ll", directory: "/")
|
|
|
|
!4 = !DILocalVariable(name: "input", arg: 1, scope: !8, file: !3, line: 5, type: !9)
|
|
|
|
!5 = !{}
|
|
|
|
|
|
|
|
!6 = !DISubroutineType(types: !7)
|
|
|
|
!7 = !{!10, !9}
|
|
|
|
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
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
2018-05-09 04:40:45 +02:00
|
|
|
!8 = distinct !DISubprogram(name: "f0", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, unit: !2, retainedNodes: !5)
|
2017-04-20 01:10:43 +02:00
|
|
|
|
|
|
|
!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", elements: !11)
|
|
|
|
!10 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
|
|
|
|
!11 = !{!12, !13, !14, !15, !16}
|
|
|
|
!12 = !DIDerivedType(tag: DW_TAG_member, name: "a", baseType: !10, size: 32)
|
|
|
|
!13 = !DIDerivedType(tag: DW_TAG_member, name: "b", baseType: !10, size: 32, offset: 32)
|
|
|
|
!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", baseType: !10, size: 32, offset: 64)
|
|
|
|
!15 = !DIDerivedType(tag: DW_TAG_member, name: "d", baseType: !10, size: 32, offset: 96)
|
|
|
|
!16 = !DIDerivedType(tag: DW_TAG_member, name: "e", baseType: !10, size: 32, offset: 128)
|
|
|
|
|
|
|
|
!17 = !DIExpression()
|
|
|
|
!18 = !DILocation(line: 5, scope: !8)
|
2017-05-04 18:24:31 +02:00
|
|
|
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
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
2018-05-09 04:40:45 +02:00
|
|
|
!19 = distinct !DISubprogram(name: "f1", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, retainedNodes: !5)
|
2017-05-04 18:24:31 +02:00
|
|
|
!20 = !DILocalVariable(name: "input", arg: 1, scope: !19, file: !3, line: 5, type: !9)
|
|
|
|
!21 = !DILocation(line: 5, scope: !19)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
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
2018-05-09 04:40:45 +02:00
|
|
|
!22 = distinct !DISubprogram(name: "f2", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, retainedNodes: !5)
|
2017-05-04 18:24:31 +02:00
|
|
|
!23 = !DILocalVariable(name: "input", arg: 1, scope: !22, file: !3, line: 5, type: !9)
|
|
|
|
!24 = !DILocation(line: 5, scope: !22)
|