brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · d2ac095 Raw
117 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 --check-prefixes=CHECK,DBGVALUE --implicit-check-not=DBG_VALUE5 6; RUN: llc %s -stop-before finalize-isel -o - \7; RUN:    -experimental-debug-variable-locations=true \8; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF --implicit-check-not=DBG_VALUE \9; RUN:    --implicit-check-not=DBG_INSTR_REF10 11;; Check that dbg.assigns for an aggregate variable which lives on the stack12;; for some of its lifetime are lowered into an appropriate set of DBG_VALUEs.13;;14;; $ cat test.cpp15;; void esc(long* p);16;; struct Ex {17;;   long A;18;;   long B;19;; };20;; long fun() {21;;   Ex X;22;;   X.B = 0;23;;   esc(&X.B);24;;   X.B += 2;25;;   return X.B;26;; }27;; $ clang++ test.cpp -O2 -g -emit-llvm -S -c -Xclang -fexperimental-assignment-tracking28 29; CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "X",30;; Check we have no debug info for local in the side table.31; CHECK: stack:32; CHECK-NEXT: - { id: 0, name: X, type: default, offset: 0, size: 16, alignment: 8,33; CHECK-NEXT:     stack-id: default, callee-saved-register: '', callee-saved-restored: true,34; CHECK-NEXT:     debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }35 36;; Initially the whole variable is on the stack.37; CHECK: bb.0.entry:38; CHECK-NEXT: DBG_VALUE %stack.0.X, $noreg, ![[VAR]], !DIExpression(DW_OP_deref), debug-location39 40;; Then there is a store to the upper 64 bits.41; CHECK: MOV64mi32 %stack.0.X, 1, $noreg, 8, $noreg, 0, debug-location42;; No change in variable location: the stack home is still valid.43 44;; The final assignment (X.B += 2) doesn't get stored back to the alloca. This45;; means that that the stack location isn't valid for the entire lifetime of X.46; DBGVALUE: %2:gr64 = nsw ADD64ri32 %1, 2, implicit-def dead $eflags, debug-location47; DBGVALUE-NEXT: DBG_VALUE %2, $noreg, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64), debug-location48; INSTRREF: %2:gr64 = nsw ADD64ri32 %1, 2, implicit-def dead $eflags, debug-instr-number 149; INSTRREF-NEXT: DBG_INSTR_REF ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_fragment, 64, 64), dbg-instr-ref(1, 0), debug-location50 51;; Bits [0, 64) are still stack homed. FIXME, this particular reinstatement is52;; unnecessary.53; CHECK-NEXT: DBG_VALUE %stack.0.X, $noreg, ![[VAR]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 64)54 55source_filename = "test.cpp"56target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"57target triple = "x86_64-unknown-linux-gnu"58 59%struct.Ex = type { i64, i64 }60 61define dso_local i64 @_Z3funv() local_unnamed_addr !dbg !7 {62entry:63  %X = alloca %struct.Ex, align 8, !DIAssignID !1764  call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !17, metadata ptr %X, metadata !DIExpression()), !dbg !1865  %B = getelementptr inbounds %struct.Ex, ptr %X, i64 0, i32 1, !dbg !2066  store i64 0, ptr %B, align 8, !dbg !21, !DIAssignID !2767  call void @llvm.dbg.assign(metadata i64 0, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64), metadata !27, metadata ptr %B, metadata !DIExpression()), !dbg !2168  call void @_Z3escPl(ptr nonnull %B), !dbg !2869  %0 = load i64, ptr %B, align 8, !dbg !2970  %add = add nsw i64 %0, 2, !dbg !2971  call void @llvm.dbg.assign(metadata i64 %add, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64), metadata !30, metadata ptr %B, metadata !DIExpression()), !dbg !2972  ret i64 %add, !dbg !3273}74 75declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)76declare !dbg !33 dso_local void @_Z3escPl(ptr) local_unnamed_addr77declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)78declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)79 80!llvm.dbg.cu = !{!0}81!llvm.module.flags = !{!3, !4, !5, !1000}82!llvm.ident = !{!6}83 84!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)85!1 = !DIFile(filename: "test.cpp", directory: "/")86!2 = !{}87!3 = !{i32 7, !"Dwarf Version", i32 4}88!4 = !{i32 2, !"Debug Info Version", i32 3}89!5 = !{i32 1, !"wchar_size", i32 4}90!6 = !{!"clang version 12.0.0"}91!7 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)92!8 = !DISubroutineType(types: !9)93!9 = !{!10}94!10 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)95!11 = !{!12}96!12 = !DILocalVariable(name: "X", scope: !7, file: !1, line: 7, type: !13)97!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Ex", file: !1, line: 2, size: 128, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS2Ex")98!14 = !{!15, !16}99!15 = !DIDerivedType(tag: DW_TAG_member, name: "A", scope: !13, file: !1, line: 3, baseType: !10, size: 64)100!16 = !DIDerivedType(tag: DW_TAG_member, name: "B", scope: !13, file: !1, line: 4, baseType: !10, size: 64, offset: 64)101!17 = distinct !DIAssignID()102!18 = !DILocation(line: 0, scope: !7)103!19 = !DILocation(line: 7, column: 3, scope: !7)104!20 = !DILocation(line: 8, column: 5, scope: !7)105!21 = !DILocation(line: 8, column: 7, scope: !7)106!27 = distinct !DIAssignID()107!28 = !DILocation(line: 9, column: 3, scope: !7)108!29 = !DILocation(line: 10, column: 7, scope: !7)109!30 = distinct !DIAssignID()110!31 = !DILocation(line: 12, column: 1, scope: !7)111!32 = !DILocation(line: 11, column: 3, scope: !7)112!33 = !DISubprogram(name: "esc", linkageName: "_Z3escPl", scope: !1, file: !1, line: 1, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)113!34 = !DISubroutineType(types: !35)114!35 = !{null, !36}115!36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)116!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}117