78 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes2; RUN: opt < %s -passes='loop-mssa(licm)' -S | FileCheck %s3; 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 %s4;5; Test that when we sink the store into the "Out" block, it lands in front of6; the dbg.value that we've left there.7;8target 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"9 10@X = global i32 7 ; <ptr> [#uses=4]11 12declare void @llvm.dbg.value(metadata, metadata, metadata)13 14define void @test1(i32 %i) {15; CHECK-LABEL: @test1(16; CHECK-NEXT: Entry:17; CHECK-NEXT: [[X_PROMOTED:%.*]] = load i32, ptr @X, align 418; CHECK-NEXT: br label [[LOOP:%.*]], !dbg [[DBG5:![0-9]+]]19; CHECK: Loop:20; CHECK-NEXT: [[X21:%.*]] = phi i32 [ [[X_PROMOTED]], [[ENTRY:%.*]] ], [ [[X2:%.*]], [[LOOP]] ], !dbg [[DBG5]]21; CHECK-NEXT: [[J:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[NEXT:%.*]], [[LOOP]] ]22; CHECK-NEXT: [[X2]] = add i32 [[X21]], 1, !dbg [[DBG5]]23; CHECK-NEXT: [[NEXT]] = add i32 [[J]], 1, !dbg [[DBG5]]24; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[NEXT]], 0, !dbg [[DBG5]]25; CHECK-NEXT: br i1 [[COND]], label [[OUT:%.*]], label [[LOOP]], !dbg [[DBG5]]26; CHECK: Out:27; CHECK-NEXT: [[X2_LCSSA:%.*]] = phi i32 [ [[X2]], [[LOOP]] ]28; CHECK-NEXT: store i32 [[X2_LCSSA]], ptr @X, align 4, !dbg [[DBG5]]29; CHECK-NEXT: #dbg_value(i32 0, [[META12:![0-9]+]], !DIExpression(), [[DBG5]])30; CHECK-NEXT: ret void, !dbg [[DBG5]]31;32Entry:33 br label %Loop, !dbg !1634 35Loop:36 %j = phi i32 [ 0, %Entry ], [ %Next, %Loop ]37 %x = load i32, ptr @X, !dbg !1638 %x2 = add i32 %x, 1, !dbg !1639 store i32 %x2, ptr @X, !dbg !1640 %Next = add i32 %j, 1, !dbg !1641 %cond = icmp eq i32 %Next, 0, !dbg !1642 br i1 %cond, label %Out, label %Loop, !dbg !1643 44Out:45 tail call void @llvm.dbg.value(metadata i32 0, metadata !11, metadata !DIExpression()), !dbg !1646 ret void, !dbg !1647}48 49!llvm.dbg.cu = !{!0}50!llvm.debugify = !{!2, !3}51!llvm.module.flags = !{!4}52 53!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)54!1 = !DIFile(filename: "dbg-value-sink.ll", directory: "/")55!2 = !{i32 9}56!3 = !{i32 5}57!4 = !{i32 2, !"Debug Info Version", i32 3}58!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)59!6 = !DISubroutineType(types: !7)60!7 = !{}61!8 = !{!9, !11, !12, !13, !14}62!9 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 2, type: !10)63!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)64!11 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 3, type: !10)65!12 = !DILocalVariable(name: "3", scope: !5, file: !1, line: 4, type: !10)66!13 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 6, type: !10)67!14 = !DILocalVariable(name: "5", scope: !5, file: !1, line: 7, type: !15)68!15 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned)69!16 = !DILocation(line: 1, column: 1, scope: !5)70!17 = !DILocation(line: 2, column: 1, scope: !5)71!18 = !DILocation(line: 3, column: 1, scope: !5)72!19 = !DILocation(line: 4, column: 1, scope: !5)73!20 = !DILocation(line: 5, column: 1, scope: !5)74!21 = !DILocation(line: 6, column: 1, scope: !5)75!22 = !DILocation(line: 7, column: 1, scope: !5)76!23 = !DILocation(line: 8, column: 1, scope: !5)77!24 = !DILocation(line: 9, column: 1, scope: !5)78