@@ -761,13 +761,14 @@ class IRGenSILFunction :
761
761
762
762
// / Unconditionally emit a stack shadow copy of an \c llvm::Value.
763
763
llvm::Value *emitShadowCopy (llvm::Value *Storage, const SILDebugScope *Scope,
764
- StringRef Name, unsigned ArgNo , Alignment Align) {
764
+ SILDebugVariable VarInfo , Alignment Align) {
765
765
if (Align.isZero ())
766
766
Align = IGM.getPointerAlignment ();
767
767
768
- auto &Alloca = ShadowStackSlots[{ArgNo, {Scope, Name}}];
768
+ unsigned ArgNo = VarInfo.ArgNo ;
769
+ auto &Alloca = ShadowStackSlots[{ArgNo, {Scope, VarInfo.Name }}];
769
770
if (!Alloca.isValid ())
770
- Alloca = createAlloca (Storage->getType (), Align, Name+ " .debug" );
771
+ Alloca = createAlloca (Storage->getType (), Align, VarInfo. Name + " .debug" );
771
772
zeroInit (cast<llvm::AllocaInst>(Alloca.getAddress ()));
772
773
773
774
ArtificialLocation AutoRestore (Scope, IGM.DebugInfo .get (), Builder);
@@ -781,7 +782,7 @@ class IRGenSILFunction :
781
782
// / shadow copies, we lose the precise lifetime.
782
783
llvm::Value *emitShadowCopyIfNeeded (llvm::Value *Storage,
783
784
const SILDebugScope *Scope,
784
- StringRef Name, unsigned ArgNo ,
785
+ SILDebugVariable VarInfo ,
785
786
bool IsAnonymous,
786
787
Alignment Align = Alignment(0 )) {
787
788
// Never emit shadow copies when optimizing, or if already on the stack.
@@ -792,7 +793,7 @@ class IRGenSILFunction :
792
793
return Storage;
793
794
794
795
// Always emit shadow copies for function arguments.
795
- if (ArgNo == 0 )
796
+ if (VarInfo. ArgNo == 0 )
796
797
// Otherwise only if debug value range extension is not feasible.
797
798
if (!needsShadowCopy (Storage)) {
798
799
// Mark for debug value range extension unless this is a constant, or
@@ -809,22 +810,22 @@ class IRGenSILFunction :
809
810
810
811
return Storage;
811
812
}
812
- return emitShadowCopy (Storage, Scope, Name, ArgNo , Align);
813
+ return emitShadowCopy (Storage, Scope, VarInfo , Align);
813
814
}
814
815
815
816
// / Like \c emitShadowCopyIfNeeded() but takes an \c Address instead of an
816
817
// / \c llvm::Value.
817
818
llvm::Value *emitShadowCopyIfNeeded (Address Storage,
818
819
const SILDebugScope *Scope,
819
- StringRef Name, unsigned ArgNo ,
820
+ SILDebugVariable VarInfo ,
820
821
bool IsAnonymous) {
821
- return emitShadowCopyIfNeeded (Storage.getAddress (), Scope, Name, ArgNo ,
822
+ return emitShadowCopyIfNeeded (Storage.getAddress (), Scope, VarInfo ,
822
823
IsAnonymous, Storage.getAlignment ());
823
824
}
824
825
825
826
// / Like \c emitShadowCopyIfNeeded() but takes an exploded value.
826
827
void emitShadowCopyIfNeeded (SILValue &SILVal, const SILDebugScope *Scope,
827
- StringRef Name, unsigned ArgNo , bool IsAnonymous,
828
+ SILDebugVariable VarInfo , bool IsAnonymous,
828
829
llvm::SmallVectorImpl<llvm::Value *> ©) {
829
830
Explosion e = getLoweredExplosion (SILVal);
830
831
@@ -840,13 +841,13 @@ class IRGenSILFunction :
840
841
auto vals = e.claimAll ();
841
842
for (auto val : vals)
842
843
copy.push_back (
843
- emitShadowCopyIfNeeded (val, Scope, Name, ArgNo , IsAnonymous));
844
+ emitShadowCopyIfNeeded (val, Scope, VarInfo , IsAnonymous));
844
845
return ;
845
846
}
846
847
847
848
SILType Type = SILVal->getType ();
848
849
auto <I = cast<LoadableTypeInfo>(IGM.getTypeInfo (Type));
849
- auto Alloca = LTI.allocateStack (*this , Type, Name+ " .debug" );
850
+ auto Alloca = LTI.allocateStack (*this , Type, VarInfo. Name + " .debug" );
850
851
zeroInit (cast<llvm::AllocaInst>(Alloca.getAddress ().getAddress ()));
851
852
ArtificialLocation AutoRestore (Scope, IGM.DebugInfo .get (), Builder);
852
853
LTI.initialize (*this , e, Alloca.getAddress (), false /* isOutlined */ );
@@ -867,22 +868,18 @@ class IRGenSILFunction :
867
868
868
869
// / Emit debug info for a function argument or a local variable.
869
870
template <typename StorageType>
870
- void emitDebugVariableDeclaration (StorageType Storage,
871
- DebugTypeInfo Ty,
872
- SILType SILTy,
873
- const SILDebugScope *DS,
874
- VarDecl *VarDecl,
875
- StringRef Name,
876
- unsigned ArgNo = 0 ,
871
+ void emitDebugVariableDeclaration (StorageType Storage, DebugTypeInfo Ty,
872
+ SILType SILTy, const SILDebugScope *DS,
873
+ VarDecl *VarDecl, SILDebugVariable VarInfo,
877
874
IndirectionKind Indirection = DirectValue) {
878
875
assert (IGM.DebugInfo && " debug info not enabled" );
879
- if (ArgNo) {
876
+ if (VarInfo. ArgNo ) {
880
877
PrologueLocation AutoRestore (IGM.DebugInfo .get (), Builder);
881
878
IGM.DebugInfo ->emitVariableDeclaration (Builder, Storage, Ty, DS, VarDecl,
882
- Name, ArgNo , Indirection);
879
+ VarInfo , Indirection);
883
880
} else
884
881
IGM.DebugInfo ->emitVariableDeclaration (Builder, Storage, Ty, DS, VarDecl,
885
- Name, 0 , Indirection);
882
+ VarInfo , Indirection);
886
883
}
887
884
888
885
void emitFailBB () {
@@ -3649,17 +3646,16 @@ void IRGenSILFunction::emitErrorResultVar(SILResultInfo ErrorInfo,
3649
3646
auto ErrorResultSlot = getErrorResultSlot (IGM.silConv .getSILType (ErrorInfo));
3650
3647
auto Var = DbgValue->getVarInfo ();
3651
3648
assert (Var && " error result without debug info" );
3652
- auto Storage =
3653
- emitShadowCopyIfNeeded (ErrorResultSlot.getAddress (), getDebugScope (),
3654
- Var->Name , Var->ArgNo , false );
3649
+ auto Storage = emitShadowCopyIfNeeded (ErrorResultSlot.getAddress (),
3650
+ getDebugScope (), *Var, false );
3655
3651
if (!IGM.DebugInfo )
3656
3652
return ;
3657
3653
auto DbgTy = DebugTypeInfo::getErrorResult (
3658
3654
ErrorInfo.getType (), ErrorResultSlot->getType (), IGM.getPointerSize (),
3659
3655
IGM.getPointerAlignment ());
3660
- IGM.DebugInfo ->emitVariableDeclaration (
3661
- Builder, Storage, DbgTy, getDebugScope (), nullptr , Var-> Name , Var-> ArgNo ,
3662
- IndirectValue, ArtificialValue);
3656
+ IGM.DebugInfo ->emitVariableDeclaration (Builder, Storage, DbgTy,
3657
+ getDebugScope (), nullptr , * Var,
3658
+ IndirectValue, ArtificialValue);
3663
3659
}
3664
3660
3665
3661
void IRGenSILFunction::visitDebugValueInst (DebugValueInst *i) {
@@ -3680,30 +3676,30 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
3680
3676
}
3681
3677
3682
3678
bool IsAnonymous = false ;
3683
- StringRef Name = getVarName (i, IsAnonymous);
3679
+ VarInfo-> Name = getVarName (i, IsAnonymous);
3684
3680
DebugTypeInfo DbgTy;
3685
3681
SILType SILTy = SILVal->getType ();
3686
3682
auto RealTy = SILVal->getType ().getASTType ();
3687
3683
if (VarDecl *Decl = i->getDecl ()) {
3688
3684
DbgTy = DebugTypeInfo::getLocalVariable (
3689
3685
Decl, RealTy, getTypeInfo (SILVal->getType ()));
3690
3686
} else if (i->getFunction ()->isBare () &&
3691
- !SILTy.hasArchetype () && !Name.empty ()) {
3687
+ !SILTy.hasArchetype () && !VarInfo-> Name .empty ()) {
3692
3688
// Preliminary support for .sil debug information.
3693
3689
DbgTy = DebugTypeInfo::getFromTypeInfo (RealTy, getTypeInfo (SILTy));
3694
3690
} else
3695
3691
return ;
3696
3692
3697
3693
// Put the value into a stack slot at -Onone.
3698
3694
llvm::SmallVector<llvm::Value *, 8 > Copy;
3699
- emitShadowCopyIfNeeded (SILVal, i->getDebugScope (), Name, VarInfo-> ArgNo ,
3700
- IsAnonymous, Copy);
3695
+ emitShadowCopyIfNeeded (SILVal, i->getDebugScope (), *VarInfo, IsAnonymous ,
3696
+ Copy);
3701
3697
bindArchetypes (DbgTy.getType ());
3702
3698
if (!IGM.DebugInfo )
3703
3699
return ;
3704
3700
3705
3701
emitDebugVariableDeclaration (Copy, DbgTy, SILTy, i->getDebugScope (),
3706
- i->getDecl (), Name, VarInfo-> ArgNo );
3702
+ i->getDecl (), * VarInfo);
3707
3703
}
3708
3704
3709
3705
void IRGenSILFunction::visitDebugValueAddrInst (DebugValueAddrInst *i) {
@@ -3722,7 +3718,7 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
3722
3718
assert (VarInfo && " debug_value_addr without debug info" );
3723
3719
bool IsAnonymous = false ;
3724
3720
bool IsLoadablyByAddress = isa<AllocStackInst>(SILVal);
3725
- StringRef Name = getVarName (i, IsAnonymous);
3721
+ VarInfo-> Name = getVarName (i, IsAnonymous);
3726
3722
auto Addr = getLoweredAddress (SILVal).getAddress ();
3727
3723
SILType SILTy = SILVal->getType ();
3728
3724
auto RealType = SILTy.getASTType ();
@@ -3736,9 +3732,8 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
3736
3732
// Put the value's address into a stack slot at -Onone and emit a debug
3737
3733
// intrinsic.
3738
3734
emitDebugVariableDeclaration (
3739
- emitShadowCopyIfNeeded (Addr, i->getDebugScope (), Name, VarInfo->ArgNo ,
3740
- IsAnonymous),
3741
- DbgTy, SILType (), i->getDebugScope (), Decl, Name, VarInfo->ArgNo ,
3735
+ emitShadowCopyIfNeeded (Addr, i->getDebugScope (), *VarInfo, IsAnonymous),
3736
+ DbgTy, SILType (), i->getDebugScope (), Decl, *VarInfo,
3742
3737
(IsLoadablyByAddress) ? DirectValue : IndirectValue);
3743
3738
}
3744
3739
@@ -4000,7 +3995,7 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
4000
3995
return ;
4001
3996
4002
3997
bool IsAnonymous = false ;
4003
- StringRef Name = getVarName (i, IsAnonymous);
3998
+ VarInfo-> Name = getVarName (i, IsAnonymous);
4004
3999
4005
4000
// At this point addr must be an alloca or an undef.
4006
4001
assert (isa<llvm::AllocaInst>(addr) || isa<llvm::UndefValue>(addr) ||
@@ -4011,8 +4006,7 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
4011
4006
if (auto *Alloca = dyn_cast<llvm::AllocaInst>(addr))
4012
4007
if (!Alloca->isStaticAlloca ()) {
4013
4008
// Store the address of the dynamic alloca on the stack.
4014
- addr = emitShadowCopy (addr, DS, Name, VarInfo->ArgNo ,
4015
- IGM.getPointerAlignment ());
4009
+ addr = emitShadowCopy (addr, DS, *VarInfo, IGM.getPointerAlignment ());
4016
4010
Indirection = IndirectValue;
4017
4011
}
4018
4012
@@ -4031,8 +4025,8 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
4031
4025
4032
4026
bindArchetypes (DbgTy.getType ());
4033
4027
if (IGM.DebugInfo )
4034
- emitDebugVariableDeclaration (addr, DbgTy, SILTy, DS, Decl, Name ,
4035
- VarInfo-> ArgNo , Indirection);
4028
+ emitDebugVariableDeclaration (addr, DbgTy, SILTy, DS, Decl, *VarInfo ,
4029
+ Indirection);
4036
4030
}
4037
4031
4038
4032
void IRGenSILFunction::visitAllocStackInst (swift::AllocStackInst *i) {
@@ -4232,16 +4226,18 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
4232
4226
auto RealType = SILTy.getASTType ();
4233
4227
auto DbgTy = DebugTypeInfo::getLocalVariable (Decl, RealType, type);
4234
4228
4229
+ auto VarInfo = i->getVarInfo ();
4230
+ assert (VarInfo && " debug_value without debug info" );
4231
+
4235
4232
auto Storage = emitShadowCopyIfNeeded (
4236
- boxWithAddr.getAddress (), i->getDebugScope (), Name, 0 , IsAnonymous);
4233
+ boxWithAddr.getAddress (), i->getDebugScope (), *VarInfo , IsAnonymous);
4237
4234
4238
4235
if (!IGM.DebugInfo )
4239
4236
return ;
4240
4237
4241
- IGM.DebugInfo ->emitVariableDeclaration (
4242
- Builder,
4243
- Storage,
4244
- DbgTy, i->getDebugScope (), Decl, Name, 0 , IndirectValue);
4238
+ IGM.DebugInfo ->emitVariableDeclaration (Builder, Storage, DbgTy,
4239
+ i->getDebugScope (), Decl, *VarInfo,
4240
+ IndirectValue);
4245
4241
}
4246
4242
4247
4243
void IRGenSILFunction::visitProjectBoxInst (swift::ProjectBoxInst *i) {
0 commit comments