|
| 1 | +; RUN: opt -S -passes=loop-reduce -mtriple=x86_64-unknown-unknown < %s | FileCheck %s |
| 2 | + |
| 3 | +; Check that LoopStrengthReduce's OptimizeShadowIV() propagates the debug |
| 4 | +; locations of the old phi (`%accum`) and binop (`%accum.next`) instruction |
| 5 | +; to the new phi and binop instruction, respectively. |
| 6 | + |
| 7 | +target datalayout = "n8:16:32:64" |
| 8 | + |
| 9 | +define i32 @foobar6() !dbg !5 { |
| 10 | +; CHECK-LABEL: define i32 @foobar6( |
| 11 | +; CHECK: loop: |
| 12 | +; CHECK: [[IV_S_:%.*]] = phi double [ -3.220000e+03, %[[ENTRY:.*]] ], [ [[IV_S_NEXT_:%.*]], %loop ], !dbg [[DBG9:![0-9]+]] |
| 13 | +; CHECK: [[IV_S_NEXT_]] = fadd double [[IV_S_]], 0x41624E65A0000000, !dbg [[DBG11:![0-9]+]] |
| 14 | +; CHECK: exit: |
| 15 | +; |
| 16 | +entry: |
| 17 | + br label %loop, !dbg !8 |
| 18 | + |
| 19 | +loop: ; preds = %loop, %entry |
| 20 | + %accum = phi i32 [ -3220, %entry ], [ %accum.next, %loop ], !dbg !9 |
| 21 | + %iv = phi i32 [ 12, %entry ], [ %iv.next, %loop ], !dbg !10 |
| 22 | + %tmp1 = sitofp i32 %accum to double, !dbg !11 |
| 23 | + tail call void @foo(double %tmp1), !dbg !12 |
| 24 | + %accum.next = add nsw i32 %accum, 9597741, !dbg !13 |
| 25 | + %iv.next = add nuw nsw i32 %iv, 1, !dbg !14 |
| 26 | + %exitcond = icmp ugt i32 %iv, 235, !dbg !15 |
| 27 | + br i1 %exitcond, label %exit, label %loop, !dbg !16 |
| 28 | + |
| 29 | +exit: ; preds = %loop |
| 30 | + ret i32 %accum.next, !dbg !17 |
| 31 | +} |
| 32 | + |
| 33 | +declare void @foo(double) |
| 34 | + |
| 35 | +!llvm.dbg.cu = !{!0} |
| 36 | +!llvm.debugify = !{!2, !3} |
| 37 | +!llvm.module.flags = !{!4} |
| 38 | + |
| 39 | +; CHECK: [[DBG9]] = !DILocation(line: 2, |
| 40 | +; CHECK: [[DBG11]] = !DILocation(line: 6, |
| 41 | + |
| 42 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 43 | +!1 = !DIFile(filename: "main.ll", directory: "/") |
| 44 | +!2 = !{i32 10} |
| 45 | +!3 = !{i32 0} |
| 46 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 47 | +!5 = distinct !DISubprogram(name: "foobar6", linkageName: "foobar6", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 48 | +!6 = !DISubroutineType(types: !7) |
| 49 | +!7 = !{} |
| 50 | +!8 = !DILocation(line: 1, column: 1, scope: !5) |
| 51 | +!9 = !DILocation(line: 2, column: 1, scope: !5) |
| 52 | +!10 = !DILocation(line: 3, column: 1, scope: !5) |
| 53 | +!11 = !DILocation(line: 4, column: 1, scope: !5) |
| 54 | +!12 = !DILocation(line: 5, column: 1, scope: !5) |
| 55 | +!13 = !DILocation(line: 6, column: 1, scope: !5) |
| 56 | +!14 = !DILocation(line: 7, column: 1, scope: !5) |
| 57 | +!15 = !DILocation(line: 8, column: 1, scope: !5) |
| 58 | +!16 = !DILocation(line: 9, column: 1, scope: !5) |
| 59 | +!17 = !DILocation(line: 10, column: 1, scope: !5) |
0 commit comments