57 lines · plain
1; RUN: opt -passes=early-cse -earlycse-debug-hash -S %s -o - | FileCheck %s2 3; PR40628: The first load below is determined to be redundant by EarlyCSE.4; During salvaging, the corresponding dbg.value could have a DW_OP_deref used5; in its DIExpression to represent the redundant operation -- however LLVM6; cannot currently determine that the subsequent store should terminate the7; variables location range. A debugger would display zero for the "redundant"8; variable after stepping onto the return instruction.9 10; Test that the load being removed results in the corresponding dbg.value11; being assigned the 'undef' value.12 13; CHECK: @foo14; CHECK-NEXT: #dbg_value(i32 poison, ![[DEADVAR:[0-9]+]],15; CHECK-NEXT: load16; CHECK-NEXT: #dbg_value(i32 %{{[0-9]+}}, ![[LIVEVAR:[0-9]+]],17; CHECK-NEXT: store18; CHECK-NEXT: ret19 20; CHECK: ![[DEADVAR]] = !DILocalVariable(name: "redundant",21; CHECK: ![[LIVEVAR]] = !DILocalVariable(name: "loaded",22 23target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"24target triple = "x86_64-unknown-linux-gnu"25 26define dso_local i32 @foo(ptr) !dbg !7 {27 %2 = load i32, ptr %0, align 4, !dbg !2328 call void @llvm.dbg.value(metadata i32 %2, metadata !16, metadata !DIExpression()), !dbg !2329 %3 = load i32, ptr %0, align 4, !dbg !2330 call void @llvm.dbg.value(metadata i32 %3, metadata !17, metadata !DIExpression()), !dbg !2331 store i32 0, ptr %0, align 4, !dbg !2332 ret i32 %3, !dbg !2333}34 35declare void @llvm.dbg.value(metadata, metadata, metadata)36 37!llvm.dbg.cu = !{!0}38!llvm.module.flags = !{!3, !4, !5}39!llvm.ident = !{!6}40 41!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)42!1 = !DIFile(filename: "pr40628.c", directory: ".")43!2 = !{}44!3 = !{i32 2, !"Dwarf Version", i32 4}45!4 = !{i32 2, !"Debug Info Version", i32 3}46!5 = !{i32 1, !"wchar_size", i32 4}47!6 = !{!"clang"}48!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)49!8 = !DISubroutineType(types: !9)50!9 = !{!10, !11}51!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)52!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)53!12 = !{!16, !17}54!16 = !DILocalVariable(name: "redundant", scope: !7, file: !1, line: 4, type: !10)55!17 = !DILocalVariable(name: "loaded", scope: !7, file: !1, line: 5, type: !10)56!23 = !DILocation(line: 4, column: 7, scope: !7)57