xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/live-debug-values-entry-transfer.mir (revision 92b33822e989884d29465d34769b07d78aeb1a84)
1# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown | FileCheck %s
2# RUN: llc %s -o - -force-instr-ref-livedebugvalues=1 -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown | FileCheck %s
3#
4# In this lightly modified test case, the transfer in the entry block from
5# geti32's return value in $eax to the non-volatile $ebx should be recognized,
6# and propagated throughout the whole function.
7#
8# CHECK-LABEL: bb.0.entry
9# CHECK:       DBG_VALUE $eax
10# CHECK:       DBG_VALUE $ebx
11# CHECK-LABEL: bb.1.loop2
12# CHECK:       DBG_VALUE $ebx
13# CHECK-LABEL: bb.2.loop
14# CHECK:       DBG_VALUE $ebx
15# CHECK-LABEL: bb.3.exit
16# CHECK:       DBG_VALUE $ebx
17--- |
18  ; ModuleID = 'asdf'
19  source_filename = "asdf.ll"
20  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21  target triple = "x86_64-unknown-unknown"
22
23  @glob = global i32 0
24
25  declare i1 @booler()
26
27  declare i32 @geti32()
28
29  declare void @escape(i32)
30
31  ; Function Attrs: nounwind readnone speculatable willreturn
32  declare void @llvm.dbg.value(metadata, metadata, metadata)
33
34  define i32 @foo() !dbg !4 {
35  entry:
36    %bar = call i32 @geti32(), !dbg !10
37    call void @llvm.dbg.value(metadata i32 %bar, metadata !9, metadata !DIExpression()), !dbg !10
38    br label %loop
39
40  loop:                                             ; preds = %loop2, %entry
41    call void @escape(i32 %bar)
42    %retval = call i1 @booler(), !dbg !10
43    br i1 %retval, label %loop2, label %exit
44
45  loop2:                                            ; preds = %loop
46    store i32 %bar, ptr @glob
47    br label %loop
48
49  exit:                                             ; preds = %loop
50    ret i32 %bar
51  }
52
53  ; Function Attrs: nounwind
54  declare void @llvm.stackprotector(ptr, ptr)
55
56  !llvm.module.flags = !{!0, !1}
57  !llvm.dbg.cu = !{!2}
58
59  !0 = !{i32 2, !"Debug Info Version", i32 3}
60  !1 = !{i32 2, !"Dwarf Version", i32 4}
61  !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "beards", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
62  !3 = !DIFile(filename: "bees.cpp", directory: ".")
63  !4 = distinct !DISubprogram(name: "nope", scope: !3, file: !3, line: 1, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
64  !5 = !DISubroutineType(types: !6)
65  !6 = !{!7}
66  !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
67  !8 = !{!9}
68  !9 = !DILocalVariable(name: "toast", scope: !4, file: !3, line: 1, type: !7)
69  !10 = !DILocation(line: 1, scope: !4)
70
71...
72---
73name:            foo
74tracksRegLiveness: true
75frameInfo:
76  stackSize:       8
77  offsetAdjustment: -8
78  adjustsStack:    true
79  hasCalls:        true
80  cvBytesOfCalleeSavedRegisters: 8
81fixedStack:
82  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
83      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
84      debug-info-expression: '', debug-info-location: '' }
85stack:           []
86body:             |
87  bb.0.entry:
88    successors: %bb.1(0x80000000)
89    liveins: $rbx
90
91    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp, debug-location !10
92    CFI_INSTRUCTION def_cfa_offset 16
93    CFI_INSTRUCTION offset $rbx, -16
94    CALL64pcrel32 @geti32, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !10
95    DBG_VALUE $eax, $noreg, !9, !DIExpression(), debug-location !10
96    $ebx = MOV32rr killed $eax, debug-location !10
97    JMP_1 %bb.1
98
99  bb.1.loop2:
100    successors: %bb.2
101    liveins: $ebx
102
103    MOV32mr $rip, 1, $noreg, @glob, $noreg, renamable $ebx :: (store (s32) into @glob)
104
105  bb.2.loop:
106    successors: %bb.1, %bb.3
107    liveins: $ebx
108
109    $edi = MOV32rr $ebx
110    CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $rsp, implicit-def $ssp
111    CALL64pcrel32 @booler, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $al, debug-location !10
112    TEST8ri killed renamable $al, 1, implicit-def $eflags
113    JCC_1 %bb.1, 5, implicit $eflags
114
115  bb.3.exit:
116    liveins: $ebx
117
118    $eax = MOV32rr killed $ebx
119    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
120    CFI_INSTRUCTION def_cfa_offset 8
121    RET64 $eax
122
123...
124