109 lines · plain
1; RUN: opt -passes=mldst-motion -S %s -o - \2; RUN: | FileCheck %s3 4;; $ cat test.cpp5;; int cond;6;; void esc(int*);7;; void fun() {8;; int a[4];9;; if (cond)10;; a[1] = 1;11;; else12;; a[1] = 2;13;; esc(a);14;; }15;;16;;17;; mldst-motion will merge and sink the stores in if.then and if.else into18;; if.end. Ensure the merged store has a DIAssignID linking it to the two19;; dbg.assign intrinsics which have been left in their original blocks.20 21; CHECK: if.then:22; CHECK-NEXT: #dbg_assign(i32 1,{{.+}}, !DIExpression(DW_OP_LLVM_fragment, 32, 32), ![[ID:[0-9]+]], ptr %1, !DIExpression(),23 24; CHECK: if.else:25; CHECK-NEXT: #dbg_assign(i32 2,{{.+}}, !DIExpression(DW_OP_LLVM_fragment, 32, 32), ![[ID]], ptr %1, !DIExpression(),26 27; CHECK: if.end:28; CHECK: store i32 %.sink, ptr %1, align 4{{.+}}, !DIAssignID ![[ID]]29 30@cond = dso_local local_unnamed_addr global i32 0, align 4, !dbg !031 32define dso_local void @_Z3funv() !dbg !11 {33entry:34 %a = alloca [4 x i32], align 16, !DIAssignID !1935 call void @llvm.dbg.assign(metadata i1 undef, metadata !15, metadata !DIExpression(), metadata !19, metadata ptr %a, metadata !DIExpression()), !dbg !2036 call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %a) #4, !dbg !2137 %0 = load i32, ptr @cond, align 4, !dbg !2238 %tobool.not = icmp eq i32 %0, 0, !dbg !2239 br i1 %tobool.not, label %if.else, label %if.then, !dbg !2840 41if.then: ; preds = %entry42 %arrayidx = getelementptr inbounds [4 x i32], ptr %a, i64 0, i64 1, !dbg !2943 store i32 1, ptr %arrayidx, align 4, !dbg !30, !DIAssignID !3144 call void @llvm.dbg.assign(metadata i32 1, metadata !15, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata !31, metadata ptr %arrayidx, metadata !DIExpression()), !dbg !2045 br label %if.end, !dbg !2946 47if.else: ; preds = %entry48 %arrayidx1 = getelementptr inbounds [4 x i32], ptr %a, i64 0, i64 1, !dbg !3249 store i32 2, ptr %arrayidx1, align 4, !dbg !33, !DIAssignID !3450 call void @llvm.dbg.assign(metadata i32 2, metadata !15, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata !34, metadata ptr %arrayidx1, metadata !DIExpression()), !dbg !2051 br label %if.end52 53if.end: ; preds = %if.else, %if.then54 %arraydecay = getelementptr inbounds [4 x i32], ptr %a, i64 0, i64 0, !dbg !3555 call void @_Z3escPi(ptr noundef nonnull %arraydecay), !dbg !3656 call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %a) #4, !dbg !3757 ret void, !dbg !3758}59 60declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)61declare !dbg !38 dso_local void @_Z3escPi(ptr noundef)62declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)63declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)64 65!llvm.dbg.cu = !{!2}66!llvm.module.flags = !{!6, !7, !8, !9, !1000}67!llvm.ident = !{!10}68 69!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())70!1 = distinct !DIGlobalVariable(name: "cond", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)71!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)72!3 = !DIFile(filename: "test.cpp", directory: "/")73!4 = !{!0}74!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)75!6 = !{i32 7, !"Dwarf Version", i32 5}76!7 = !{i32 2, !"Debug Info Version", i32 3}77!8 = !{i32 1, !"wchar_size", i32 4}78!9 = !{i32 7, !"uwtable", i32 1}79!10 = !{!"clang version 14.0.0"}80!11 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !3, file: !3, line: 3, type: !12, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)81!12 = !DISubroutineType(types: !13)82!13 = !{null}83!14 = !{!15}84!15 = !DILocalVariable(name: "a", scope: !11, file: !3, line: 4, type: !16)85!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !5, size: 128, elements: !17)86!17 = !{!18}87!18 = !DISubrange(count: 4)88!19 = distinct !DIAssignID()89!20 = !DILocation(line: 0, scope: !11)90!21 = !DILocation(line: 4, column: 3, scope: !11)91!22 = !DILocation(line: 5, column: 7, scope: !23)92!23 = distinct !DILexicalBlock(scope: !11, file: !3, line: 5, column: 7)93!28 = !DILocation(line: 5, column: 7, scope: !11)94!29 = !DILocation(line: 6, column: 5, scope: !23)95!30 = !DILocation(line: 6, column: 10, scope: !23)96!31 = distinct !DIAssignID()97!32 = !DILocation(line: 8, column: 5, scope: !23)98!33 = !DILocation(line: 8, column: 10, scope: !23)99!34 = distinct !DIAssignID()100!35 = !DILocation(line: 9, column: 7, scope: !11)101!36 = !DILocation(line: 9, column: 3, scope: !11)102!37 = !DILocation(line: 10, column: 1, scope: !11)103!38 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !3, file: !3, line: 2, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !42)104!39 = !DISubroutineType(types: !40)105!40 = !{null, !41}106!41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)107!42 = !{}108!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}109