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