1 # RUN: llc %s -o - -run-pass=machine-sink -mtriple=x86_64-- | FileCheck %s
2 # This is a copy of test/CodeGen/X86/MachineSink-DbgValue.ll, where we
3 # additionally test that when the MOV32rm defining %0 is sunk, it leaves
4 # an 'undef' DBG_VALUE behind to terminate earlier location ranges.
6 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-apple-macosx10.7.0"
9 ; Function Attrs: nounwind readonly ssp uwtable
10 define i32 @foo(i32 %i, i32* nocapture %c) !dbg !4 {
11 call void @llvm.dbg.value(metadata i32 %i, metadata !9, metadata !DIExpression()), !dbg !14
12 %ab = load i32, i32* %c, align 1, !dbg !15
13 call void @llvm.dbg.value(metadata i32* %c, metadata !10, metadata !DIExpression()), !dbg !16
14 call void @llvm.dbg.value(metadata i32 %ab, metadata !12, metadata !DIExpression()), !dbg !15
15 %cd = icmp eq i32 %i, 42, !dbg !17
16 br i1 %cd, label %bb1, label %bb2, !dbg !17
19 %gh = add nsw i32 %ab, 2, !dbg !18
20 br label %bb2, !dbg !18
22 bb2: ; preds = %bb1, %0
23 %.0 = phi i32 [ %gh, %bb1 ], [ 0, %0 ]
27 ; Function Attrs: nounwind readnone speculatable
28 declare void @llvm.dbg.value(metadata, metadata, metadata)
30 ; Function Attrs: nounwind
31 declare void @llvm.stackprotector(i8*, i8**)
34 !llvm.module.flags = !{!3}
36 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
37 !1 = !DIFile(filename: "a.c", directory: "/private/tmp")
39 !3 = !{i32 1, !"Debug Info Version", i32 3}
40 !4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !5, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
41 !5 = !DISubroutineType(types: !6)
43 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
45 !9 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 2, type: !7)
46 !10 = !DILocalVariable(name: "c", arg: 2, scope: !4, file: !1, line: 2, type: !11)
47 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !0, baseType: !7, size: 64, align: 64)
48 !12 = !DILocalVariable(name: "a", scope: !13, file: !1, line: 3, type: !7)
49 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 25)
50 !14 = !DILocation(line: 2, column: 13, scope: !4)
51 !15 = !DILocation(line: 3, column: 14, scope: !13)
52 !16 = !DILocation(line: 2, column: 22, scope: !4)
53 !17 = !DILocation(line: 4, column: 3, scope: !13)
54 !18 = !DILocation(line: 5, column: 5, scope: !13)
55 !19 = !DILocation(line: 7, column: 1, scope: !13)
56 ; CHECK: ![[VARNUM:[0-9]+]] = !DILocalVariable(name: "a",
61 tracksRegLiveness: true
63 - { id: 0, class: gr32 }
64 - { id: 1, class: gr32 }
65 - { id: 2, class: gr32 }
66 - { id: 3, class: gr32 }
67 - { id: 4, class: gr64 }
68 - { id: 5, class: gr32 }
69 - { id: 6, class: gr32 }
71 - { reg: '$edi', virtual-reg: '%3' }
72 - { reg: '$rsi', virtual-reg: '%4' }
75 successors: %bb.1, %bb.2
77 ; CHECK-LABEL: bb.0 (%ir-block.0):
78 ; CHECK: DBG_VALUE $noreg, $noreg, ![[VARNUM]]
80 DBG_VALUE $edi, $noreg, !9, !DIExpression(), debug-location !14
81 DBG_VALUE $rsi, $noreg, !10, !DIExpression(), debug-location !16
83 DBG_VALUE %4, $noreg, !10, !DIExpression(), debug-location !16
85 DBG_VALUE %3, $noreg, !9, !DIExpression(), debug-location !14
86 %0:gr32 = MOV32rm %4, 1, $noreg, 0, $noreg, debug-location !15 :: (load (s32) from %ir.c, align 1)
87 DBG_VALUE %0, $noreg, !12, !DIExpression(), debug-location !15
88 %5:gr32 = MOV32r0 implicit-def dead $eflags
89 %6:gr32 = SUB32ri8 %3, 42, implicit-def $eflags, debug-location !17
90 JCC_1 %bb.2, 5, implicit $eflags, debug-location !17
91 JMP_1 %bb.1, debug-location !17
94 ; CHECK-LABEL: bb.1.bb1:
95 ; CHECK: %[[VREG:[0-9]+]]:gr32 = MOV32rm
96 ; CHECK-NEXT: DBG_VALUE %[[VREG]], $noreg, ![[VARNUM]]
97 ; CHECK-NEXT: ADD32ri8
98 %1:gr32 = nsw ADD32ri8 %0, 2, implicit-def dead $eflags, debug-location !18
101 %2:gr32 = PHI %5, %bb.0, %1, %bb.1
102 $eax = COPY %2, debug-location !19
103 RET 0, $eax, debug-location !19