1; RUN: llc %s -stop-after=finalize-isel -o - \ 2; RUN: | FileCheck %s 3 4 5; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - \ 6; RUN: | FileCheck %s 7 8;; cat test.cpp 9;; void d(); 10;; void e(); 11;; void es(int*); 12;; int f(int a) { 13;; if (a) { 14;; e(); 15;; a = 100; 16;; } else { 17;; d(); 18;; a = 500; 19;; } 20;; es(&a); 21;; return a; 22;; } 23;; $ clang++ test.cpp -S -emit-llvm -Xclang -fexperimental-assignment-tracking 24 25;; Check that the memory location is selected after the store in if.end: 26;; entry: 27;; a = param-value 28;; if.then: 29;; a = 100 30;; if.else: 31;; a = 500 32;; if.end: 33;; store (phi if.then: 100, if.else: 500) 34;; a = in memory 35 36; CHECK-DAG: ![[VAR:[0-9]+]] = !DILocalVariable(name: "a", 37 38; CHECK: bb.0.entry: 39; CHECK: DBG_VALUE $edi, $noreg, ![[VAR]], !DIExpression() 40 41; CHECK: bb.1.if.then: 42; CHECK: DBG_VALUE 100, $noreg, ![[VAR]], !DIExpression() 43 44; CHECK: bb.2.if.else: 45; CHECK: DBG_VALUE 500, $noreg, ![[VAR]], !DIExpression() 46 47; CHECK: bb.3.if.end: 48; CHECK-NEXT: %0:gr32 = PHI %2, %bb.1, %3, %bb.2 49; CHECK-NEXT: MOV32mr %stack.0.a.addr, 1, $noreg, 0, $noreg, %0 50; CHECK-NEXT: DBG_VALUE %stack.0.a.addr, $noreg, ![[VAR]], !DIExpression(DW_OP_deref) 51 52target triple = "x86_64-unknown-linux-gnu" 53 54; Function Attrs: mustprogress uwtable 55define dso_local noundef i32 @_Z1fi(i32 noundef %a) local_unnamed_addr #0 !dbg !7 { 56entry: 57 %a.addr = alloca i32, align 4, !DIAssignID !13 58 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %a.addr, metadata !DIExpression()), !dbg !14 59 call void @llvm.dbg.assign(metadata i32 %a, metadata !12, metadata !DIExpression(), metadata !15, metadata ptr %a.addr, metadata !DIExpression()), !dbg !14 60 %tobool.not = icmp eq i32 %a, 0, !dbg !16 61 br i1 %tobool.not, label %if.else, label %if.then, !dbg !18 62 63if.then: ; preds = %entry 64 tail call void @_Z1ev(), !dbg !19 65 call void @llvm.dbg.assign(metadata i32 100, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr %a.addr, metadata !DIExpression()), !dbg !14 66 br label %if.end, !dbg !22 67 68if.else: ; preds = %entry 69 tail call void @_Z1dv(), !dbg !23 70 call void @llvm.dbg.assign(metadata i32 500, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr %a.addr, metadata !DIExpression()), !dbg !14 71 br label %if.end 72 73if.end: ; preds = %if.else, %if.then 74 %storemerge = phi i32 [ 500, %if.else ], [ 100, %if.then ], !dbg !25 75 store i32 %storemerge, ptr %a.addr, align 4, !dbg !25, !DIAssignID !21 76 call void @_Z2esPi(ptr noundef nonnull %a.addr), !dbg !30 77 %0 = load i32, ptr %a.addr, align 4, !dbg !31 78 ret i32 %0, !dbg !32 79} 80 81declare !dbg !33 dso_local void @_Z1ev() local_unnamed_addr #1 82declare !dbg !37 dso_local void @_Z1dv() local_unnamed_addr #1 83declare !dbg !38 dso_local void @_Z2esPi(ptr noundef) local_unnamed_addr #1 84declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #2 85 86!llvm.dbg.cu = !{!0} 87!llvm.module.flags = !{!2, !3, !4, !5, !1000} 88!llvm.ident = !{!6} 89 90!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) 91!1 = !DIFile(filename: "test.cpp", directory: "/") 92!2 = !{i32 7, !"Dwarf Version", i32 5} 93!3 = !{i32 2, !"Debug Info Version", i32 3} 94!4 = !{i32 1, !"wchar_size", i32 4} 95!5 = !{i32 7, !"uwtable", i32 1} 96!6 = !{!"clang version 14.0.0"} 97!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) 98!8 = !DISubroutineType(types: !9) 99!9 = !{!10, !10} 100!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 101!11 = !{!12} 102!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 4, type: !10) 103!13 = distinct !DIAssignID() 104!14 = !DILocation(line: 0, scope: !7) 105!15 = distinct !DIAssignID() 106!16 = !DILocation(line: 5, column: 7, scope: !17) 107!17 = distinct !DILexicalBlock(scope: !7, file: !1, line: 5, column: 7) 108!18 = !DILocation(line: 5, column: 7, scope: !7) 109!19 = !DILocation(line: 6, column: 5, scope: !20) 110!20 = distinct !DILexicalBlock(scope: !17, file: !1, line: 5, column: 10) 111!21 = distinct !DIAssignID() 112!22 = !DILocation(line: 8, column: 3, scope: !20) 113!23 = !DILocation(line: 9, column: 5, scope: !24) 114!24 = distinct !DILexicalBlock(scope: !17, file: !1, line: 8, column: 10) 115!25 = !DILocation(line: 0, scope: !17) 116!30 = !DILocation(line: 12, column: 3, scope: !7) 117!31 = !DILocation(line: 13, column: 10, scope: !7) 118!32 = !DILocation(line: 13, column: 3, scope: !7) 119!33 = !DISubprogram(name: "e", linkageName: "_Z1ev", scope: !1, file: !1, line: 2, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !36) 120!34 = !DISubroutineType(types: !35) 121!35 = !{null} 122!36 = !{} 123!37 = !DISubprogram(name: "d", linkageName: "_Z1dv", scope: !1, file: !1, line: 1, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !36) 124!38 = !DISubprogram(name: "es", linkageName: "_Z2esPi", scope: !1, file: !1, line: 3, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !36) 125!39 = !DISubroutineType(types: !40) 126!40 = !{null, !41} 127!41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64) 128!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 129