brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.5 KiB · 747ac04 Raw
150 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 pseudo-pass works on a simple CFG. When11;; LLVM sees a dbg.value with an overlapping fragment it essentially considers12;; the previous location as valid for all bits in that fragment. The pass13;; tracks which bits are in memory and inserts dbg.values preserve memory14;; locations for bits in memory when overlapping fragments are encountered.15 16;; nums lives in mem, except prior to the second call to step() where there has17;; been some DSE. At this point, the memory loc for nums.c is invalid.  But the18;; rest of num's bits, [0, 64), are in memory, so check there's a dbg.value for19;; them.20 21;; $ cat test.cpp22;; struct Nums { int a, b, c; };23;;24;; void esc1(struct Nums*);25;; void esc2(struct Nums*);26;; bool step();27;;28;; int main() {29;;   struct Nums nums = { 1, 2, 1 };30;;   if (step())31;;     esc1(&nums);32;;   else33;;     esc2(&nums);34;;35;;   nums.c = 2; //< Include some DSE to force a non-mem location.36;;   step();37;;38;;   nums.c = nums.a;39;;40;;   esc1(&nums);41;;   return 0;42;; }43;;44;; $ clang++ test.cpp -O2 -g -Xclang -fexperimental-assignment-tracking -emit-llvm -S -o -45 46;; Most check lines are inline in main.47; CHECK: ![[nums:[0-9]+]] = !DILocalVariable(name: "nums",48 49target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"50target triple = "x86_64-unknown-linux-gnu"51 52%struct.Nums = type { i32, i32, i32 }53 54@__const.main.nums = private unnamed_addr constant %struct.Nums { i32 1, i32 2, i32 1 }, align 455 56declare void @_Z4esc1P4Nums(ptr nocapture noundef readonly %p)57declare void @_Z4esc2P4Nums(ptr nocapture noundef readonly %p)58 59; Function Attrs: mustprogress norecurse uwtable60define dso_local noundef i32 @main() local_unnamed_addr #3 !dbg !40 {61; CHECK: name: main62entry:63  %nums = alloca %struct.Nums, align 4, !DIAssignID !4564  call void @llvm.dbg.assign(metadata i1 undef, metadata !44, metadata !DIExpression(), metadata !45, metadata ptr %nums, metadata !DIExpression()), !dbg !4665; CHECK: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref)66  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %nums, ptr noundef nonnull align 4 dereferenceable(12) %nums, i64 12, i1 false), !dbg !48, !DIAssignID !4967  call void @llvm.dbg.assign(metadata i1 undef, metadata !44, metadata !DIExpression(), metadata !49, metadata ptr %nums, metadata !DIExpression()), !dbg !4668  %call = tail call noundef zeroext i1 @_Z4stepv(), !dbg !5069  br i1 %call, label %if.then, label %if.else, !dbg !5270 71if.then:                                          ; preds = %entry72  call void @_Z4esc1P4Nums(ptr noundef nonnull %nums), !dbg !5373  br label %if.end, !dbg !5374 75if.else:                                          ; preds = %entry76  call void @_Z4esc2P4Nums(ptr noundef nonnull %nums), !dbg !5477  br label %if.end78 79if.end:                                           ; preds = %if.else, %if.then80; CHECK: bb.3.if.end:81; CHECK-NEXT: DBG_VALUE 2, $noreg, ![[nums]], !DIExpression(DW_OP_LLVM_fragment, 64, 32), debug-location82; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 64)83  %c = getelementptr inbounds %struct.Nums, ptr %nums, i64 0, i32 2, !dbg !5584  call void @llvm.dbg.assign(metadata i32 2, metadata !44, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !56, metadata ptr %c, metadata !DIExpression()), !dbg !4685  %call1 = tail call noundef zeroext i1 @_Z4stepv(), !dbg !5786  store i32 1, ptr %c, align 4, !dbg !58, !DIAssignID !6187;; Store to bits 64 to 96 - the whole variable is in memory again.88; CHECK:      MOV32mi %stack.0.nums, 1, $noreg, 8, $noreg, 189; CHECK-NEXT: DBG_VALUE %stack.0.nums, $noreg, ![[nums]], !DIExpression(DW_OP_deref)90  call void @llvm.dbg.assign(metadata i32 1, metadata !44, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !61, metadata ptr %c, metadata !DIExpression()), !dbg !4691  call void @_Z4esc1P4Nums(ptr noundef nonnull %nums), !dbg !6292  ret i32 0, !dbg !6493}94 95declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #496declare !dbg !65 dso_local noundef zeroext i1 @_Z4stepv() local_unnamed_addr #597declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #498declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #199declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #2100 101!llvm.dbg.cu = !{!2}102!llvm.module.flags = !{!11, !12, !13, !14, !1000}103!llvm.ident = !{!15}104 105!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())106!1 = distinct !DIGlobalVariable(name: "glob", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true)107!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)108!3 = !DIFile(filename: "test.cpp", directory: "/")109!4 = !{!0}110!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nums", file: !3, line: 1, size: 96, flags: DIFlagTypePassByValue, elements: !6, identifier: "_ZTS4Nums")111!6 = !{!7, !9, !10}112!7 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !5, file: !3, line: 1, baseType: !8, size: 32)113!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)114!9 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !3, line: 1, baseType: !8, size: 32, offset: 32)115!10 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !3, line: 1, baseType: !8, size: 32, offset: 64)116!11 = !{i32 7, !"Dwarf Version", i32 5}117!12 = !{i32 2, !"Debug Info Version", i32 3}118!13 = !{i32 1, !"wchar_size", i32 4}119!14 = !{i32 7, !"uwtable", i32 1}120!15 = !{!"clang version 14.0.0"}121!40 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 7, type: !41, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !43)122!41 = !DISubroutineType(types: !42)123!42 = !{!8}124!43 = !{!44}125!44 = !DILocalVariable(name: "nums", scope: !40, file: !3, line: 8, type: !5)126!45 = distinct !DIAssignID()127!46 = !DILocation(line: 0, scope: !40)128!47 = !DILocation(line: 8, column: 3, scope: !40)129!48 = !DILocation(line: 8, column: 15, scope: !40)130!49 = distinct !DIAssignID()131!50 = !DILocation(line: 9, column: 7, scope: !51)132!51 = distinct !DILexicalBlock(scope: !40, file: !3, line: 9, column: 7)133!52 = !DILocation(line: 9, column: 7, scope: !40)134!53 = !DILocation(line: 10, column: 5, scope: !51)135!54 = !DILocation(line: 12, column: 5, scope: !51)136!55 = !DILocation(line: 14, column: 8, scope: !40)137!56 = distinct !DIAssignID()138!57 = !DILocation(line: 15, column: 3, scope: !40)139!58 = !DILocation(line: 17, column: 10, scope: !40)140!61 = distinct !DIAssignID()141!62 = !DILocation(line: 19, column: 3, scope: !40)142!63 = !DILocation(line: 21, column: 1, scope: !40)143!64 = !DILocation(line: 20, column: 3, scope: !40)144!65 = !DISubprogram(name: "step", linkageName: "_Z4stepv", scope: !3, file: !3, line: 5, type: !66, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !69)145!66 = !DISubroutineType(types: !67)146!67 = !{!68}147!68 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)148!69 = !{}149!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}150