1--- |
2  ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations -emulate-old-livedebugvalues=0 | FileCheck %s -implicit-check-not=DBG_VALUE
3
4  ; Sometimes, variables can have multiple locations, and when control flow
5  ; merges LiveDebugValues has a hard time picking which one the variable lives
6  ; in. Test two of these scenarios that old LiveDebugValues can't handle: when
7  ; a value is in two registers, and when a value is both in a register and
8  ; on the stack.
9
10  ; In a register:
11
12  ; CHECK-LABEL: bb.0.entry:
13  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
14  ; CHECK-LABEL: bb.1.bb1:
15  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
16  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
17  ; CHECK-LABEL: bb.2.bb2:
18  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
19  ; CHECK-LABEL: bb.3.bb3:
20  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
21
22  ; On the stack: we move from $rbp to a stack slot in bb4, but join back on
23  ; $rbp in bb6.
24
25  ; CHECK-LABEL: bb.4:
26  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
27  ; CHECK:       DBG_VALUE $rsp, 0, !16, !DIExpression()
28  ; CHECK-LABEL: bb.5:
29  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
30  ; CHECK-LABEL: bb.6:
31  ; CHECK:       DBG_VALUE $rbp, $noreg, !16, !DIExpression()
32
33  declare i64 @bees(i64 %arg);
34
35  define i32 @_Z8bb_to_bb(i64 %arg) local_unnamed_addr !dbg !12 {
36  entry:
37    br label %bb1, !dbg !17
38  bb1:
39    br label %bb2, !dbg !17
40  bb2:
41    br label %bb3, !dbg !17
42  bb3:
43    ret i32 0, !dbg !17
44  }
45
46  !llvm.dbg.cu = !{!0}
47  !llvm.module.flags = !{!7, !8, !9, !10}
48  !llvm.ident = !{!11}
49  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None)
50  !1 = !DIFile(filename: "main.cpp", directory: "F:\")
51  !2 = !{}
52  !3 = !{!4}
53  !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
54  !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
55  !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
56  !7 = !{i32 2, !"Dwarf Version", i32 4}
57  !8 = !{i32 2, !"Debug Info Version", i32 3}
58  !9 = !{i32 1, !"wchar_size", i32 2}
59  !10 = !{i32 7, !"PIC Level", i32 2}
60  !11 = !{!"clang version 10.0.0"}
61  !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
62  !13 = !DISubroutineType(types: !14)
63  !14 = !{!6, !6}
64  !15 = !{!16}
65  !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
66  !17 = !DILocation(line: 10, scope: !12)
67
68...
69---
70name: _Z8bb_to_bb
71tracksRegLiveness: true
72liveins:
73  - { reg: '$rdi', virtual-reg: '' }
74stack:
75  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
76      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
77      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
78body:  |
79  bb.0.entry:
80  liveins: $rdi
81    successors: %bb.1, %bb.2
82    $rbp = MOV64rr $rdi, debug-location !17
83    DBG_VALUE $rbp, $noreg, !16, !DIExpression(), debug-location !17
84    dead $rcx = MOV64ri 0, debug-location !17
85    CALL64pcrel32 @bees, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $rax, debug-location !17
86    CMP64ri8 renamable $rax, 1, implicit-def $eflags, debug-location !17
87    JCC_1 %bb.2, 4, implicit killed $eflags, debug-location !17
88  bb.1.bb1:
89  liveins: $rax, $rbp
90    successors: %bb.3
91    $rbp = MOV64ri 0, debug-location !17
92    DBG_VALUE $rbp, $noreg, !16, !DIExpression(), debug-location !17
93    JMP_1 %bb.3
94  bb.2.bb2:
95  liveins: $rax, $rbp
96    successors: %bb.3
97    $rax = MOV64ri 0, debug-location !17
98  bb.3.bb3:
99  liveins: $rax, $rbp
100    $rdi = MOV64rr $rbp, debug-location !17
101    CALL64pcrel32 @bees, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $rax, debug-location !17
102    CMP64ri8 renamable $rax, 1, implicit-def $eflags, debug-location !17
103    JCC_1 %bb.5, 4, implicit killed $eflags, debug-location !17
104  bb.4:
105  liveins: $rax, $rbp
106    MOV64mr $rsp, 1, $noreg, 8, $noreg, killed renamable $rbp :: (store (s64) into %stack.0)
107    JMP_1 %bb.6
108  bb.5:
109  liveins: $rax, $rbp
110  bb.6:
111  liveins: $rax, $rbp
112    RETQ $rax, debug-location !17
113...
114