1 ; RUN: opt -passes=licm %s -S | FileCheck %s
2 ; RUN: opt -passes=licm %s -S --try-experimental-debuginfo-iterators | FileCheck %s
5 ; CHECK-NEXT: #dbg_value(i8 poison
7 ; The load is loop invariant. Check that we leave an undef dbg.value behind
8 ; when licm sinks the instruction.
10 ; clang reduce.cpp -g -O2 -Xclang -disable-llvm-passes -emit-llvm -o reduce.ll
11 ; opt -passes=simplifycfg -sroa -passes=loop-rotate -o - -S reduce.ll
23 @b = external dso_local global i8, align 1
24 @a = external dso_local global i8, align 1
26 define dso_local void @_Z3funv() !dbg !12 {
28 call void @llvm.dbg.value(metadata i8 0, metadata !16, metadata !DIExpression()), !dbg !17
29 %0 = load i8, ptr @b, align 1, !dbg !18
30 %tobool1 = icmp ne i8 %0, 0, !dbg !18
31 br i1 %tobool1, label %for.body.lr.ph, label %for.end, !dbg !24
33 for.body.lr.ph: ; preds = %entry
34 br label %for.body, !dbg !24
36 for.body: ; preds = %for.body.lr.ph, %for.body
37 %1 = load i8, ptr @a, align 1, !dbg !25
38 call void @llvm.dbg.value(metadata i8 %1, metadata !16, metadata !DIExpression()), !dbg !17
39 %2 = load i8, ptr @b, align 1, !dbg !18
40 %tobool = icmp ne i8 %2, 0, !dbg !18
41 br i1 %tobool, label %for.body, label %for.cond.for.end_crit_edge, !dbg !24, !llvm.loop !26
43 for.cond.for.end_crit_edge: ; preds = %for.body
44 %split = phi i8 [ %1, %for.body ]
45 br label %for.end, !dbg !24
47 for.end: ; preds = %for.cond.for.end_crit_edge, %entry
48 %local.0.lcssa = phi i8 [ %split, %for.cond.for.end_crit_edge ], [ 0, %entry ], !dbg !17
49 call void @llvm.dbg.value(metadata i8 %local.0.lcssa, metadata !16, metadata !DIExpression()), !dbg !17
50 call void @_Z3usec(i8 signext %local.0.lcssa), !dbg !28
54 declare !dbg !4 dso_local void @_Z3usec(i8 signext)
55 declare void @llvm.dbg.value(metadata, metadata, metadata)
58 !llvm.module.flags = !{!8, !9, !10}
61 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
62 !1 = !DIFile(filename: "reduce.cpp", directory: "/")
65 !4 = !DISubprogram(name: "use", linkageName: "_Z3usec", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
66 !5 = !DISubroutineType(types: !6)
68 !7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
69 !8 = !{i32 7, !"Dwarf Version", i32 4}
70 !9 = !{i32 2, !"Debug Info Version", i32 3}
71 !10 = !{i32 1, !"wchar_size", i32 4}
72 !11 = !{!"clang version 11.0.0"}
73 !12 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 4, type: !13, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
74 !13 = !DISubroutineType(types: !14)
77 !16 = !DILocalVariable(name: "local", scope: !12, file: !1, line: 5, type: !7)
78 !17 = !DILocation(line: 0, scope: !12)
79 !18 = !DILocation(line: 6, column: 9, scope: !19)
80 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 6, column: 3)
81 !20 = distinct !DILexicalBlock(scope: !12, file: !1, line: 6, column: 3)
82 !24 = !DILocation(line: 6, column: 3, scope: !20)
83 !25 = !DILocation(line: 7, column: 13, scope: !19)
84 !26 = distinct !{!26, !24, !27}
85 !27 = !DILocation(line: 7, column: 13, scope: !20)
86 !28 = !DILocation(line: 8, column: 3, scope: !12)
87 !29 = !DILocation(line: 9, column: 1, scope: !12)