|
| 1 | +; RUN: opt -S -passes="loop(loop-flatten)" < %s | FileCheck %s |
| 2 | + |
| 3 | +; Check that LoopFlatten's DoFlattenLoopPair() propagates the debug location of the |
| 4 | +; original terminator to the new branch instruction. |
| 5 | + |
| 6 | +define i32 @test1(i32 %val, ptr nocapture %A) !dbg !5 { |
| 7 | +; CHECK-LABEL: define i32 @test1( |
| 8 | +; CHECK-LABEL: for.body3: |
| 9 | +; CHECK: br label %for.inc6, !dbg [[DBG22:![0-9]+]] |
| 10 | +; CHECK-LABEL: for.inc6: |
| 11 | +; |
| 12 | +entry: |
| 13 | + br label %for.body, !dbg !8 |
| 14 | + |
| 15 | +for.body: ; preds = %for.inc6, %entry |
| 16 | + %i.018 = phi i32 [ 0, %entry ], [ %inc7, %for.inc6 ], !dbg !9 |
| 17 | + %mul = mul nuw nsw i32 %i.018, 20, !dbg !10 |
| 18 | + br label %for.body3, !dbg !11 |
| 19 | + |
| 20 | +for.body3: ; preds = %for.body3, %for.body |
| 21 | + %j.017 = phi i32 [ 0, %for.body ], [ %inc, %for.body3 ], !dbg !12 |
| 22 | + %add = add nuw nsw i32 %j.017, %mul, !dbg !13 |
| 23 | + %arrayidx = getelementptr inbounds i16, ptr %A, i32 %add, !dbg !14 |
| 24 | + %0 = load i16, ptr %arrayidx, align 2, !dbg !15 |
| 25 | + %conv16 = zext i16 %0 to i32, !dbg !16 |
| 26 | + %add4 = add i32 %conv16, %val, !dbg !17 |
| 27 | + %conv5 = trunc i32 %add4 to i16, !dbg !18 |
| 28 | + store i16 %conv5, ptr %arrayidx, align 2, !dbg !19 |
| 29 | + %inc = add nuw nsw i32 %j.017, 1, !dbg !20 |
| 30 | + %exitcond = icmp ne i32 %inc, 20, !dbg !21 |
| 31 | + br i1 %exitcond, label %for.body3, label %for.inc6, !dbg !22 |
| 32 | + |
| 33 | +for.inc6: ; preds = %for.body3 |
| 34 | + %inc7 = add nuw nsw i32 %i.018, 1, !dbg !23 |
| 35 | + %exitcond19 = icmp ne i32 %inc7, 10, !dbg !24 |
| 36 | + br i1 %exitcond19, label %for.body, label %for.end8, !dbg !25 |
| 37 | + |
| 38 | +for.end8: ; preds = %for.inc6 |
| 39 | + ret i32 10, !dbg !26 |
| 40 | +} |
| 41 | + |
| 42 | +!llvm.dbg.cu = !{!0} |
| 43 | +!llvm.debugify = !{!2, !3} |
| 44 | +!llvm.module.flags = !{!4} |
| 45 | + |
| 46 | +; CHECK: [[DBG22]] = !DILocation(line: 15, |
| 47 | + |
| 48 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 49 | +!1 = !DIFile(filename: "temp.ll", directory: "/") |
| 50 | +!2 = !{i32 19} |
| 51 | +!3 = !{i32 0} |
| 52 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 53 | +!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 54 | +!6 = !DISubroutineType(types: !7) |
| 55 | +!7 = !{} |
| 56 | +!8 = !DILocation(line: 1, column: 1, scope: !5) |
| 57 | +!9 = !DILocation(line: 2, column: 1, scope: !5) |
| 58 | +!10 = !DILocation(line: 3, column: 1, scope: !5) |
| 59 | +!11 = !DILocation(line: 4, column: 1, scope: !5) |
| 60 | +!12 = !DILocation(line: 5, column: 1, scope: !5) |
| 61 | +!13 = !DILocation(line: 6, column: 1, scope: !5) |
| 62 | +!14 = !DILocation(line: 7, column: 1, scope: !5) |
| 63 | +!15 = !DILocation(line: 8, column: 1, scope: !5) |
| 64 | +!16 = !DILocation(line: 9, column: 1, scope: !5) |
| 65 | +!17 = !DILocation(line: 10, column: 1, scope: !5) |
| 66 | +!18 = !DILocation(line: 11, column: 1, scope: !5) |
| 67 | +!19 = !DILocation(line: 12, column: 1, scope: !5) |
| 68 | +!20 = !DILocation(line: 13, column: 1, scope: !5) |
| 69 | +!21 = !DILocation(line: 14, column: 1, scope: !5) |
| 70 | +!22 = !DILocation(line: 15, column: 1, scope: !5) |
| 71 | +!23 = !DILocation(line: 16, column: 1, scope: !5) |
| 72 | +!24 = !DILocation(line: 17, column: 1, scope: !5) |
| 73 | +!25 = !DILocation(line: 18, column: 1, scope: !5) |
| 74 | +!26 = !DILocation(line: 19, column: 1, scope: !5) |
0 commit comments