1; RUN: llc %s -stop-before finalize-isel -o - \ 2; RUN: -experimental-debug-variable-locations=false \ 3; RUN: -debug-ata-coalesce-frags=true \ 4; RUN: | FileCheck %s --implicit-check-not=DBG_ 5 6; RUN: llc --try-experimental-debuginfo-iterators %s -stop-before finalize-isel -o - \ 7; RUN: -experimental-debug-variable-locations=false \ 8; RUN: -debug-ata-coalesce-frags=true \ 9; RUN: | FileCheck %s --implicit-check-not=DBG_ 10; RUN: llc %s -stop-before finalize-isel -o - \ 11; RUN: -experimental-debug-variable-locations=true \ 12; RUN: | FileCheck %s --implicit-check-not=DBG_ 13 14 15; RUN: llc --try-experimental-debuginfo-iterators %s -stop-before finalize-isel -o - \ 16; RUN: -experimental-debug-variable-locations=true \ 17; RUN: | FileCheck %s --implicit-check-not=DBG_ 18 19;; Check that the mem-loc-frag-fill analysis works on a simple case; ensure 20;; that location definitions are added to preserve memory locations of 21;; fragments of variables at subsequent location definitions for other 22;; fragments of the variable are not currently in memory. 23 24;; Test generated from: 25;; $ cat test.cpp 26;; struct Nums { int a, b, c; }; 27;; void esc(struct Nums*); 28;; void step(); 29;; int main() { 30;; struct Nums nums = { 1, 2, 1 }; //< Store to .c is elided. 31;; step(); 32;; nums.c = 2; //< Killing store. 33;; step(); 34;; esc(&nums); 35;; return 0; 36;; } 37;; $ clang++ test.cpp -O2 -g -Xclang -fexperimental-assignmment-tracking -emit-llvm -S -o - 38 39;; Most check lines are inline in main. 40; CHECK: ![[nums:[0-9]+]] = !DILocalVariable(name: "nums", 41 42target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 43target triple = "x86_64-unknown-linux-gnu" 44 45%struct.Nums = type { i32, i32, i32 } 46 47; Function Attrs: mustprogress norecurse uwtable 48define dso_local noundef i32 @main() local_unnamed_addr #0 !dbg !7 { 49entry: 50 %nums = alloca %struct.Nums, align 8, !DIAssignID !18 51; CHECK: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref) 52 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !18, metadata ptr %nums, metadata !DIExpression()), !dbg !19 53 store i64 8589934593, ptr %nums, align 8, !dbg !21, !DIAssignID !22 54; CHECK: MOV64mr %stack.0.nums, 1, $noreg, 0, $noreg, killed %0 55 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !22, metadata ptr %nums, metadata !DIExpression()), !dbg !19 56 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !22, metadata ptr undef, metadata !DIExpression()), !dbg !19 57; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[nums]], !DIExpression(DW_OP_LLVM_fragment, 64, 32) 58; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 64) 59 tail call void @_Z4stepv(), !dbg !23 60 %c = getelementptr inbounds %struct.Nums, ptr %nums, i64 0, i32 2, !dbg !24 61 store i32 2, ptr %c, align 8, !dbg !25, !DIAssignID !31 62; CHECK: MOV32mi %stack.0.nums, 1, $noreg, 8, $noreg, 2 63 call void @llvm.dbg.assign(metadata i32 2, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !31, metadata ptr %c, metadata !DIExpression()), !dbg !19 64; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref) 65 tail call void @_Z4stepv(), !dbg !32 66;; Next dbg.assign added by hand to test that the bits [64, 32) have been 67;; correctly tracked as in memory - we know this has worked if 68;; mem-loc-frag-fill reinstates the memory location after this kill-location 69;; for bits [80, 96). 70 call void @llvm.dbg.assign(metadata i32 poison, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 80, 16), metadata !44, metadata ptr poison, metadata !DIExpression()), !dbg !19 71; CHECK: CALL64pcrel32 @_Z4stepv 72; CHECK-NEXT: ADJCALLSTACKUP64 73; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[nums]], !DIExpression(DW_OP_LLVM_fragment, 80, 16) 74; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 80) 75 tail call void @_Z4stepv(), !dbg !32 76 call void @_Z3escP4Nums(ptr noundef nonnull %nums), !dbg !33 77 ret i32 0, !dbg !35 78} 79 80declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1 81declare !dbg !36 dso_local void @_Z4stepv() local_unnamed_addr #2 82declare !dbg !40 dso_local void @_Z3escP4Nums(ptr noundef) local_unnamed_addr #2 83declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1 84declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #3 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: "main", 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} 100!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 101!11 = !{!12} 102!12 = !DILocalVariable(name: "nums", scope: !7, file: !1, line: 5, type: !13) 103!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nums", file: !1, line: 1, size: 96, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS4Nums") 104!14 = !{!15, !16, !17} 105!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !1, line: 1, baseType: !10, size: 32) 106!16 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !1, line: 1, baseType: !10, size: 32, offset: 32) 107!17 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !13, file: !1, line: 1, baseType: !10, size: 32, offset: 64) 108!18 = distinct !DIAssignID() 109!19 = !DILocation(line: 0, scope: !7) 110!20 = !DILocation(line: 5, column: 3, scope: !7) 111!21 = !DILocation(line: 5, column: 15, scope: !7) 112!22 = distinct !DIAssignID() 113!23 = !DILocation(line: 6, column: 3, scope: !7) 114!24 = !DILocation(line: 7, column: 8, scope: !7) 115!25 = !DILocation(line: 7, column: 10, scope: !7) 116!31 = distinct !DIAssignID() 117!32 = !DILocation(line: 8, column: 3, scope: !7) 118!33 = !DILocation(line: 9, column: 3, scope: !7) 119!34 = !DILocation(line: 11, column: 1, scope: !7) 120!35 = !DILocation(line: 10, column: 3, scope: !7) 121!36 = !DISubprogram(name: "step", linkageName: "_Z4stepv", scope: !1, file: !1, line: 3, type: !37, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !39) 122!37 = !DISubroutineType(types: !38) 123!38 = !{null} 124!39 = !{} 125!40 = !DISubprogram(name: "esc", linkageName: "_Z3escP4Nums", scope: !1, file: !1, line: 2, type: !41, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !39) 126!41 = !DISubroutineType(types: !42) 127!42 = !{null, !43} 128!43 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) 129!44 = distinct !DIAssignID() 130!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 131