1# RUN: llc -mtriple=x86_64-none-linux-gnu -run-pass=postra-machine-sink -verify-machineinstrs -o - %s | FileCheck %s 2# 3# This test was originally generated from the following sample: 4# 5# int x0; 6# extern void x3(int, int); 7# void x1(int x2) { 8# if (x0) 9# x3(0, x2); 10# } 11# 12# The code generates a COPY instruction which the PostRA Machine Sink pass will 13# try to sink. Earlier versions were not performing the sink due to a 14# DBG_VALUE instruction confusing the sinking algorithm. 15 16--- | 17 @x0 = common dso_local global i32 0, align 4, !dbg !0 18 19 define dso_local void @x1(i32) !dbg !11 { 20 %2 = alloca i32, align 4 21 store i32 %0, i32* %2, align 4 22 call void @llvm.dbg.declare(metadata i32* %2, metadata !14, metadata !DIExpression()), !dbg !16 23 %3 = load i32, i32* @x0, align 4, !dbg !16 24 %4 = icmp ne i32 %3, 0, !dbg !16 25 br i1 %4, label %5, label %7, !dbg !16 26 27 ; <label>:5: ; preds = %1 28 %6 = load i32, i32* %2, align 4, !dbg !16 29 call void @x3(i32 0, i32 %6), !dbg !16 30 br label %7, !dbg !16 31 32 ; <label>:7: ; preds = %5, %1 33 ret void, !dbg !16 34 } 35 36 declare void @llvm.dbg.declare(metadata, metadata, metadata) 37 declare dso_local void @x3(i32, i32) 38 39 !llvm.dbg.cu = !{!2} 40 !llvm.module.flags = !{!7, !8} 41 42 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 43 !1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true) 44 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) 45 !3 = !DIFile(filename: "test.c", directory: "") 46 !4 = !{} 47 !5 = !{!0} 48 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 49 !7 = !{i32 2, !"Dwarf Version", i32 4} 50 !8 = !{i32 2, !"Debug Info Version", i32 3} 51 !11 = distinct !DISubprogram(name: "x1", scope: !3, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !2) 52 !12 = !DISubroutineType(types: !13) 53 !13 = !{null, !6} 54 !14 = !DILocalVariable(name: "x2", arg: 1, scope: !11, file: !3, line: 3, type: !6) 55 !15 = distinct !DILexicalBlock(scope: !11, file: !3, line: 4, column: 7) 56 !16 = !DILocation(line: 4, column: 7, scope: !15) 57 58... 59--- 60# CHECK: name: x1 61# CHECK: bb.0: 62# CHECK-NOT: $eax = COPY $edi 63# CHECK: bb.1: 64# CHECK: renamable $eax = COPY $edi 65# CHECK-NEXT: DBG_VALUE debug-use $eax, 66# CHECK: bb.2: 67name: x1 68alignment: 4 69tracksRegLiveness: true 70body: | 71 bb.0: 72 successors: %bb.2, %bb.1; %bb.2, %bb.1 73 liveins: $edi 74 DBG_VALUE debug-use $edi, debug-use $noreg, !14, !DIExpression(), debug-location !16 75 renamable $eax = COPY $edi 76 DBG_VALUE debug-use $eax, debug-use $noreg, !14, !DIExpression(), debug-location !16 77 CMP32mi8 $rip, 1, $noreg, @x0, $noreg, 0, implicit-def $eflags, debug-location !16 78 JE_1 %bb.2, implicit killed $eflags, debug-location !16 79 JMP_1 %bb.1, debug-location !16 80 81 bb.1: 82 liveins: $eax 83 $edi = MOV32r0 implicit-def dead $eflags, debug-location !16 84 $esi = COPY killed renamable $eax, debug-location !16 85 86 bb.2: 87 RET 0, debug-location !16 88... 89