xref: /llvm-project/llvm/test/tools/llvm-reduce/remove-dp-values.ll (revision 8128d4b1229203c2ab20d3136410c149ea3652cf)
1; RUN: llvm-reduce --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
2; RUN: FileCheck --check-prefixes=CHECK-FINAL --input-file=%t %s --implicit-check-not=#dbg_value
3
4; RUN: opt < %s -S --write-experimental-debuginfo=false > %t.intrinsics.ll
5; RUN: llvm-reduce --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=INTRINSIC-INTERESTINGNESS --test-arg %s --test-arg --input-file %t.intrinsics.ll -o %t
6; RUN: FileCheck --check-prefixes=INTRINSIC-FINAL --input-file=%t %s --implicit-check-not=#dbg_value
7
8; Test that we can, in RemoveDIs mode / DbgVariableRecords mode (where variable location
9; information isn't an instruction), remove one variable location assignment
10; but not another.
11
12; CHECK-INTERESTINGNESS:     #dbg_value(i32 %added,
13; INTRINSIC-INTERESTINGNESS: llvm.dbg.value(metadata i32 %added,
14
15; CHECK-FINAL:      %added = add
16; CHECK-FINAL-NEXT: #dbg_value(i32 %added,
17; INTRINSIC-FINAL:      %added = add
18; INTRINSIC-FINAL-NEXT: llvm.dbg.value(metadata i32 %added,
19
20define i32 @main() !dbg !7 {
21entry:
22  %uninteresting1 = alloca i32, align 4
23  %interesting = alloca i32, align 4
24  %uninteresting2 = alloca i32, align 4
25  store i32 0, ptr %uninteresting1, align 4
26  store i32 0, ptr %interesting, align 4
27  %0 = load i32, ptr %interesting, align 4
28  %added = add nsw i32 %0, 1
29    #dbg_value(i32 %added, !13, !DIExpression(), !14)
30  store i32 %added, ptr %interesting, align 4
31  %alsoloaded = load i32, ptr %interesting, align 4
32    #dbg_value(i32 %alsoloaded, !13, !DIExpression(), !14)
33  store i32 %alsoloaded, ptr %uninteresting2, align 4
34  ret i32 0
35}
36
37!llvm.dbg.cu = !{!0}
38!llvm.module.flags = !{!2, !3, !4, !5, !6}
39
40!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
41!1 = !DIFile(filename: "/tmp/a.c", directory: "/")
42!2 = !{i32 7, !"Dwarf Version", i32 4}
43!3 = !{i32 2, !"Debug Info Version", i32 3}
44!4 = !{i32 1, !"wchar_size", i32 4}
45!5 = !{i32 7, !"uwtable", i32 1}
46!6 = !{i32 7, !"frame-pointer", i32 2}
47!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 1, type: !9, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
48!8 = !DIFile(filename: "/tmp/a.c", directory: "")
49!9 = !DISubroutineType(types: !10)
50!10 = !{!11}
51!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
52!12 = !{}
53!13 = !DILocalVariable(name: "a", scope: !7, file: !8, line: 2, type: !11)
54!14 = !DILocation(line: 2, column: 7, scope: !7)
55
56