|
| 1 | +; RUN: opt -S -passes=licm %s | FileCheck %s |
| 2 | + |
| 3 | +; Check that hoistSub() in LICM salvages the dbg_value for the hoisted sub |
| 4 | +; instruction. |
| 5 | + |
| 6 | +define i32 @hoist_sub(ptr %p, ptr %x_p, ptr %length_p) !dbg !5 { |
| 7 | +; CHECK-LABEL: define i32 @hoist_sub( |
| 8 | +; CHECK-LABEL: loop: |
| 9 | +; CHECK: #dbg_value(!DIArgList(i32 [[X:%.*]], i32 [[IV:%.*]]), [[META9:![0-9]+]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus, DW_OP_stack_value), [[META16:![0-9]+]]) |
| 10 | +; |
| 11 | +entry: |
| 12 | + %x = load i32, ptr %x_p, align 4, !dbg !20, !range !21 |
| 13 | + %length = load i32, ptr %length_p, align 4, !dbg !22, !range !21 |
| 14 | + br label %loop, !dbg !23 |
| 15 | + |
| 16 | +loop: ; preds = %backedge, %entry |
| 17 | + %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ], !dbg !24 |
| 18 | + %arith = sub nsw i32 %x, %iv, !dbg !25 |
| 19 | + #dbg_value(i32 %arith, !13, !DIExpression(), !25) |
| 20 | + %x_check = icmp slt i32 %arith, 4, !dbg !26 |
| 21 | + br i1 %x_check, label %out_of_bounds, label %backedge, !dbg !27 |
| 22 | + |
| 23 | +backedge: ; preds = %loop |
| 24 | + %el.ptr = getelementptr i32, ptr %p, i32 %iv, !dbg !28 |
| 25 | + store i32 1, ptr %el.ptr, align 4, !dbg !29 |
| 26 | + %iv.next = add nuw nsw i32 %iv, 4, !dbg !30 |
| 27 | + %loop_cond = icmp slt i32 %iv.next, %length, !dbg !31 |
| 28 | + br i1 %loop_cond, label %loop, label %exit, !dbg !32 |
| 29 | + |
| 30 | +exit: ; preds = %backedge |
| 31 | + ret i32 %iv.next, !dbg !33 |
| 32 | + |
| 33 | +out_of_bounds: ; preds = %loop |
| 34 | + ret i32 -1, !dbg !34 |
| 35 | +} |
| 36 | + |
| 37 | +!llvm.dbg.cu = !{!0} |
| 38 | +!llvm.debugify = !{!2, !3} |
| 39 | +!llvm.module.flags = !{!4} |
| 40 | + |
| 41 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 42 | +!1 = !DIFile(filename: "salvage-hoisted-sub.ll", directory: "/") |
| 43 | +!2 = !{i32 14} |
| 44 | +!3 = !{i32 8} |
| 45 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 46 | +!5 = distinct !DISubprogram(name: "hoist_sub", linkageName: "hoist_sub", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) |
| 47 | +!6 = !DISubroutineType(types: !7) |
| 48 | +!7 = !{} |
| 49 | +!8 = !{!13} |
| 50 | +!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) |
| 51 | +!13 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 5, type: !10) |
| 52 | +!20 = !DILocation(line: 1, column: 1, scope: !5) |
| 53 | +!21 = !{i32 0, i32 -2147483648} |
| 54 | +!22 = !DILocation(line: 2, column: 1, scope: !5) |
| 55 | +!23 = !DILocation(line: 3, column: 1, scope: !5) |
| 56 | +!24 = !DILocation(line: 4, column: 1, scope: !5) |
| 57 | +!25 = !DILocation(line: 5, column: 1, scope: !5) |
| 58 | +!26 = !DILocation(line: 6, column: 1, scope: !5) |
| 59 | +!27 = !DILocation(line: 7, column: 1, scope: !5) |
| 60 | +!28 = !DILocation(line: 8, column: 1, scope: !5) |
| 61 | +!29 = !DILocation(line: 9, column: 1, scope: !5) |
| 62 | +!30 = !DILocation(line: 10, column: 1, scope: !5) |
| 63 | +!31 = !DILocation(line: 11, column: 1, scope: !5) |
| 64 | +!32 = !DILocation(line: 12, column: 1, scope: !5) |
| 65 | +!33 = !DILocation(line: 13, column: 1, scope: !5) |
| 66 | +!34 = !DILocation(line: 14, column: 1, scope: !5) |
| 67 | +;. |
| 68 | +; CHECK: [[META9]] = !DILocalVariable(name: "4", |
| 69 | +; CHECK: [[META16]] = !DILocation(line: 5, column: 1, |
| 70 | +;. |
0 commit comments