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