161 lines · plain
1; RUN: opt %s -S -passes=memcpyopt -o - | FileCheck %s2 3;; $ cat test.cpp4;; struct v {5;; float c[4];6;;7;; v(float d) {8;; c[0] = c[1] = c[2] = d;9;; c[3] = 0.f;10;; }11;; };12;;13;; void esc(v*);14;;15;; v f() {16;; v g(0);17;; esc(&g);18;; }19;; IR grabbed before memcpyopt in:20;; clang++ -Xclang -fexperimental-assignment-tracking -g -c -O2 test.cpp21 22;; Check that the memset that memcpyopt creates to merge 4 stores merges the23;; DIASsignIDs from the stores.24 25; CHECK: #dbg_assign(float 0.000000e+00, ![[VAR:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 64, 32), ![[ID:[0-9]+]], ptr %arrayidx.i, !DIExpression(),26; CHECK: #dbg_assign(float 0.000000e+00, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 32, 32), ![[ID]], ptr %arrayidx3.i, !DIExpression(),27; CHECK: #dbg_assign(float 0.000000e+00, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 32), ![[ID]], ptr %arrayidx5.i, !DIExpression(),28; CHECK: #dbg_assign(float 0.000000e+00, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 96, 32), ![[ID]], ptr %arrayidx7.i, !DIExpression(),29; CHECK: call void @llvm.memset{{.*}}, !DIAssignID ![[ID]]30 31%struct.v = type { [4 x float] }32 33$_ZN1vC2Ef = comdat any34 35; Function Attrs: uwtable36define dso_local void @_Z1fv() local_unnamed_addr #0 !dbg !7 {37entry:38 %g = alloca %struct.v, align 4, !DIAssignID !2339 call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !23, metadata ptr %g, metadata !DIExpression()), !dbg !2440 call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %g) #5, !dbg !2541 call void @llvm.dbg.assign(metadata i1 undef, metadata !26, metadata !DIExpression(), metadata !31, metadata ptr undef, metadata !DIExpression()), !dbg !3242 call void @llvm.dbg.assign(metadata i1 undef, metadata !29, metadata !DIExpression(), metadata !34, metadata ptr undef, metadata !DIExpression()), !dbg !3243 call void @llvm.dbg.assign(metadata ptr %g, metadata !26, metadata !DIExpression(), metadata !35, metadata ptr undef, metadata !DIExpression()), !dbg !3244 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !29, metadata !DIExpression(), metadata !36, metadata ptr undef, metadata !DIExpression()), !dbg !3245 %arrayidx.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 2, !dbg !3746 store float 0.000000e+00, ptr %arrayidx.i, align 4, !dbg !39, !DIAssignID !4447 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !44, metadata ptr %arrayidx.i, metadata !DIExpression()), !dbg !2448 %arrayidx3.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 1, !dbg !4549 store float 0.000000e+00, ptr %arrayidx3.i, align 4, !dbg !46, !DIAssignID !4750 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata !47, metadata ptr %arrayidx3.i, metadata !DIExpression()), !dbg !2451 %arrayidx5.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 0, !dbg !4852 store float 0.000000e+00, ptr %arrayidx5.i, align 4, !dbg !49, !DIAssignID !5053 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32), metadata !50, metadata ptr %arrayidx5.i, metadata !DIExpression()), !dbg !2454 %arrayidx7.i = getelementptr inbounds %struct.v, ptr %g, i64 0, i32 0, i64 3, !dbg !5155 store float 0.000000e+00, ptr %arrayidx7.i, align 4, !dbg !52, !DIAssignID !5356 call void @llvm.dbg.assign(metadata float 0.000000e+00, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 96, 32), metadata !53, metadata ptr %arrayidx7.i, metadata !DIExpression()), !dbg !2457 call void @_Z3escP1v(ptr nonnull %g), !dbg !5458 call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %g) #5, !dbg !5559 ret void, !dbg !5560}61 62; Function Attrs: argmemonly nofree nosync nounwind willreturn63declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #164 65; Function Attrs: nounwind uwtable66define linkonce_odr dso_local void @_ZN1vC2Ef(ptr %this, float %d) unnamed_addr #2 comdat align 2 !dbg !27 {67entry:68 call void @llvm.dbg.assign(metadata i1 undef, metadata !26, metadata !DIExpression(), metadata !56, metadata ptr undef, metadata !DIExpression()), !dbg !5769 call void @llvm.dbg.assign(metadata i1 undef, metadata !29, metadata !DIExpression(), metadata !58, metadata ptr undef, metadata !DIExpression()), !dbg !5770 call void @llvm.dbg.assign(metadata ptr %this, metadata !26, metadata !DIExpression(), metadata !59, metadata ptr undef, metadata !DIExpression()), !dbg !5771 call void @llvm.dbg.assign(metadata float %d, metadata !29, metadata !DIExpression(), metadata !60, metadata ptr undef, metadata !DIExpression()), !dbg !5772 %arrayidx = getelementptr inbounds %struct.v, ptr %this, i64 0, i32 0, i64 2, !dbg !6173 store float %d, ptr %arrayidx, align 4, !dbg !6274 %arrayidx3 = getelementptr inbounds %struct.v, ptr %this, i64 0, i32 0, i64 1, !dbg !6375 store float %d, ptr %arrayidx3, align 4, !dbg !6476 %arrayidx5 = getelementptr inbounds %struct.v, ptr %this, i64 0, i32 0, i64 0, !dbg !6577 store float %d, ptr %arrayidx5, align 4, !dbg !6678 %arrayidx7 = getelementptr inbounds %struct.v, ptr %this, i64 0, i32 0, i64 3, !dbg !6779 store float 0.000000e+00, ptr %arrayidx7, align 4, !dbg !6880 ret void, !dbg !6981}82 83declare !dbg !70 dso_local void @_Z3escP1v(ptr) local_unnamed_addr84declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)85declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)86 87!llvm.dbg.cu = !{!0}88!llvm.module.flags = !{!3, !4, !5, !1000}89!llvm.ident = !{!6}90 91!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)92!1 = !DIFile(filename: "reduce.cpp", directory: "/")93!2 = !{}94!3 = !{i32 7, !"Dwarf Version", i32 4}95!4 = !{i32 2, !"Debug Info Version", i32 3}96!5 = !{i32 1, !"wchar_size", i32 4}97!6 = !{!"clang version 12.0.0"}98!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)99!8 = !DISubroutineType(types: !9)100!9 = !{null}101!10 = !{!11}102!11 = !DILocalVariable(name: "g", scope: !7, file: !1, line: 13, type: !12)103!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v", file: !1, line: 1, size: 128, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !13, identifier: "_ZTS1v")104!13 = !{!14, !19}105!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !12, file: !1, line: 2, baseType: !15, size: 128)106!15 = !DICompositeType(tag: DW_TAG_array_type, baseType: !16, size: 128, elements: !17)107!16 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)108!17 = !{!18}109!18 = !DISubrange(count: 4)110!19 = !DISubprogram(name: "v", scope: !12, file: !1, line: 4, type: !20, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)111!20 = !DISubroutineType(types: !21)112!21 = !{null, !22, !16}113!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)114!23 = distinct !DIAssignID()115!24 = !DILocation(line: 0, scope: !7)116!25 = !DILocation(line: 13, column: 3, scope: !7)117!26 = !DILocalVariable(name: "this", arg: 1, scope: !27, type: !30, flags: DIFlagArtificial | DIFlagObjectPointer)118!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)119!28 = !{!26, !29}120!29 = !DILocalVariable(name: "d", arg: 2, scope: !27, file: !1, line: 4, type: !16)121!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)122!31 = distinct !DIAssignID()123!32 = !DILocation(line: 0, scope: !27, inlinedAt: !33)124!33 = distinct !DILocation(line: 13, column: 5, scope: !7)125!34 = distinct !DIAssignID()126!35 = distinct !DIAssignID()127!36 = distinct !DIAssignID()128!37 = !DILocation(line: 5, column: 19, scope: !38, inlinedAt: !33)129!38 = distinct !DILexicalBlock(scope: !27, file: !1, line: 4, column: 14)130!39 = !DILocation(line: 5, column: 24, scope: !38, inlinedAt: !33)131!44 = distinct !DIAssignID()132!45 = !DILocation(line: 5, column: 12, scope: !38, inlinedAt: !33)133!46 = !DILocation(line: 5, column: 17, scope: !38, inlinedAt: !33)134!47 = distinct !DIAssignID()135!48 = !DILocation(line: 5, column: 5, scope: !38, inlinedAt: !33)136!49 = !DILocation(line: 5, column: 10, scope: !38, inlinedAt: !33)137!50 = distinct !DIAssignID()138!51 = !DILocation(line: 6, column: 5, scope: !38, inlinedAt: !33)139!52 = !DILocation(line: 6, column: 10, scope: !38, inlinedAt: !33)140!53 = distinct !DIAssignID()141!54 = !DILocation(line: 14, column: 3, scope: !7)142!55 = !DILocation(line: 15, column: 1, scope: !7)143!56 = distinct !DIAssignID()144!57 = !DILocation(line: 0, scope: !27)145!58 = distinct !DIAssignID()146!59 = distinct !DIAssignID()147!60 = distinct !DIAssignID()148!61 = !DILocation(line: 5, column: 19, scope: !38)149!62 = !DILocation(line: 5, column: 24, scope: !38)150!63 = !DILocation(line: 5, column: 12, scope: !38)151!64 = !DILocation(line: 5, column: 17, scope: !38)152!65 = !DILocation(line: 5, column: 5, scope: !38)153!66 = !DILocation(line: 5, column: 10, scope: !38)154!67 = !DILocation(line: 6, column: 5, scope: !38)155!68 = !DILocation(line: 6, column: 10, scope: !38)156!69 = !DILocation(line: 7, column: 3, scope: !27)157!70 = !DISubprogram(name: "esc", linkageName: "_Z3escP1v", scope: !1, file: !1, line: 10, type: !71, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)158!71 = !DISubroutineType(types: !72)159!72 = !{null, !30}160!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}161