1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes 2; RUN: opt < %s -passes='loop-mssa(licm)' -S | FileCheck %s 3; RUN: opt < %s -passes='loop-mssa(licm)' -S --try-experimental-debuginfo-iterators | FileCheck %s 4; RUN: opt -aa-pipeline=tbaa,basic-aa -passes='require<aa>,require<target-ir>,require<scalar-evolution>,require<opt-remark-emit>,loop-mssa(licm)' -S %s | FileCheck %s 5; RUN: opt -aa-pipeline=tbaa,basic-aa -passes='require<aa>,require<target-ir>,require<scalar-evolution>,require<opt-remark-emit>,loop-mssa(licm)' -S %s --try-experimental-debuginfo-iterators| FileCheck %s 6; 7; Test that when we sink the store into the "Out" block, it lands in front of 8; the dbg.value that we've left there. 9; 10target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" 11 12@X = global i32 7 ; <ptr> [#uses=4] 13 14declare void @llvm.dbg.value(metadata, metadata, metadata) 15 16define void @test1(i32 %i) { 17; CHECK-LABEL: @test1( 18; CHECK-NEXT: Entry: 19; CHECK-NEXT: [[X_PROMOTED:%.*]] = load i32, ptr @X, align 4 20; CHECK-NEXT: br label [[LOOP:%.*]], !dbg [[DBG5:![0-9]+]] 21; CHECK: Loop: 22; CHECK-NEXT: [[X21:%.*]] = phi i32 [ [[X_PROMOTED]], [[ENTRY:%.*]] ], [ [[X2:%.*]], [[LOOP]] ], !dbg [[DBG5]] 23; CHECK-NEXT: [[J:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[NEXT:%.*]], [[LOOP]] ] 24; CHECK-NEXT: [[X2]] = add i32 [[X21]], 1, !dbg [[DBG5]] 25; CHECK-NEXT: [[NEXT]] = add i32 [[J]], 1, !dbg [[DBG5]] 26; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[NEXT]], 0, !dbg [[DBG5]] 27; CHECK-NEXT: br i1 [[COND]], label [[OUT:%.*]], label [[LOOP]], !dbg [[DBG5]] 28; CHECK: Out: 29; CHECK-NEXT: [[X2_LCSSA:%.*]] = phi i32 [ [[X2]], [[LOOP]] ] 30; CHECK-NEXT: store i32 [[X2_LCSSA]], ptr @X, align 4, !dbg [[DBG5]] 31; CHECK-NEXT: #dbg_value(i32 0, [[META12:![0-9]+]], !DIExpression(), [[DBG5]]) 32; CHECK-NEXT: ret void, !dbg [[DBG5]] 33; 34Entry: 35 br label %Loop, !dbg !16 36 37Loop: 38 %j = phi i32 [ 0, %Entry ], [ %Next, %Loop ] 39 %x = load i32, ptr @X, !dbg !16 40 %x2 = add i32 %x, 1, !dbg !16 41 store i32 %x2, ptr @X, !dbg !16 42 %Next = add i32 %j, 1, !dbg !16 43 %cond = icmp eq i32 %Next, 0, !dbg !16 44 br i1 %cond, label %Out, label %Loop, !dbg !16 45 46Out: 47 tail call void @llvm.dbg.value(metadata i32 0, metadata !11, metadata !DIExpression()), !dbg !16 48 ret void, !dbg !16 49} 50 51!llvm.dbg.cu = !{!0} 52!llvm.debugify = !{!2, !3} 53!llvm.module.flags = !{!4} 54 55!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 56!1 = !DIFile(filename: "dbg-value-sink.ll", directory: "/") 57!2 = !{i32 9} 58!3 = !{i32 5} 59!4 = !{i32 2, !"Debug Info Version", i32 3} 60!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) 61!6 = !DISubroutineType(types: !7) 62!7 = !{} 63!8 = !{!9, !11, !12, !13, !14} 64!9 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 2, type: !10) 65!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) 66!11 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 3, type: !10) 67!12 = !DILocalVariable(name: "3", scope: !5, file: !1, line: 4, type: !10) 68!13 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 6, type: !10) 69!14 = !DILocalVariable(name: "5", scope: !5, file: !1, line: 7, type: !15) 70!15 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned) 71!16 = !DILocation(line: 1, column: 1, scope: !5) 72!17 = !DILocation(line: 2, column: 1, scope: !5) 73!18 = !DILocation(line: 3, column: 1, scope: !5) 74!19 = !DILocation(line: 4, column: 1, scope: !5) 75!20 = !DILocation(line: 5, column: 1, scope: !5) 76!21 = !DILocation(line: 6, column: 1, scope: !5) 77!22 = !DILocation(line: 7, column: 1, scope: !5) 78!23 = !DILocation(line: 8, column: 1, scope: !5) 79!24 = !DILocation(line: 9, column: 1, scope: !5) 80