xref: /llvm-project/llvm/test/DebugInfo/MIR/InstrRef/spill-slot-limits.mir (revision d53425e2a33a0ff7336c86d3f668b1855c47a6de)
1# RUN: llc %s -o - -experimental-debug-variable-locations \
2# RUN:     -mtriple=x86_64-unknown-unknown \
3# RUN:     -run-pass=livedebugvalues -livedebugvalues-max-stack-slots=0  | \
4# RUN: FileCheck %s --implicit-check-not=DBG_VALUE
5# RUN: llc %s -o - -experimental-debug-variable-locations \
6# RUN:     -mtriple=x86_64-unknown-unknown \
7# RUN:     -run-pass=livedebugvalues -livedebugvalues-max-stack-slots=100  | \
8# RUN: FileCheck %s --check-prefixes=NOLIMIT --implicit-check-not=DBG_VALUE
9#
10# Test that spills of live values to the stack are NOT tracked by
11# LiveDebugValues if an internal accounting limit is exceeded -- in this test,
12# set to zero. This is to avoid scenarios where we track thousands of stack
13# slots, which can show up with autogenerated code and/or asan.
14#
15# This is a copy of livedebugvalues_stackslot_subregs.mir, here the stack slot
16#  limit is set to zero, meaning the spill shouldn't be tracked.
17#
18## Capture variable num,
19# CHECK: ![[VARNUM:[0-9]+]] = !DILocalVariable
20#
21## There should be no variable location, just a single DBG_VALUE $noreg.
22# CHECK:     DBG_VALUE_LIST {{.+}} $noreg
23#
24## And then another.
25# CHECK:     DBG_VALUE_LIST {{.+}} $noreg
26#
27## Test that if there's no limit, we _do_ get some locations.
28# NOLIMIT:      DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
29# NOLIMIT-NEXT: DBG_VALUE_LIST {{.+}} $esi
30#
31# NOLIMIT:      DBG_INSTR_REF {{.+}}, dbg-instr-ref(5,
32# NOLIMIT-NEXT: DBG_VALUE_LIST {{.+}} $rsp
33--- |
34  define i8 @test(i32 %bar) local_unnamed_addr !dbg !7 {
35  entry:
36    ret i8 0, !dbg !12
37  }
38
39  declare dso_local void @ext(i64)
40
41  !llvm.dbg.cu = !{!0}
42  !llvm.module.flags = !{!3, !4, !5, !6}
43  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
44  !1 = !DIFile(filename: "foo.cpp", directory: ".")
45  !2 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed)
46  !3 = !{i32 2, !"Dwarf Version", i32 4}
47  !4 = !{i32 2, !"Debug Info Version", i32 3}
48  !5 = !{i32 1, !"wchar_size", i32 2}
49  !6 = !{i32 7, !"PIC Level", i32 2}
50  !7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
51  !8 = !DISubroutineType(types: !9)
52  !9 = !{!2, !2}
53  !10 = !{!11}
54  !11 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 7, type: !2)
55  !12 = !DILocation(line: 10, scope: !7)
56...
57---
58name: test
59tracksRegLiveness: true
60debugInstrRef: true
61liveins:
62  - { reg: '$rdi', virtual-reg: '' }
63stack:
64  - { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
65      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
66      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
67body:  |
68  bb.0:
69  liveins: $rdi, $rax, $rbx
70    $eax = MOV32ri 0, debug-instr-number 1
71    $edi = COPY $eax
72    MOV64mr $rsp, 1, $noreg, 16, $noreg, $rdi :: (store 8 into %stack.0)
73    $rsi = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
74
75    MOV64mr $rsp, 1, $noreg, 16, $noreg, $rbx :: (store 8 into %stack.0)
76    $rax = MOV64ri 0
77    $rdi = MOV64ri 0
78
79    DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !12
80    ; This shouldn't find anything -- we have disabled tracking of spills.
81
82    ; In addition to plain spills, spills that are folded into instructions
83    ; shouldn't be tracked either.
84    INC32m $rsp, 1, $noreg, 4, $noreg, implicit-def dead $eflags, debug-instr-number 5, debug-location !12 :: (store (s32) into %stack.0)
85
86
87    DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 1000000), debug-location !12
88    ; Shouldn't be able to find the reference to instr 5's memory operand.
89
90    RET64 $rsi, debug-location !12
91...
92