127 lines · plain
1; RUN: opt %s -S -passes=dse -o - | FileCheck %s --implicit-check-not="#dbg_"2 3;; Observed in the wild, but test is created by running memcpyopt on4;; assignment-tracking/memcpyopt/merge-stores.ll then manually inserting5;; two stores that overwrite each end of the memset.6;;7;; A memory intrinsic (or vector instruction) might have multiple dbg.assigns8;; linked to it if it has been created as a result of merging scalar stores,9;; such as in this example. DSE is going to shorten the memset because there's10;; a later store that overwrites part of it. Unlink the dbg.assigns that11;; describe the overlapping fragments.12 13;; Check that there's an unlinked dbg.assign inserted after each overlapping14;; fragment of the shortened store.15;;16; CHECK: #dbg_assign({{.*}}, ptr %g, !DIExpression(),17; CHECK: #dbg_assign(float 0.000000e+00, ![[#]], !DIExpression(DW_OP_LLVM_fragment, 64, 32), ![[ID:[0-9]+]], ptr %arrayidx.i, !DIExpression(),18; CHECK: #dbg_assign(float 0.000000e+00, ![[#]], !DIExpression(DW_OP_LLVM_fragment, 32, 32), ![[ID]], ptr %arrayidx3.i, !DIExpression(),19; CHECK: #dbg_assign(float 0.000000e+00, ![[#]], !DIExpression(DW_OP_LLVM_fragment, 0, 32), ![[UniqueID1:[0-9]+]], ptr poison, !DIExpression(),20; CHECK: #dbg_assign(float 0.000000e+00, ![[#]], !DIExpression(DW_OP_LLVM_fragment, 96, 32), ![[UniqueID2:[0-9]+]], ptr poison, !DIExpression(),21; CHECK: call void @llvm.memset{{.*}}, !DIAssignID ![[ID]]22 23; CHECK-DAG: ![[ID]] = distinct !DIAssignID()24; CHECK-DAG: ![[UniqueID1]] = distinct !DIAssignID()25; CHECK-DAG: ![[UniqueID2]] = distinct !DIAssignID()26 27%struct.v = type { [4 x float] }28 29$_ZN1vC2Ef = comdat any30 31define dso_local void @_Z1fv() local_unnamed_addr !dbg !7 {32entry:33 %g = alloca %struct.v, align 4, !DIAssignID !2334 call void @llvm.dbg.assign(metadata i1 poison, metadata !11, metadata !DIExpression(), metadata !23, metadata ptr %g, metadata !DIExpression()), !dbg !2435 %arrayidx.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 2, !dbg !3736 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !39, metadata ptr %arrayidx.i, metadata !DIExpression()), !dbg !2437 %arrayidx3.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 1, !dbg !4038 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata !39, metadata ptr %arrayidx3.i, metadata !DIExpression()), !dbg !2439 %arrayidx5.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 0, !dbg !4140 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32), metadata !39, metadata ptr %arrayidx5.i, metadata !DIExpression()), !dbg !2441 %arrayidx7.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 3, !dbg !4242 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 96, 32), metadata !39, metadata ptr %arrayidx7.i, metadata !DIExpression()), !dbg !2443 %0 = bitcast ptr %arrayidx5.i to ptr, !dbg !4344 call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 16, i1 false), !dbg !44, !DIAssignID !3945 ;; -- Start modification46 %arrayidx7 = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 3, !dbg !2447 store float 0.000000e+00, ptr %arrayidx7, align 4, !dbg !24, !DIAssignID !4948 %arrayidx = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 0, !dbg !2449 store float 0.000000e+00, ptr %arrayidx, align 4, !dbg !24, !DIAssignID !5050 ;; -- End modification51 call void @_Z3escP1v(ptr nonnull %g), !dbg !4352 ret void, !dbg !4553}54 55declare !dbg !64 dso_local void @_Z3escP1v(ptr) local_unnamed_addr56declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)57declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)58 59!llvm.dbg.cu = !{!0}60!llvm.module.flags = !{!3, !4, !5, !1000}61!llvm.ident = !{!6}62 63!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)64!1 = !DIFile(filename: "reduce.cpp", directory: "/")65!2 = !{}66!3 = !{i32 7, !"Dwarf Version", i32 4}67!4 = !{i32 2, !"Debug Info Version", i32 3}68!5 = !{i32 1, !"wchar_size", i32 4}69!6 = !{!"clang version 12.0.0"}70!7 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !1, file: !1, line: 12, type: !8, scopeLine: 12, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)71!8 = !DISubroutineType(types: !9)72!9 = !{null}73!10 = !{!11}74!11 = !DILocalVariable(name: "g", scope: !7, file: !1, line: 13, type: !12)75!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v", file: !1, line: 1, size: 128, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !13, identifier: "_ZTS1v")76!13 = !{!14, !19}77!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !12, file: !1, line: 2, baseType: !15, size: 128)78!15 = !DICompositeType(tag: DW_TAG_array_type, baseType: !16, size: 128, elements: !17)79!16 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)80!17 = !{!18}81!18 = !DISubrange(count: 4)82!19 = !DISubprogram(name: "v", scope: !12, file: !1, line: 4, type: !20, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)83!20 = !DISubroutineType(types: !21)84!21 = !{null, !22, !16}85!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)86!23 = distinct !DIAssignID()87!24 = !DILocation(line: 0, scope: !7)88!25 = !DILocation(line: 13, column: 3, scope: !7)89!26 = !DILocalVariable(name: "this", arg: 1, scope: !27, type: !30, flags: DIFlagArtificial | DIFlagObjectPointer)90!27 = distinct !DISubprogram(name: "v", linkageName: "_ZN1vC2Ef", scope: !12, file: !1, line: 4, type: !20, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !19, retainedNodes: !28)91!28 = !{!26, !29}92!29 = !DILocalVariable(name: "d", arg: 2, scope: !27, file: !1, line: 4, type: !16)93!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)94!31 = distinct !DIAssignID()95!32 = !DILocation(line: 0, scope: !27, inlinedAt: !33)96!33 = distinct !DILocation(line: 13, column: 5, scope: !7)97!34 = distinct !DIAssignID()98!35 = distinct !DIAssignID()99!36 = distinct !DIAssignID()100!37 = !DILocation(line: 5, column: 19, scope: !38, inlinedAt: !33)101!38 = distinct !DILexicalBlock(scope: !27, file: !1, line: 4, column: 14)102!39 = distinct !DIAssignID()103!40 = !DILocation(line: 5, column: 12, scope: !38, inlinedAt: !33)104!41 = !DILocation(line: 5, column: 5, scope: !38, inlinedAt: !33)105!42 = !DILocation(line: 6, column: 5, scope: !38, inlinedAt: !33)106!43 = !DILocation(line: 14, column: 3, scope: !7)107!44 = !DILocation(line: 5, column: 17, scope: !38, inlinedAt: !33)108!45 = !DILocation(line: 15, column: 1, scope: !7)109!46 = distinct !DIAssignID()110!47 = !DILocation(line: 0, scope: !27)111!48 = distinct !DIAssignID()112!49 = distinct !DIAssignID()113!50 = distinct !DIAssignID()114!51 = !DILocation(line: 5, column: 19, scope: !38)115!52 = !DILocation(line: 5, column: 24, scope: !38)116!57 = !DILocation(line: 5, column: 12, scope: !38)117!58 = !DILocation(line: 5, column: 17, scope: !38)118!59 = !DILocation(line: 5, column: 5, scope: !38)119!60 = !DILocation(line: 5, column: 10, scope: !38)120!61 = !DILocation(line: 6, column: 5, scope: !38)121!62 = !DILocation(line: 6, column: 10, scope: !38)122!63 = !DILocation(line: 7, column: 3, scope: !27)123!64 = !DISubprogram(name: "esc", linkageName: "_Z3escP1v", scope: !1, file: !1, line: 10, type: !65, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)124!65 = !DISubroutineType(types: !66)125!66 = !{null, !30}126!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}127