1 ;; Check that adce salvages debug info properly.
2 ; RUN: opt -passes=adce -S < %s | FileCheck %s
5 source_filename = "test.ll"
7 ; Function Attrs: nounwind readnone
8 declare void @may_not_return(i32) #0
10 ; Function Attrs: nounwind readnone willreturn
11 declare void @will_return(i32) #1
13 define void @test(i32 %a) !dbg !6 {
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
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
30 declare void @llvm.dbg.value(metadata, metadata, metadata)
32 attributes #0 = { nounwind readnone }
33 attributes #1 = { nounwind readnone willreturn }
36 !llvm.debugify = !{!3, !4}
37 !llvm.module.flags = !{!5}
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: "/")
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)
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)