92 lines · plain
1; RUN: llc -stop-after=finalize-isel %s -o - \2; RUN: | FileCheck %s3 4;; Check that a dbg.assign for a fully stack-homed variable causes the variable5;; location to appear in the Machine Function side table (variable 'local').6;;7;; The variable 'local2' is tracked using a dbg.declare. Check the variable is8;; dropped and doesn't cause a crash when the address is an empty metadata9;; tuple and assignment tracking is enabled for the function.10;;11;; $ cat test.cpp12;; void maybe_writes(int*);13;; void ext(int, int, int, int, int, int, int, int, int, int);14;; int example() {15;; int local;16;; maybe_writes(&local);17;; ext(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);18;; return local;19;; }20;; $ clang++ -O2 -g -emit-llvm -S -c -Xclang -fexperimental-assignment-tracking21 22; CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "local",23; CHECK: stack:24; CHECK-NEXT: - { id: 0, name: local, type: default, offset: 0, size: 4, alignment: 4,25; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true,26; CHECK-NEXT: debug-info-variable: '![[VAR]]', debug-info-expression: '!DIExpression()',27; CHECK-NEXT: debug-info-location: '!{{.+}}' }28; CHECK-NEXT: - { id: 1, name: local2, type: default, offset: 0, size: 4, alignment: 4,29; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true,30; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }31 32source_filename = "test.cpp"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 36define dso_local i32 @_Z7examplev() local_unnamed_addr !dbg !7 {37entry:38 %local = alloca i32, align 4, !DIAssignID !1339 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %local, metadata !DIExpression()), !dbg !1440 %local2 = alloca i32, align 441 call void @llvm.dbg.declare(metadata !2, metadata !32, metadata !DIExpression()), !dbg !1442 %0 = bitcast ptr %local to ptr, !dbg !1543 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0), !dbg !1544 call void @_Z12maybe_writesPi(ptr nonnull %local), !dbg !1645 call void @_Z3extiiiiiiiiii(i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9), !dbg !1746 %1 = load i32, ptr %local, align 4, !dbg !1847 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0), !dbg !2348 ret i32 %1, !dbg !2449}50 51declare !dbg !25 dso_local void @_Z12maybe_writesPi(ptr) local_unnamed_addr52declare !dbg !29 dso_local void @_Z3extiiiiiiiiii(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) local_unnamed_addr53declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)54declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)55declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)56declare void @llvm.dbg.declare(metadata, metadata, metadata)57 58!llvm.dbg.cu = !{!0}59!llvm.module.flags = !{!3, !4, !5, !1000}60!llvm.ident = !{!6}61 62!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)63!1 = !DIFile(filename: "test.cpp", directory: "/")64!2 = !{}65!3 = !{i32 7, !"Dwarf Version", i32 4}66!4 = !{i32 2, !"Debug Info Version", i32 3}67!5 = !{i32 1, !"wchar_size", i32 4}68!6 = !{!"clang version 12.0.0"}69!7 = distinct !DISubprogram(name: "example", linkageName: "_Z7examplev", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)70!8 = !DISubroutineType(types: !9)71!9 = !{!10}72!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)73!11 = !{!12}74!12 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 4, type: !10)75!13 = distinct !DIAssignID()76!14 = !DILocation(line: 0, scope: !7)77!15 = !DILocation(line: 4, column: 4, scope: !7)78!16 = !DILocation(line: 5, column: 4, scope: !7)79!17 = !DILocation(line: 6, column: 4, scope: !7)80!18 = !DILocation(line: 7, column: 11, scope: !7)81!23 = !DILocation(line: 8, column: 1, scope: !7)82!24 = !DILocation(line: 7, column: 4, scope: !7)83!25 = !DISubprogram(name: "maybe_writes", linkageName: "_Z12maybe_writesPi", scope: !1, file: !1, line: 1, type: !26, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)84!26 = !DISubroutineType(types: !27)85!27 = !{null, !28}86!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)87!29 = !DISubprogram(name: "ext", linkageName: "_Z3extiiiiiiiiii", scope: !1, file: !1, line: 2, type: !30, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)88!30 = !DISubroutineType(types: !31)89!31 = !{null, !10, !10, !10, !10, !10, !10, !10, !10, !10, !10}90!32 = !DILocalVariable(name: "local2", scope: !7, file: !1, line: 4, type: !10)91!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}92