Djordje Todorovic | cd49b3a | 2021-05-21 05:02:09 -0700 | [diff] [blame] | 1 | ;; Check that adce salvages debug info properly. |
Bjorn Pettersson | 3f8027f | 2021-09-13 10:43:38 +0200 | [diff] [blame] | 2 | ; RUN: opt -passes=adce -S < %s | FileCheck %s |
Djordje Todorovic | cd49b3a | 2021-05-21 05:02:09 -0700 | [diff] [blame] | 3 | |
| 4 | ; ModuleID = 'test.ll' |
| 5 | source_filename = "test.ll" |
| 6 | |
| 7 | ; Function Attrs: nounwind readnone |
| 8 | declare void @may_not_return(i32) #0 |
| 9 | |
| 10 | ; Function Attrs: nounwind readnone willreturn |
| 11 | declare void @will_return(i32) #1 |
| 12 | |
| 13 | define void @test(i32 %a) !dbg !6 { |
| 14 | ; CHECK-LABEL: @test( |
| 15 | ; CHECK-NEXT: [[B:%.*]] = add i32 [[A:%.*]], 1 |
| 16 | ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[B]] |
| 17 | ; CHECK-NEXT: call void @may_not_return(i32 [[B]]) |
| 18 | ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[B]], {{.*}}DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value) |
| 19 | ; CHECK-NEXT: ret void |
| 20 | ; |
| 21 | %b = add i32 %a, 1, !dbg !12 |
| 22 | call void @llvm.dbg.value(metadata i32 %b, metadata !9, metadata !DIExpression()), !dbg !12 |
| 23 | call void @may_not_return(i32 %b), !dbg !13 |
| 24 | %c = add i32 %b, 1, !dbg !14 |
| 25 | call void @llvm.dbg.value(metadata i32 %c, metadata !11, metadata !DIExpression()), !dbg !14 |
| 26 | call void @will_return(i32 %c), !dbg !15 |
| 27 | ret void, !dbg !16 |
| 28 | } |
| 29 | |
| 30 | declare void @llvm.dbg.value(metadata, metadata, metadata) |
| 31 | |
| 32 | attributes #0 = { nounwind readnone } |
| 33 | attributes #1 = { nounwind readnone willreturn } |
| 34 | |
| 35 | !llvm.dbg.cu = !{!0} |
| 36 | !llvm.debugify = !{!3, !4} |
| 37 | !llvm.module.flags = !{!5} |
| 38 | |
| 39 | !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) |
| 40 | !1 = !DIFile(filename: "test.ll", directory: "/") |
| 41 | !2 = !{} |
| 42 | !3 = !{i32 5} |
| 43 | !4 = !{i32 2} |
| 44 | !5 = !{i32 2, !"Debug Info Version", i32 3} |
| 45 | !6 = distinct !DISubprogram(name: "test", linkageName: "test", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) |
| 46 | !7 = !DISubroutineType(types: !2) |
| 47 | !8 = !{!9, !11} |
| 48 | !9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10) |
| 49 | !10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) |
| 50 | !11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 3, type: !10) |
| 51 | !12 = !DILocation(line: 1, column: 1, scope: !6) |
| 52 | !13 = !DILocation(line: 2, column: 1, scope: !6) |
| 53 | !14 = !DILocation(line: 3, column: 1, scope: !6) |
| 54 | !15 = !DILocation(line: 4, column: 1, scope: !6) |
| 55 | !16 = !DILocation(line: 5, column: 1, scope: !6) |