76 lines · plain
1; RUN: opt -S -passes=dse -dse-memoryssa-scanlimit=2 < %s | FileCheck %s2; RUN: opt -S -strip-debug -passes=dse -dse-memoryssa-scanlimit=2 < %s | FileCheck %s3 4; Test case to check that DSE gets the same result even if we have a dbg value5; between the memcpy.6 7; This test case is less relevant for the MemorySSA backed version of DSE, as8; debug values are not modeled in MemorySSA and are skipped regardless of the9; exploration limit.10 11target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"12target triple = "x86_64-unknown-linux-gnu"13 14@g = common global [1 x i8] zeroinitializer, align 1, !dbg !015 16; Function Attrs: noinline nounwind uwtable17define void @foo() !dbg !14 {18entry:19 %i = alloca i8, align 120 store i8 1, ptr %i, align 1, !dbg !1921 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !1822 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !1823 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !1824 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !1825 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !1826 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !1827 call void @llvm.memcpy.p0.p0.i64(ptr %i, ptr @g, i64 1, i1 false), !dbg !2028 br label %bb229 30bb2: ; preds = @g31 ret void, !dbg !2132}33 34; Function Attrs: nounwind readnone speculatable35declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #136 37; Function Attrs: argmemonly nounwind38declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #239 40attributes #1 = { nounwind readnone speculatable }41attributes #2 = { argmemonly nounwind }42 43!llvm.dbg.cu = !{!2}44!llvm.module.flags = !{!10, !11, !12}45!llvm.ident = !{!13}46 47!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())48!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 3, type: !6, isLocal: false, isDefinition: true)49!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 6.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)50!3 = !DIFile(filename: "foo.c", directory: "/bar")51!4 = !{}52!5 = !{!0}53!6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 8, elements: !8)54!7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)55!8 = !{!9}56!9 = !DISubrange(count: 1)57!10 = !{i32 2, !"Dwarf Version", i32 4}58!11 = !{i32 2, !"Debug Info Version", i32 3}59!12 = !{i32 1, !"wchar_size", i32 4}60!13 = !{!"clang version 6.0.0"}61!14 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 5, type: !15, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: false, unit: !2, retainedNodes: !4)62!15 = !DISubroutineType(types: !16)63!16 = !{null}64!17 = !DILocalVariable(name: "i", scope: !14, file: !3, line: 7, type: !7)65!18 = !DILocation(line: 7, column: 10, scope: !14)66!19 = !DILocation(line: 8, column: 7, scope: !14)67!20 = !DILocation(line: 9, column: 5, scope: !14)68!21 = !DILocation(line: 10, column: 1, scope: !14)69 70; Check that the both the store and memcpy are removed because they both access71; an alloca that is not read.72; CHECK-LABEL: foo73; CHECK-NOT: store i874; CHECK-NOT: call void @llvm.memcpy75; CHECK: ret void76