125 lines · plain
1; RUN: llc %s -stop-after=finalize-isel -o - \2; RUN: | FileCheck %s3 4;; cat test.cpp5;; void d();6;; void e();7;; void es(int*);8;; int f(int a) {9;; if (a) {10;; e();11;; a = 100;12;; } else {13;; d();14;; a = 500;15;; }16;; es(&a);17;; return a;18;; }19;; $ clang++ test.cpp -S -emit-llvm -Xclang -fexperimental-assignment-tracking20 21;; Check that the memory location is selected after the store in if.end:22;; entry:23;; a = param-value24;; if.then:25;; a = 10026;; if.else:27;; a = 50028;; if.end:29;; store (phi if.then: 100, if.else: 500)30;; a = in memory31 32; CHECK-DAG: ![[VAR:[0-9]+]] = !DILocalVariable(name: "a",33 34; CHECK: bb.0.entry:35; CHECK: DBG_VALUE $edi, $noreg, ![[VAR]], !DIExpression()36 37; CHECK: bb.1.if.then:38; CHECK: DBG_VALUE 100, $noreg, ![[VAR]], !DIExpression()39 40; CHECK: bb.2.if.else:41; CHECK: DBG_VALUE 500, $noreg, ![[VAR]], !DIExpression()42 43; CHECK: bb.3.if.end:44; CHECK-NEXT: %0:gr32 = PHI %2, %bb.1, %3, %bb.245; CHECK-NEXT: MOV32mr %stack.0.a.addr, 1, $noreg, 0, $noreg, %046; CHECK-NEXT: DBG_VALUE %stack.0.a.addr, $noreg, ![[VAR]], !DIExpression(DW_OP_deref)47 48target triple = "x86_64-unknown-linux-gnu"49 50; Function Attrs: mustprogress uwtable51define dso_local noundef i32 @_Z1fi(i32 noundef %a) local_unnamed_addr #0 !dbg !7 {52entry:53 %a.addr = alloca i32, align 4, !DIAssignID !1354 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1455 call void @llvm.dbg.assign(metadata i32 %a, metadata !12, metadata !DIExpression(), metadata !15, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1456 %tobool.not = icmp eq i32 %a, 0, !dbg !1657 br i1 %tobool.not, label %if.else, label %if.then, !dbg !1858 59if.then: ; preds = %entry60 tail call void @_Z1ev(), !dbg !1961 call void @llvm.dbg.assign(metadata i32 100, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1462 br label %if.end, !dbg !2263 64if.else: ; preds = %entry65 tail call void @_Z1dv(), !dbg !2366 call void @llvm.dbg.assign(metadata i32 500, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1467 br label %if.end68 69if.end: ; preds = %if.else, %if.then70 %storemerge = phi i32 [ 500, %if.else ], [ 100, %if.then ], !dbg !2571 store i32 %storemerge, ptr %a.addr, align 4, !dbg !25, !DIAssignID !2172 call void @_Z2esPi(ptr noundef nonnull %a.addr), !dbg !3073 %0 = load i32, ptr %a.addr, align 4, !dbg !3174 ret i32 %0, !dbg !3275}76 77declare !dbg !33 dso_local void @_Z1ev() local_unnamed_addr #178declare !dbg !37 dso_local void @_Z1dv() local_unnamed_addr #179declare !dbg !38 dso_local void @_Z2esPi(ptr noundef) local_unnamed_addr #180declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #281 82!llvm.dbg.cu = !{!0}83!llvm.module.flags = !{!2, !3, !4, !5, !1000}84!llvm.ident = !{!6}85 86!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)87!1 = !DIFile(filename: "test.cpp", directory: "/")88!2 = !{i32 7, !"Dwarf Version", i32 5}89!3 = !{i32 2, !"Debug Info Version", i32 3}90!4 = !{i32 1, !"wchar_size", i32 4}91!5 = !{i32 7, !"uwtable", i32 1}92!6 = !{!"clang version 14.0.0"}93!7 = distinct !DISubprogram(name: "f", linkageName: "_Z1fi", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)94!8 = !DISubroutineType(types: !9)95!9 = !{!10, !10}96!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)97!11 = !{!12}98!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 4, type: !10)99!13 = distinct !DIAssignID()100!14 = !DILocation(line: 0, scope: !7)101!15 = distinct !DIAssignID()102!16 = !DILocation(line: 5, column: 7, scope: !17)103!17 = distinct !DILexicalBlock(scope: !7, file: !1, line: 5, column: 7)104!18 = !DILocation(line: 5, column: 7, scope: !7)105!19 = !DILocation(line: 6, column: 5, scope: !20)106!20 = distinct !DILexicalBlock(scope: !17, file: !1, line: 5, column: 10)107!21 = distinct !DIAssignID()108!22 = !DILocation(line: 8, column: 3, scope: !20)109!23 = !DILocation(line: 9, column: 5, scope: !24)110!24 = distinct !DILexicalBlock(scope: !17, file: !1, line: 8, column: 10)111!25 = !DILocation(line: 0, scope: !17)112!30 = !DILocation(line: 12, column: 3, scope: !7)113!31 = !DILocation(line: 13, column: 10, scope: !7)114!32 = !DILocation(line: 13, column: 3, scope: !7)115!33 = !DISubprogram(name: "e", linkageName: "_Z1ev", scope: !1, file: !1, line: 2, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !36)116!34 = !DISubroutineType(types: !35)117!35 = !{null}118!36 = !{}119!37 = !DISubprogram(name: "d", linkageName: "_Z1dv", scope: !1, file: !1, line: 1, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !36)120!38 = !DISubprogram(name: "es", linkageName: "_Z2esPi", scope: !1, file: !1, line: 3, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !36)121!39 = !DISubroutineType(types: !40)122!40 = !{null, !41}123!41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)124!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}125