1 # RUN: llc -mtriple=x86_64-unknown-unknown %s -run-pass=postra-machine-sink -o - | FileCheck %s
2 # Test that when we run the postra machine sinker (which sinks COPYs), that
3 # DBG_VALUEs of both sub and super-registers that depend on such COPYs are
6 ; Module stripped of everything, MIR below is what's interesting
8 source_filename = "justacall.cpp"
9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-unknown-linux-gnu"
12 ; Function Attrs: noinline norecurse nounwind uwtable
13 define dso_local i32 @main(i32 %argc, i8** nocapture readnone %argv) !dbg !14 {
21 !llvm.module.flags = !{!1, !1000}
23 !0 = !{!"dummy metadata"}
24 !1 = !{i32 2, !"Dwarf Version", i32 4}
25 !1000 = !{i32 2, !"Debug Info Version", i32 3}
26 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, nameTableKind: None)
27 !3 = !DIFile(filename: "justacall.cpp", directory: "/tmp")
29 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
30 !8 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed)
31 !9 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
32 !14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 7, type: !15, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !20)
33 !15 = !DISubroutineType(types: !16)
35 !20 = !{!21, !22, !23, !24}
36 !21 = !DILocalVariable(name: "argc", arg: 1, scope: !14, file: !3, line: 7, type: !7)
37 !22 = !DILocalVariable(name: "foo", scope: !14, file: !3, line: 7, type: !8)
38 !23 = !DILocalVariable(name: "bar", scope: !14, file: !3, line: 7, type: !7)
39 !24 = !DILocalVariable(name: "baz", scope: !14, file: !3, line: 7, type: !9)
40 !100 = !DILocation(line: 1, scope: !14)
45 tracksRegLiveness: true
48 - { reg: '$edi', virtual-reg: '' }
56 ; CHECK: ![[ARGVAR:[0-9]+]] = !DILocalVariable(name: "argc",
57 ; CHECK: ![[FOOVAR:[0-9]+]] = !DILocalVariable(name: "foo",
58 ; CHECK: ![[BARVAR:[0-9]+]] = !DILocalVariable(name: "bar",
59 ; CHECK: ![[BAZVAR:[0-9]+]] = !DILocalVariable(name: "baz",
61 ; In the following code, the:
62 ; DBG_VALUE of $edi should not sink: it's an argument
63 ; DBG_VALUE of $ebx should sink: it's a standard copy
64 ; DBG_VALUE of $bx should sink: a write of its superregister sinks
65 ; DBG_VALUE of $ecx should sink: a write of one of its subregisters sinks
67 ; CHECK-LABEL: name: main
69 ; CHECK: successors: %bb.1(0x80000000)
70 ; CHECK: liveins: $edi
71 ; CHECK: DBG_VALUE $edi, $noreg, ![[BARVAR]]
72 ; CHECK-NEXT: renamable $cl = MOV8ri 1
73 ; CHECK-NEXT: JMP_1 %bb.1
75 ; CHECK: liveins: $cl, $edi
76 ; CHECK: renamable $ebx = COPY $edi
77 ; CHECK-NEXT: DBG_VALUE $bx, $noreg, ![[BAZVAR]]
78 ; CHECK-NEXT: DBG_VALUE $ebx, $noreg, ![[ARGVAR]]
79 ; CHECK-NEXT: renamable $ch = COPY renamable $cl
80 ; CHECK-NEXT: DBG_VALUE $ecx, $noreg, ![[FOOVAR]]
81 ; CHECK-NEXT: $rdi = MOV32ri64 0
82 ; CHECK-NEXT: $eax = MOV32r0 implicit-def dead $eflags
83 ; CHECK-NEXT: RET 0, $eax
85 successors: %bb.1(0x40000000)
88 DBG_VALUE $edi, $noreg, !23, !DIExpression(), debug-location !100
89 renamable $ebx = COPY $edi
90 DBG_VALUE $ebx, $noreg, !21, !DIExpression(), debug-location !100
91 DBG_VALUE $bx, $noreg, !24, !DIExpression(), debug-location !100
92 renamable $cl = MOV8ri 1, debug-location !100
93 renamable $ch = COPY renamable $cl
94 DBG_VALUE $ecx, $noreg, !22, !DIExpression(), debug-location !100
101 $eax = MOV32r0 implicit-def dead $eflags