xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/live-debug-values-cutoffs.mir (revision 1dc0e47cb96a45fe8ca1576c603b0f8258b0e40b)
1# Test cutoffs for livedebugvalues debug range extension.
2# Disable LDV if the input-bb-limit AND the input-dbg-value-limit are both exceeded.
3
4# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
5# RUN:   -livedebugvalues-input-bb-limit=1 \
6# RUN:   -livedebugvalues-input-dbg-value-limit=1 \
7# RUN:   -experimental-debug-variable-locations=false \
8# RUN:   | FileCheck %s -check-prefix=LDV-DISABLED
9# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
10# RUN:   -experimental-debug-variable-locations \
11# RUN:   -livedebugvalues-input-bb-limit=1 \
12# RUN:   -livedebugvalues-input-dbg-value-limit=1 \
13# RUN:   | FileCheck %s -check-prefix=LDV-DISABLED
14
15# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
16# RUN:   -livedebugvalues-input-bb-limit=1 \
17# RUN:   -livedebugvalues-input-dbg-value-limit=10 \
18# RUN:   -experimental-debug-variable-locations=false \
19# RUN:   | FileCheck %s -check-prefix=LDV-ENABLED
20# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
21# RUN:   -experimental-debug-variable-locations \
22# RUN:   -livedebugvalues-input-bb-limit=1 \
23# RUN:   -livedebugvalues-input-dbg-value-limit=10 \
24# RUN:   | FileCheck %s -check-prefix=LDV-ENABLED
25
26# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
27# RUN:   -livedebugvalues-input-bb-limit=10 \
28# RUN:   -livedebugvalues-input-dbg-value-limit=1 \
29# RUN:   -experimental-debug-variable-locations=false \
30# RUN:   | FileCheck %s -check-prefix=LDV-ENABLED
31# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
32# RUN:   -experimental-debug-variable-locations \
33# RUN:   -livedebugvalues-input-bb-limit=10 \
34# RUN:   -livedebugvalues-input-dbg-value-limit=1 \
35# RUN:   | FileCheck %s -check-prefix=LDV-ENABLED
36
37# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
38# RUN:   -livedebugvalues-input-bb-limit=10 \
39# RUN:   -livedebugvalues-input-dbg-value-limit=10 \
40# RUN:   -experimental-debug-variable-locations=false \
41# RUN:   | FileCheck %s -check-prefix=LDV-ENABLED
42# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown \
43# RUN:   -experimental-debug-variable-locations \
44# RUN:   -livedebugvalues-input-bb-limit=10 \
45# RUN:   -livedebugvalues-input-dbg-value-limit=10 \
46# RUN:   | FileCheck %s -check-prefix=LDV-ENABLED
47
48# LDV-DISABLED-LABEL: bb.1.exit
49# LDV-DISABLED-NEXT: $edi = MOV32rm
50
51# LDV-ENABLED-LABEL: bb.1.exit
52# LDV-ENABLED-NEXT: DBG_VALUE $rsp, 0, {{.*}}, !DIExpression(DW_OP_plus_uconst, 4)
53# LDV-ENABLED-NEXT: $edi = MOV32rm
54
55--- |
56  target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
57
58  declare i32 @use(i32)
59
60  define i32 @foo(i32 %x) !dbg !6 {
61  entry:
62    %y = add i32 %x, %x, !dbg !12
63    call void @llvm.dbg.value(metadata i32 %y, metadata !9, metadata !DIExpression()), !dbg !12
64    br label %exit, !dbg !13
65
66  exit:                                             ; preds = %entry
67    %z = call i32 @use(i32 %y), !dbg !14
68    call void @llvm.dbg.value(metadata i32 %z, metadata !11, metadata !DIExpression()), !dbg !14
69    ret i32 %z, !dbg !15
70  }
71
72  declare void @llvm.dbg.value(metadata, metadata, metadata)
73
74  !llvm.dbg.cu = !{!0}
75  !llvm.debugify = !{!3, !4}
76  !llvm.module.flags = !{!5}
77
78  !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
79  !1 = !DIFile(filename: "/tmp/t.ll", directory: "/")
80  !2 = !{}
81  !3 = !{i32 4}
82  !4 = !{i32 2}
83  !5 = !{i32 2, !"Debug Info Version", i32 3}
84  !6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
85  !7 = !DISubroutineType(types: !2)
86  !8 = !{!9, !11}
87  !9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
88  !10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
89  !11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 3, type: !10)
90  !12 = !DILocation(line: 1, column: 1, scope: !6)
91  !13 = !DILocation(line: 2, column: 1, scope: !6)
92  !14 = !DILocation(line: 3, column: 1, scope: !6)
93  !15 = !DILocation(line: 4, column: 1, scope: !6)
94
95...
96---
97name:            foo
98liveins:
99  - { reg: '$edi', virtual-reg: '' }
100stack:
101  - { id: 0, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,
102      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
103      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
104body:             |
105  bb.0.entry:
106    successors: %bb.1(0x80000000)
107    liveins: $edi
108
109    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
110    CFI_INSTRUCTION def_cfa_offset 16
111    renamable $edi = ADD32rr renamable $edi, killed renamable $edi, implicit-def $eflags, debug-location !12
112    DBG_VALUE renamable $edi, $noreg, !9, !DIExpression(), debug-location !12
113    MOV32mr $rsp, 1, $noreg, 4, $noreg, killed $edi :: (store (s32) into %stack.0)
114    DBG_VALUE $rsp, 0, !9, !DIExpression(DW_OP_plus_uconst, 4), debug-location !12
115
116  bb.1.exit:
117    $edi = MOV32rm $rsp, 1, $noreg, 4, $noreg :: (load (s32) from %stack.0)
118    CALL64pcrel32 @use, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $eax, debug-location !14
119    DBG_VALUE renamable $eax, $noreg, !11, !DIExpression(), debug-location !14
120    $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15
121    RET64 implicit killed $eax, debug-location !15
122
123...
124