xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/live-debug-values-bad-transfer.mir (revision 9f8544713ad8e57fb74cbfce3fbc7fff523e549f)
1# RUN: llc %s -mtriple=x86_64-unknown-unknown -o - -run-pass=livedebugvalues -experimental-debug-variable-locations=true | FileCheck %s -check-prefix=NEWLDV --implicit-check-not=DBG_VALUE
2#
3# Test that the DBG_VALUE of ecx below does not get propagated. It is considered
4# live-in on LiveDebugValues' first pass through the loop, but on the second it
5# should be removed from the InLocs set because it gets clobbered inside the
6# loop. There should be no transfer from ecx to ebx -- this is ensured by the
7# FileCheck implicit-check-not option.
8#
9# An identical test in llvm/test/DebugInfo/MIR/X86/live-debug-values-bad-transfer2.mir
10# checks this for VarLocBasedLDV.
11#
12# NEWLDV-LABEL: name: foo
13# NEWLDV-LABEL: bb.0.entry:
14# NEWLDV:       $ecx = MOV32ri 0
15# NEWLDV-NEXT:  DBG_VALUE
16
17--- |
18  source_filename = "live-debug-values-remove-range.ll"
19  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20
21  declare void @llvm.dbg.value(metadata, metadata, metadata)
22
23  define i32 @foo(i32 %bar) !dbg !4 {
24  entry:
25    br label %loop
26  loop:
27    br label %loop
28  exit:
29    ret i32 %bar
30  }
31
32  !llvm.module.flags = !{!0, !1}
33  !llvm.dbg.cu = !{!2}
34
35  !0 = !{i32 2, !"Debug Info Version", i32 3}
36  !1 = !{i32 2, !"Dwarf Version", i32 4}
37  !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "beards", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
38  !3 = !DIFile(filename: "bees.cpp", directory: ".")
39  !4 = distinct !DISubprogram(name: "nope", scope: !3, file: !3, line: 1, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
40  !5 = !DISubroutineType(types: !6)
41  !6 = !{!7}
42  !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
43  !8 = !{!9}
44  !9 = !DILocalVariable(name: "thin", scope: !4, file: !3, line: 1, type: !7)
45  !10 = !DILocation(line: 1, scope: !4)
46
47...
48---
49name:            foo
50alignment:       4
51tracksRegLiveness: true
52debugInstrRef: true
53liveins:
54  - { reg: '$edi' }
55frameInfo:
56  stackSize:       8
57  offsetAdjustment: -8
58  maxAlignment:    1
59  adjustsStack:    true
60  hasCalls:        true
61  maxCallFrameSize: 0
62  cvBytesOfCalleeSavedRegisters: 8
63fixedStack:
64  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$rbx' }
65machineFunctionInfo: {}
66body:             |
67  bb.0.entry:
68    liveins: $edi, $rbx
69
70    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
71    CFI_INSTRUCTION def_cfa_offset 16
72    CFI_INSTRUCTION offset $rbx, -16
73    $ebx = MOV32rr $edi
74    $eax = MOV32ri 0, debug-location !10
75    $ecx = MOV32ri 0, debug-location !10
76    DBG_VALUE $ecx, $noreg, !9, !DIExpression(), debug-location !10
77    $edi = MOV32ri 0, debug-location !10
78    $esi = MOV32ri 0, debug-location !10
79
80  bb.1.loop:
81    successors: %bb.1, %bb.2
82    liveins: $ebx, $eax, $ecx, $edi, $esi
83
84    $eax = COPY $ecx, debug-location !10
85    $ebx = COPY killed $ecx, debug-location !10
86    $ecx = COPY killed $edi, debug-location !10
87    $edi = COPY killed $esi, debug-location !10
88    $esi = MOV32ri 1, debug-location !10
89    TEST8ri killed renamable $al, 1, implicit-def $eflags
90    JCC_1 %bb.1, 5, implicit killed $eflags, debug-location !10
91
92  bb.2.exit:
93    liveins: $ebx
94
95    $eax = MOV32rr killed $ebx, debug-location !10
96    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
97    CFI_INSTRUCTION def_cfa_offset 8
98    RET64 $eax, debug-location !10
99
100...
101