xref: /llvm-project/llvm/test/Transforms/InstCombine/debuginfo-skip.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -instcombine-lower-dbg-declare=0 < %s -passes=instcombine -S | FileCheck %s
2; RUN: opt -instcombine-lower-dbg-declare=1 < %s -passes=instcombine -S | FileCheck %s
3
4; RUN: opt -instcombine-lower-dbg-declare=0 < %s -passes=instcombine -S --try-experimental-debuginfo-iterators | FileCheck %s
5; RUN: opt -instcombine-lower-dbg-declare=1 < %s -passes=instcombine -S --try-experimental-debuginfo-iterators | FileCheck %s
6
7define i32 @foo(i32 %j) #0 !dbg !7 {
8entry:
9  %j.addr = alloca i32, align 4
10  store i32 %j, ptr %j.addr, align 4
11  call void @llvm.dbg.declare(metadata ptr %j.addr, metadata !11, metadata !12), !dbg !13
12  call void @llvm.dbg.value(metadata i32 10, metadata !16, metadata !12), !dbg !15
13  %0 = load i32, ptr %j.addr, align 4, !dbg !14
14  ret i32 %0, !dbg !15
15}
16
17; Instcombine can remove the alloca and forward the load to store, but it
18; should convert the declare to dbg value.
19; CHECK-LABEL: define i32 @foo(i32 %j)
20; CHECK-NOT: alloca
21; CHECK: #dbg_value(i32 %j, {{.*}})
22; CHECK: #dbg_value(i32 10, {{.*}})
23; CHECK: ret i32 %j
24
25declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
26declare void @llvm.dbg.value(metadata, metadata, metadata) #1
27
28!llvm.dbg.cu = !{!0}
29!llvm.module.flags = !{!3, !4, !5}
30!llvm.ident = !{!6}
31
32!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang 5.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
33!1 = !DIFile(filename: "a.c", directory: "/tmp")
34!2 = !{}
35!3 = !{i32 2, !"Dwarf Version", i32 4}
36!4 = !{i32 2, !"Debug Info Version", i32 3}
37!5 = !{i32 1, !"PIC Level", i32 2}
38!6 = !{!"clang version 5.0.0 (trunk 302918) (llvm/trunk 302925)"}
39!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
40!8 = !DISubroutineType(types: !9)
41!9 = !{!10, !10}
42!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
43!11 = !DILocalVariable(name: "j", arg: 1, scope: !7, file: !1, line: 2, type: !10)
44!12 = !DIExpression()
45!13 = !DILocation(line: 2, column: 13, scope: !7)
46!14 = !DILocation(line: 5, column: 10, scope: !7)
47!15 = !DILocation(line: 5, column: 3, scope: !7)
48!16 = !DILocalVariable(name: "h", scope: !7, file: !1, line: 4, type: !10)
49