122 lines · plain
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 %s -stop-before finalize-isel -o - \7; RUN: -experimental-debug-variable-locations=true \8; RUN: | FileCheck %s --implicit-check-not=DBG_9 10;; Check that the mem-loc-frag-fill analysis works on a simple case; ensure11;; that location definitions are added to preserve memory locations of12;; fragments of variables at subsequent location definitions for other13;; fragments of the variable are not currently in memory.14 15;; Test generated from:16;; $ cat test.cpp17;; struct Nums { int a, b, c; };18;; void esc(struct Nums*);19;; void step();20;; int main() {21;; struct Nums nums = { 1, 2, 1 }; //< Store to .c is elided.22;; step();23;; nums.c = 2; //< Killing store.24;; step();25;; esc(&nums);26;; return 0;27;; }28;; $ clang++ test.cpp -O2 -g -Xclang -fexperimental-assignmment-tracking -emit-llvm -S -o -29 30;; Most check lines are inline in main.31; CHECK: ![[nums:[0-9]+]] = !DILocalVariable(name: "nums",32 33target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"34target triple = "x86_64-unknown-linux-gnu"35 36%struct.Nums = type { i32, i32, i32 }37 38; Function Attrs: mustprogress norecurse uwtable39define dso_local noundef i32 @main() local_unnamed_addr #0 !dbg !7 {40entry:41 %nums = alloca %struct.Nums, align 8, !DIAssignID !1842; CHECK: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref)43 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !18, metadata ptr %nums, metadata !DIExpression()), !dbg !1944 store i64 8589934593, ptr %nums, align 8, !dbg !21, !DIAssignID !2245; CHECK: MOV64mr %stack.0.nums, 1, $noreg, 0, $noreg, killed %046 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !22, metadata ptr %nums, metadata !DIExpression()), !dbg !1947 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 !1948; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[nums]], !DIExpression(DW_OP_LLVM_fragment, 64, 32)49; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 64)50 tail call void @_Z4stepv(), !dbg !2351 %c = getelementptr inbounds %struct.Nums, ptr %nums, i64 0, i32 2, !dbg !2452 store i32 2, ptr %c, align 8, !dbg !25, !DIAssignID !3153; CHECK: MOV32mi %stack.0.nums, 1, $noreg, 8, $noreg, 254 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 !1955; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref)56 tail call void @_Z4stepv(), !dbg !3257;; Next dbg.assign added by hand to test that the bits [64, 32) have been58;; correctly tracked as in memory - we know this has worked if59;; mem-loc-frag-fill reinstates the memory location after this kill-location60;; for bits [80, 96).61 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 !1962; CHECK: CALL64pcrel32 @_Z4stepv63; CHECK-NEXT: ADJCALLSTACKUP6464; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[nums]], !DIExpression(DW_OP_LLVM_fragment, 80, 16)65; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 80)66 tail call void @_Z4stepv(), !dbg !3267 call void @_Z3escP4Nums(ptr noundef nonnull %nums), !dbg !3368 ret i32 0, !dbg !3569}70 71declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #172declare !dbg !36 dso_local void @_Z4stepv() local_unnamed_addr #273declare !dbg !40 dso_local void @_Z3escP4Nums(ptr noundef) local_unnamed_addr #274declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #175declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #376 77!llvm.dbg.cu = !{!0}78!llvm.module.flags = !{!2, !3, !4, !5, !1000}79!llvm.ident = !{!6}80 81!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)82!1 = !DIFile(filename: "test.cpp", directory: "/")83!2 = !{i32 7, !"Dwarf Version", i32 5}84!3 = !{i32 2, !"Debug Info Version", i32 3}85!4 = !{i32 1, !"wchar_size", i32 4}86!5 = !{i32 7, !"uwtable", i32 1}87!6 = !{!"clang version 14.0.0"}88!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)89!8 = !DISubroutineType(types: !9)90!9 = !{!10}91!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)92!11 = !{!12}93!12 = !DILocalVariable(name: "nums", scope: !7, file: !1, line: 5, type: !13)94!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nums", file: !1, line: 1, size: 96, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS4Nums")95!14 = !{!15, !16, !17}96!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !1, line: 1, baseType: !10, size: 32)97!16 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !1, line: 1, baseType: !10, size: 32, offset: 32)98!17 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !13, file: !1, line: 1, baseType: !10, size: 32, offset: 64)99!18 = distinct !DIAssignID()100!19 = !DILocation(line: 0, scope: !7)101!20 = !DILocation(line: 5, column: 3, scope: !7)102!21 = !DILocation(line: 5, column: 15, scope: !7)103!22 = distinct !DIAssignID()104!23 = !DILocation(line: 6, column: 3, scope: !7)105!24 = !DILocation(line: 7, column: 8, scope: !7)106!25 = !DILocation(line: 7, column: 10, scope: !7)107!31 = distinct !DIAssignID()108!32 = !DILocation(line: 8, column: 3, scope: !7)109!33 = !DILocation(line: 9, column: 3, scope: !7)110!34 = !DILocation(line: 11, column: 1, scope: !7)111!35 = !DILocation(line: 10, column: 3, scope: !7)112!36 = !DISubprogram(name: "step", linkageName: "_Z4stepv", scope: !1, file: !1, line: 3, type: !37, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !39)113!37 = !DISubroutineType(types: !38)114!38 = !{null}115!39 = !{}116!40 = !DISubprogram(name: "esc", linkageName: "_Z3escP4Nums", scope: !1, file: !1, line: 2, type: !41, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !39)117!41 = !DISubroutineType(types: !42)118!42 = !{null, !43}119!43 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)120!44 = distinct !DIAssignID()121!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}122