1 # RUN: llc -run-pass livedebugvalues -march=x86-64 -o - %s | FileCheck %s
3 # Generated from the following source with:
4 # clang -g -mllvm -stop-before=livedebugvalues -S -O2 test.c -o test.mir
6 # #define FORCE_SPILL() \
7 # __asm volatile("" : : : \
8 # "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \
9 # "r9", "r10", "r11", "r12", "r13", "r14", "r15")
17 # Ascertain that the spill has been recognized and manifested in a DBG_VALUE.
18 # CHECK: MOV64mr $rsp,{{.*-8.*}}killed{{.*}}$rdi :: (store 8 into %stack.0)
19 # CHECK-NEXT: DBG_VALUE $rsp,{{.*}}![[MDIX:[0-9]+]],{{.*}}!DIExpression(DW_OP_constu, 8, DW_OP_minus)
21 # Check for the restore.
22 # CHECK: $rdi = MOV64rm $rsp,{{.*-8.*}}:: (load 8 from %stack.0)
23 # CHECK-NEXT: DBG_VALUE $rdi,{{.*}}![[MDIX]], !DIExpression()
26 define dso_local i32 @f(i32* readonly %p) local_unnamed_addr !dbg !7 {
28 call void @llvm.dbg.value(metadata i32* %p, metadata !13, metadata !DIExpression()), !dbg !14
29 %tobool = icmp eq i32* %p, null, !dbg !15
30 br i1 %tobool, label %if.end, label %if.then, !dbg !17
32 if.then: ; preds = %entry
33 tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !18, !srcloc !20
34 br label %if.end, !dbg !21
36 if.end: ; preds = %entry, %if.then
37 %add.ptr = getelementptr inbounds i32, i32* %p, i64 1, !dbg !22
38 %0 = load i32, i32* %add.ptr, align 4, !dbg !23, !tbaa !24
42 declare void @llvm.dbg.value(metadata, metadata, metadata)
45 !llvm.module.flags = !{!3, !4, !5}
48 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 57a6ce7ac318de98e3e777e09cb9ed8282b5cc03) (https://git.llvm.org/git/llvm.git/ ff54a19e4912d7f15cb02798a7f2048441bff751)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
49 !1 = !DIFile(filename: "test2.c", directory: "/home/test")
51 !3 = !{i32 2, !"Dwarf Version", i32 4}
52 !4 = !{i32 2, !"Debug Info Version", i32 3}
53 !5 = !{i32 1, !"wchar_size", i32 4}
54 !6 = !{!"clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 57a6ce7ac318de98e3e777e09cb9ed8282b5cc03) (https://git.llvm.org/git/llvm.git/ ff54a19e4912d7f15cb02798a7f2048441bff751)"}
55 !7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
56 !8 = !DISubroutineType(types: !9)
58 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
59 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
61 !13 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 5, type: !11)
62 !14 = !DILocation(line: 5, column: 12, scope: !7)
63 !15 = !DILocation(line: 6, column: 7, scope: !16)
64 !16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 6, column: 7)
65 !17 = !DILocation(line: 6, column: 7, scope: !7)
66 !18 = !DILocation(line: 7, column: 5, scope: !19)
67 !19 = distinct !DILexicalBlock(scope: !16, file: !1, line: 6, column: 10)
68 !20 = !{i32 -2147471544}
69 !21 = !DILocation(line: 8, column: 3, scope: !19)
70 !22 = !DILocation(line: 9, column: 14, scope: !7)
71 !23 = !DILocation(line: 9, column: 10, scope: !7)
72 !24 = !{!25, !25, i64 0}
73 !25 = !{!"int", !26, i64 0}
74 !26 = !{!"omnipotent char", !27, i64 0}
75 !27 = !{!"Simple C/C++ TBAA"}
76 !28 = !DILocation(line: 9, column: 3, scope: !7)
82 exposesReturnsTwice: false
84 regBankSelected: false
87 tracksRegLiveness: true
91 - { reg: '$rdi', virtual-reg: '' }
93 isFrameAddressTaken: false
94 isReturnAddressTaken: false
104 cvBytesOfCalleeSavedRegisters: 48
105 hasOpaqueSPAdjustment: false
107 hasMustTailInVarArgFunc: false
112 - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
113 callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
114 debug-info-expression: '', debug-info-location: '' }
115 - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
116 callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
117 debug-info-expression: '', debug-info-location: '' }
118 - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
119 callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
120 debug-info-expression: '', debug-info-location: '' }
121 - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
122 callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
123 debug-info-expression: '', debug-info-location: '' }
124 - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
125 callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
126 debug-info-expression: '', debug-info-location: '' }
127 - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
128 callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
129 debug-info-expression: '', debug-info-location: '' }
131 - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
132 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
133 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
137 successors: %bb.2(0x30000000), %bb.1(0x50000000)
138 liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
140 DBG_VALUE $rdi, $noreg, !13, !DIExpression(), debug-location !14
141 DBG_VALUE $rdi, $noreg, !13, !DIExpression(), debug-location !14
142 TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !15
143 JCC_1 %bb.2, 4, implicit $eflags, debug-location !17
146 successors: %bb.2(0x80000000)
147 liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx
149 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
150 CFI_INSTRUCTION def_cfa_offset 16
151 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
152 CFI_INSTRUCTION def_cfa_offset 24
153 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
154 CFI_INSTRUCTION def_cfa_offset 32
155 frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
156 CFI_INSTRUCTION def_cfa_offset 40
157 frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
158 CFI_INSTRUCTION def_cfa_offset 48
159 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
160 CFI_INSTRUCTION def_cfa_offset 56
161 CFI_INSTRUCTION offset $rbx, -56
162 CFI_INSTRUCTION offset $r12, -48
163 CFI_INSTRUCTION offset $r13, -40
164 CFI_INSTRUCTION offset $r14, -32
165 CFI_INSTRUCTION offset $r15, -24
166 CFI_INSTRUCTION offset $rbp, -16
167 MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store 8 into %stack.0)
168 INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !20, debug-location !18
169 renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load 8 from %stack.0)
170 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
171 CFI_INSTRUCTION def_cfa_offset 48
172 $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
173 CFI_INSTRUCTION def_cfa_offset 40
174 $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
175 CFI_INSTRUCTION def_cfa_offset 32
176 $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
177 CFI_INSTRUCTION def_cfa_offset 24
178 $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
179 CFI_INSTRUCTION def_cfa_offset 16
180 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
181 CFI_INSTRUCTION def_cfa_offset 8
184 liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
186 renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !23 :: (load 4 from %ir.add.ptr, !tbaa !24)
187 RETQ $eax, debug-location !28