87 lines · plain
1; RUN: opt -passes=licm %s -S | FileCheck %s2 3; CHECK: for.body:4; CHECK-NEXT: #dbg_value(i8 poison5 6; The load is loop invariant. Check that we leave an undef dbg.value behind7; when licm sinks the instruction.8 9; clang reduce.cpp -g -O2 -Xclang -disable-llvm-passes -emit-llvm -o reduce.ll10; opt -passes=simplifycfg -sroa -passes=loop-rotate -o - -S reduce.ll11; cat reduce.cpp12; extern char a;13; extern char b;14; void use(char);15; void fun() {16; char local = 0;17; for (;b;)18; local = a;19; use(local);20; }21 22@b = external dso_local global i8, align 123@a = external dso_local global i8, align 124 25define dso_local void @_Z3funv() !dbg !12 {26entry:27 call void @llvm.dbg.value(metadata i8 0, metadata !16, metadata !DIExpression()), !dbg !1728 %0 = load i8, ptr @b, align 1, !dbg !1829 %tobool1 = icmp ne i8 %0, 0, !dbg !1830 br i1 %tobool1, label %for.body.lr.ph, label %for.end, !dbg !2431 32for.body.lr.ph: ; preds = %entry33 br label %for.body, !dbg !2434 35for.body: ; preds = %for.body.lr.ph, %for.body36 %1 = load i8, ptr @a, align 1, !dbg !2537 call void @llvm.dbg.value(metadata i8 %1, metadata !16, metadata !DIExpression()), !dbg !1738 %2 = load i8, ptr @b, align 1, !dbg !1839 %tobool = icmp ne i8 %2, 0, !dbg !1840 br i1 %tobool, label %for.body, label %for.cond.for.end_crit_edge, !dbg !24, !llvm.loop !2641 42for.cond.for.end_crit_edge: ; preds = %for.body43 %split = phi i8 [ %1, %for.body ]44 br label %for.end, !dbg !2445 46for.end: ; preds = %for.cond.for.end_crit_edge, %entry47 %local.0.lcssa = phi i8 [ %split, %for.cond.for.end_crit_edge ], [ 0, %entry ], !dbg !1748 call void @llvm.dbg.value(metadata i8 %local.0.lcssa, metadata !16, metadata !DIExpression()), !dbg !1749 call void @_Z3usec(i8 signext %local.0.lcssa), !dbg !2850 ret void, !dbg !2951}52 53declare !dbg !4 dso_local void @_Z3usec(i8 signext)54declare void @llvm.dbg.value(metadata, metadata, metadata)55 56!llvm.dbg.cu = !{!0}57!llvm.module.flags = !{!8, !9, !10}58!llvm.ident = !{!11}59 60!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)61!1 = !DIFile(filename: "reduce.cpp", directory: "/")62!2 = !{}63!3 = !{!4}64!4 = !DISubprogram(name: "use", linkageName: "_Z3usec", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)65!5 = !DISubroutineType(types: !6)66!6 = !{null, !7}67!7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)68!8 = !{i32 7, !"Dwarf Version", i32 4}69!9 = !{i32 2, !"Debug Info Version", i32 3}70!10 = !{i32 1, !"wchar_size", i32 4}71!11 = !{!"clang version 11.0.0"}72!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)73!13 = !DISubroutineType(types: !14)74!14 = !{null}75!15 = !{!16}76!16 = !DILocalVariable(name: "local", scope: !12, file: !1, line: 5, type: !7)77!17 = !DILocation(line: 0, scope: !12)78!18 = !DILocation(line: 6, column: 9, scope: !19)79!19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 6, column: 3)80!20 = distinct !DILexicalBlock(scope: !12, file: !1, line: 6, column: 3)81!24 = !DILocation(line: 6, column: 3, scope: !20)82!25 = !DILocation(line: 7, column: 13, scope: !19)83!26 = distinct !{!26, !24, !27}84!27 = !DILocation(line: 7, column: 13, scope: !20)85!28 = !DILocation(line: 8, column: 3, scope: !12)86!29 = !DILocation(line: 9, column: 1, scope: !12)87