1; RUN: opt -passes=licm %s -S | FileCheck %s 2; RUN: opt -passes=licm %s -S --try-experimental-debuginfo-iterators | FileCheck %s 3 4; CHECK: for.body: 5; CHECK-NEXT: #dbg_value(i8 poison 6 7; The load is loop invariant. Check that we leave an undef dbg.value behind 8; when licm sinks the instruction. 9 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 12; cat reduce.cpp 13; extern char a; 14; extern char b; 15; void use(char); 16; void fun() { 17; char local = 0; 18; for (;b;) 19; local = a; 20; use(local); 21; } 22 23@b = external dso_local global i8, align 1 24@a = external dso_local global i8, align 1 25 26define dso_local void @_Z3funv() !dbg !12 { 27entry: 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 32 33for.body.lr.ph: ; preds = %entry 34 br label %for.body, !dbg !24 35 36for.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 42 43for.cond.for.end_crit_edge: ; preds = %for.body 44 %split = phi i8 [ %1, %for.body ] 45 br label %for.end, !dbg !24 46 47for.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 51 ret void, !dbg !29 52} 53 54declare !dbg !4 dso_local void @_Z3usec(i8 signext) 55declare void @llvm.dbg.value(metadata, metadata, metadata) 56 57!llvm.dbg.cu = !{!0} 58!llvm.module.flags = !{!8, !9, !10} 59!llvm.ident = !{!11} 60 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: "/") 63!2 = !{} 64!3 = !{!4} 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) 67!6 = !{null, !7} 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) 75!14 = !{null} 76!15 = !{!16} 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) 88