• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -S -redundant-dbg-inst-elim | FileCheck %s
3; RUN: opt < %s -S -passes=redundant-dbg-inst-elim | FileCheck %s
4
5; All dbg.value with location "!dbg !19" are redundant in the input.
6; FIXME: We do not handle non-overlapping/overlapping fragments perfectly yet.
7
8define dso_local i16 @main(i16 %a1, i16 %a2) local_unnamed_addr #0 !dbg !7 {
9; CHECK-LABEL: @main(
10; CHECK-NEXT:  entry:
11; CHECK-NEXT:    br label [[BB0:%.*]]
12; CHECK:       bb0:
13; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 13, metadata !13, metadata !DIExpression()), !dbg !16
14; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 14, metadata !14, metadata !DIExpression()), !dbg !18
15; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 13, metadata !13, metadata !DIExpression()), !dbg !18
16; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 12, metadata !12, metadata !DIExpression()), !dbg !18
17; CHECK-NEXT:    br label [[BB1:%.*]]
18; CHECK:       bb1:
19; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A1:%.*]], metadata !14, metadata !DIExpression()), !dbg !18
20; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 888, metadata !13, metadata !DIExpression()), !dbg !18
21; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A2:%.*]], metadata !12, metadata !DIExpression()), !dbg !18
22; CHECK-NEXT:    [[T1:%.*]] = call i16 @bar(i16 0)
23; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[T1]], metadata !13, metadata !DIExpression()), !dbg !18
24; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A2]], metadata !12, metadata !DIExpression(DW_OP_constu, 2, DW_OP_shr, DW_OP_stack_value)), !dbg !18
25; CHECK-NEXT:    br label [[BB2:%.*]]
26; CHECK:       bb2:
27; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A1]], metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !18
28; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A1]], metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 8, 8)), !dbg !18
29; CHECK-NEXT:    [[T2:%.*]] = call i16 @bar(i16 [[T1]])
30; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[T2]], metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !18
31; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A1]], metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 8, 8)), !dbg !19
32; CHECK-NEXT:    br label [[BB3:%.*]]
33; CHECK:       bb3:
34; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A1]], metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !19
35; CHECK-NEXT:    call void @llvm.dbg.value(metadata i16 [[A1]], metadata !13, metadata !DIExpression()), !dbg !18
36; CHECK-NEXT:    br label [[EXIT:%.*]]
37; CHECK:       exit:
38; CHECK-NEXT:    ret i16 [[T2]]
39;
40entry:
41  br label %bb0
42
43bb0:
44  call void @llvm.dbg.value(metadata i16 999, metadata !12, metadata !DIExpression()), !dbg !19
45  call void @llvm.dbg.value(metadata i16 996, metadata !13, metadata !DIExpression()), !dbg !19
46  call void @llvm.dbg.value(metadata i16 13, metadata !13, metadata !DIExpression()), !dbg !17
47  call void @llvm.dbg.value(metadata i16 998, metadata !12, metadata !DIExpression(DW_OP_constu, 2, DW_OP_shr, DW_OP_stack_value)), !dbg !19
48  call void @llvm.dbg.value(metadata i16 14, metadata !14, metadata !DIExpression()), !dbg !16
49  call void @llvm.dbg.value(metadata i16 997, metadata !12, metadata !DIExpression()), !dbg !19
50  call void @llvm.dbg.value(metadata i16 13, metadata !13, metadata !DIExpression()), !dbg !16
51  call void @llvm.dbg.value(metadata i16 12, metadata !12, metadata !DIExpression()), !dbg !16
52  br label %bb1
53
54bb1:
55  call void @llvm.dbg.value(metadata i16 %a1, metadata !14, metadata !DIExpression()), !dbg !16
56  call void @llvm.dbg.value(metadata i16 888, metadata !13, metadata !DIExpression()), !dbg !16
57  call void @llvm.dbg.value(metadata i16 %a2, metadata !12, metadata !DIExpression()), !dbg !16
58  %t1 = call i16 @bar(i16 0)
59  call void @llvm.dbg.value(metadata i16 %a1, metadata !14, metadata !DIExpression()), !dbg !19
60  call void @llvm.dbg.value(metadata i16 %t1, metadata !13, metadata !DIExpression()), !dbg !16
61  call void @llvm.dbg.value(metadata i16 %a2, metadata !12, metadata !DIExpression(DW_OP_constu, 2, DW_OP_shr, DW_OP_stack_value)), !dbg !16
62  br label %bb2
63
64bb2:
65  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !19
66  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 8, 8)), !dbg !19
67  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !16
68  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 8, 8)), !dbg !16
69  %t2 = call i16 @bar(i16 %t1)
70  call void @llvm.dbg.value(metadata i16 %t2, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !16
71  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 8, 8)), !dbg !19
72  br label %bb3
73
74bb3:
75  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)), !dbg !19
76  call void @llvm.dbg.value(metadata i16 %a1, metadata !13, metadata !DIExpression()), !dbg !16
77  br label %exit
78
79exit:
80  ret i16 %t2
81}
82
83declare void @llvm.dbg.value(metadata, metadata, metadata) #1
84declare i16 @bar(i16) #2
85
86attributes #0 = { noinline nounwind }
87attributes #1 = { nounwind readnone speculatable willreturn }
88attributes #2 = { noinline nounwind readnone }
89
90!llvm.dbg.cu = !{!0}
91!llvm.module.flags = !{!3, !4, !5}
92!llvm.ident = !{!6}
93
94!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2, nameTableKind: None)
95!1 = !DIFile(filename: "foo.c", directory: "")
96!2 = !{}
97!3 = !{i32 7, !"Dwarf Version", i32 4}
98!4 = !{i32 2, !"Debug Info Version", i32 3}
99!5 = !{i32 1, !"wchar_size", i32 1}
100!6 = !{!"clang version 10.0.0"}
101!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 8, type: !8, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
102!8 = !DISubroutineType(types: !9)
103!9 = !{!10}
104!10 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
105!11 = !{!12, !13, !14}
106!12 = !DILocalVariable(name: "x", scope: !7, file: !1, line: 9, type: !10)
107!13 = !DILocalVariable(name: "y", scope: !7, file: !1, line: 10, type: !10)
108!14 = !DILocalVariable(name: "u", scope: !15, file: !1, line: 11, type: !10)
109!15 = distinct !DILexicalBlock(scope: !7, file: !1, line: 11, column: 3)
110!16 = !DILocation(line: 0, scope: !7)
111!17 = !DILocation(line: 0, scope: !7, inlinedAt: !18)
112!18 = !DILocation(line: 1, scope: !7)
113!19 = !DILocation(line: 77, scope: !7)
114