112 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. Similar to6;; single-memory-location.ll except this has slightly more complicated input7;; (there's a loop and an assignment).8;;9;; $ cat test.cpp10;; int get();11;; void esc(int*);12;; void doSomething(int);13;; void fun() {14;; int local;15;; esc(&local);16;; while (local) {17;; local = get();18;; doSomething(local);19;; esc(&local); 20;; }21;; }22;; $ clang++ -O2 -g -emit-llvm -S -c -Xclang -fexperimental-assignment-tracking23 24; CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "local",25; CHECK: stack:26; CHECK-NEXT: - { id: 0, name: local, type: default, offset: 0, size: 4, alignment: 4, 27; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true, 28; CHECK-NEXT: debug-info-variable: '![[VAR]]', debug-info-expression: '!DIExpression()', 29; CHECK-NEXT: debug-info-location: '!{{.+}}' }30 31target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"32target triple = "x86_64-unknown-linux-gnu"33 34; Function Attrs: uwtable mustprogress35define dso_local void @_Z3funv() local_unnamed_addr #0 !dbg !7 {36entry:37 %local = alloca i32, align 4, !DIAssignID !1338 call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !13, metadata ptr %local, metadata !DIExpression()), !dbg !1439 %0 = bitcast ptr %local to ptr, !dbg !1540 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #4, !dbg !1541 call void @_Z3escPi(ptr nonnull %local), !dbg !1642 %1 = load i32, ptr %local, align 4, !dbg !1743 %tobool.not1 = icmp eq i32 %1, 0, !dbg !1744 br i1 %tobool.not1, label %while.end, label %while.body, !dbg !2245 46while.body: ; preds = %entry, %while.body47 %call = call i32 @_Z3getv(), !dbg !2348 store i32 %call, ptr %local, align 4, !dbg !25, !DIAssignID !2649 call void @llvm.dbg.assign(metadata i32 %call, metadata !11, metadata !DIExpression(), metadata !26, metadata ptr %local, metadata !DIExpression()), !dbg !1450 call void @_Z11doSomethingi(i32 %call), !dbg !2751 call void @_Z3escPi(ptr nonnull %local), !dbg !2852 %2 = load i32, ptr %local, align 4, !dbg !1753 %tobool.not = icmp eq i32 %2, 0, !dbg !1754 br i1 %tobool.not, label %while.end, label %while.body, !dbg !22, !llvm.loop !2955 56while.end: ; preds = %while.body, %entry57 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #4, !dbg !3258 ret void, !dbg !3259}60 61declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)62declare !dbg !33 dso_local void @_Z3escPi(ptr) local_unnamed_addr63declare !dbg !37 dso_local i32 @_Z3getv() local_unnamed_addr64declare !dbg !40 dso_local void @_Z11doSomethingi(i32) local_unnamed_addr65declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)66declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)67 68!llvm.dbg.cu = !{!0}69!llvm.module.flags = !{!3, !4, !5, !1000}70!llvm.ident = !{!6}71 72!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)73!1 = !DIFile(filename: "test.cpp", directory: "/")74!2 = !{}75!3 = !{i32 7, !"Dwarf Version", i32 4}76!4 = !{i32 2, !"Debug Info Version", i32 3}77!5 = !{i32 1, !"wchar_size", i32 4}78!6 = !{!"clang version 12.0.0"}79!7 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)80!8 = !DISubroutineType(types: !9)81!9 = !{null}82!10 = !{!11}83!11 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 5, type: !12)84!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)85!13 = distinct !DIAssignID()86!14 = !DILocation(line: 0, scope: !7)87!15 = !DILocation(line: 5, column: 3, scope: !7)88!16 = !DILocation(line: 6, column: 3, scope: !7)89!17 = !DILocation(line: 7, column: 10, scope: !7)90!22 = !DILocation(line: 7, column: 3, scope: !7)91!23 = !DILocation(line: 8, column: 13, scope: !24)92!24 = distinct !DILexicalBlock(scope: !7, file: !1, line: 7, column: 17)93!25 = !DILocation(line: 8, column: 11, scope: !24)94!26 = distinct !DIAssignID()95!27 = !DILocation(line: 9, column: 5, scope: !24)96!28 = !DILocation(line: 10, column: 5, scope: !24)97!29 = distinct !{!29, !22, !30, !31}98!30 = !DILocation(line: 11, column: 3, scope: !7)99!31 = !{!"llvm.loop.mustprogress"}100!32 = !DILocation(line: 12, column: 1, scope: !7)101!33 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !1, file: !1, line: 2, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)102!34 = !DISubroutineType(types: !35)103!35 = !{null, !36}104!36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)105!37 = !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !1, file: !1, line: 1, type: !38, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)106!38 = !DISubroutineType(types: !39)107!39 = !{!12}108!40 = !DISubprogram(name: "doSomething", linkageName: "_Z11doSomethingi", scope: !1, file: !1, line: 3, type: !41, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)109!41 = !DISubroutineType(types: !42)110!42 = !{null, !12}111!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}112