blob: fb0da1b50d11c1fff40068b2f5cc7753badc8063 [file] [log] [blame]
Matthias Braun372ee592017-04-19 23:10:43 +00001; RUN: llc -o - %s | FileCheck %s
2; This test checks that parameters on the stack pointer are correctly
3; referenced by debug info.
4target triple = "x86_64--"
5
6@glob = external global i64
7@ptr = external global i32*
8%struct.s = type { i32, i32, i32, i32, i32 }
9
10; CHECK-LABEL: f0:
Reid Kleckner9f299142017-05-09 01:14:39 +000011; CHECK: DEBUG_VALUE: f:input <- [%RSP+8]
Matthias Braun372ee592017-04-19 23:10:43 +000012define i32 @f0(%struct.s* byval align 8 %input) !dbg !8 {
13 call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !4, metadata !17), !dbg !18
Reid Kleckner9f299142017-05-09 01:14:39 +000014 ret i32 42
Matthias Braun372ee592017-04-19 23:10:43 +000015}
16
17; CHECK-LABEL: f1:
Reid Kleckner9f299142017-05-09 01:14:39 +000018; CHECK: DEBUG_VALUE: f:input <- [%RBP+16]
Adrian Prantldefc99a2017-05-04 16:24:31 +000019define i32 @f1(%struct.s* byval align 8 %input) !dbg !19 {
Matthias Braun372ee592017-04-19 23:10:43 +000020 %val = load i64, i64* @glob
21 ; this alloca should force FP usage.
22 %stackspace = alloca i32, i64 %val, align 1
23 store i32* %stackspace, i32** @ptr
Adrian Prantldefc99a2017-05-04 16:24:31 +000024 call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !20, metadata !17), !dbg !21
Reid Kleckner9f299142017-05-09 01:14:39 +000025 ret i32 42
Matthias Braun372ee592017-04-19 23:10:43 +000026}
27
28; CHECK-LABEL: f2:
29; Just check that we are indeed aligning the stack and setting up a base pointer
30; in RBX.
31; CHECK: pushq %rbp
32; CHECK: movq %rsp, %rbp
33; CHECK: pushq %rbx
34; CHECK: andq $-64, %rsp
35; CHECK: subq $64, %rsp
36; CHECK: movq %rsp, %rbx
Reid Kleckner9f299142017-05-09 01:14:39 +000037; The parameter should still be referenced through RBP though.
38; CHECK-NOT: DEBUG_VALUE: f:input <- [%RBX
39; CHECK: DEBUG_VALUE: f:input <- [%RBP+16]
Adrian Prantldefc99a2017-05-04 16:24:31 +000040define i32 @f2(%struct.s* byval align 8 %input) !dbg !22 {
Matthias Braun372ee592017-04-19 23:10:43 +000041 %val = load i64, i64* @glob
42 %stackspace = alloca i32, i64 %val, align 64
43 store i32* %stackspace, i32** @ptr
Adrian Prantldefc99a2017-05-04 16:24:31 +000044 call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !23, metadata !17), !dbg !24
Reid Kleckner9f299142017-05-09 01:14:39 +000045 ret i32 42
Matthias Braun372ee592017-04-19 23:10:43 +000046}
47
48declare void @llvm.dbg.declare(metadata, metadata, metadata)
49
50!llvm.dbg.cu = !{!2}
51!llvm.module.flags = !{!0, !1}
52
53!0 = !{i32 2, !"Dwarf Version", i32 4}
54!1 = !{i32 2, !"Debug Info Version", i32 3}
Reid Kleckner9f299142017-05-09 01:14:39 +000055!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
Matthias Braun372ee592017-04-19 23:10:43 +000056!3 = !DIFile(filename: "dbg-baseptr.ll", directory: "/")
57!4 = !DILocalVariable(name: "input", arg: 1, scope: !8, file: !3, line: 5, type: !9)
58!5 = !{}
59
60!6 = !DISubroutineType(types: !7)
61!7 = !{!10, !9}
62
Reid Kleckner9f299142017-05-09 01:14:39 +000063!8 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5)
Matthias Braun372ee592017-04-19 23:10:43 +000064
65!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", elements: !11)
66!10 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
67!11 = !{!12, !13, !14, !15, !16}
68!12 = !DIDerivedType(tag: DW_TAG_member, name: "a", baseType: !10, size: 32)
69!13 = !DIDerivedType(tag: DW_TAG_member, name: "b", baseType: !10, size: 32, offset: 32)
70!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", baseType: !10, size: 32, offset: 64)
71!15 = !DIDerivedType(tag: DW_TAG_member, name: "d", baseType: !10, size: 32, offset: 96)
72!16 = !DIDerivedType(tag: DW_TAG_member, name: "e", baseType: !10, size: 32, offset: 128)
73
74!17 = !DIExpression()
75!18 = !DILocation(line: 5, scope: !8)
Adrian Prantldefc99a2017-05-04 16:24:31 +000076
Reid Kleckner9f299142017-05-09 01:14:39 +000077!19 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5)
Adrian Prantldefc99a2017-05-04 16:24:31 +000078!20 = !DILocalVariable(name: "input", arg: 1, scope: !19, file: !3, line: 5, type: !9)
79!21 = !DILocation(line: 5, scope: !19)
Reid Kleckner9f299142017-05-09 01:14:39 +000080!22 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5)
Adrian Prantldefc99a2017-05-04 16:24:31 +000081!23 = !DILocalVariable(name: "input", arg: 1, scope: !22, file: !3, line: 5, type: !9)
82!24 = !DILocation(line: 5, scope: !22)