@@ -3167,17 +3167,20 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
3167
3167
StringRef Name = getVarName (i);
3168
3168
DebugTypeInfo DbgTy;
3169
3169
SILType SILTy = SILVal->getType ();
3170
- if (VarDecl *Decl = i->getDecl ())
3171
- DbgTy = DebugTypeInfo (Decl, Decl->getType (), getTypeInfo (SILTy));
3172
- else if (i->getFunction ()->isBare () &&
3173
- !SILTy.getSwiftType ()->hasArchetype () && !Name.empty ())
3174
- // Preliminary support for .sil debug information.
3175
- DbgTy = DebugTypeInfo (SILTy.getSwiftType (), getTypeInfo (SILTy), nullptr );
3176
- else
3177
- return ;
3178
3170
// An inout/lvalue type that is described by a debug value has been
3179
3171
// promoted by an optimization pass. Unwrap the type.
3180
- DbgTy.unwrapLValueOrInOutType ();
3172
+ bool Unwrap = true ;
3173
+ auto RealTy = SILVal->getType ().getSwiftType ();
3174
+ if (VarDecl *Decl = i->getDecl ()) {
3175
+ DbgTy = DebugTypeInfo (Decl, RealTy, getTypeInfo (SILVal->getType ()), Unwrap);
3176
+ } else if (i->getFunction ()->isBare () &&
3177
+ !SILTy.getSwiftType ()->hasArchetype () && !Name.empty ()) {
3178
+ // Preliminary support for .sil debug information.
3179
+ DbgTy = DebugTypeInfo (RealTy, getTypeInfo (SILTy), nullptr );
3180
+ if (Unwrap)
3181
+ DbgTy.unwrapLValueOrInOutType ();
3182
+ } else
3183
+ return ;
3181
3184
3182
3185
// Put the value into a stack slot at -Onone.
3183
3186
llvm::SmallVector<llvm::Value *, 8 > Copy;
@@ -3200,12 +3203,13 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
3200
3203
3201
3204
StringRef Name = getVarName (i);
3202
3205
auto Addr = getLoweredAddress (SILVal).getAddress ();
3203
- DebugTypeInfo DbgTy (Decl, SILVal->getType ().getSwiftType (),
3204
- getTypeInfo (SILVal->getType ()));
3206
+ auto RealType = SILVal->getType ().getSwiftType ();
3205
3207
// Unwrap implicitly indirect types and types that are passed by
3206
3208
// reference only at the SIL level and below.
3207
- if (DbgTy.isArchetype () || i->getVarInfo ().Constant )
3208
- DbgTy.unwrapLValueOrInOutType ();
3209
+ bool Unwrap =
3210
+ i->getVarInfo ().Constant ||
3211
+ RealType->getLValueOrInOutObjectType ()->getKind () == TypeKind::Archetype;
3212
+ DebugTypeInfo DbgTy (Decl, RealType, getTypeInfo (SILVal->getType ()), Unwrap);
3209
3213
// Put the value's address into a stack slot at -Onone and emit a debug
3210
3214
// intrinsic.
3211
3215
unsigned ArgNo = i->getVarInfo ().ArgNo ;
@@ -3468,11 +3472,12 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
3468
3472
Pattern->getKind () != PatternKind::OptionalSome)
3469
3473
return ;
3470
3474
3471
- auto DbgTy = DebugTypeInfo (Decl, type);
3472
3475
// Discard any inout or lvalue qualifiers. Since the object itself
3473
3476
// is stored in the alloca, emitting it as a reference type would
3474
3477
// be wrong.
3475
- DbgTy.unwrapLValueOrInOutType ();
3478
+ bool Unwrap = true ;
3479
+ auto RealType = i->getType ().getSwiftType ().getLValueOrInOutObjectType ();
3480
+ auto DbgTy = DebugTypeInfo (Decl, RealType, type, Unwrap);
3476
3481
StringRef Name = getVarName (i);
3477
3482
if (auto DS = i->getDebugScope ())
3478
3483
emitDebugVariableDeclaration (addr, DbgTy, DS, Name,
@@ -3628,7 +3633,7 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
3628
3633
if (Name == IGM.Context .Id_self .str ())
3629
3634
return ;
3630
3635
3631
- DebugTypeInfo DbgTy (Decl, i->getElementType ().getSwiftType (), type);
3636
+ DebugTypeInfo DbgTy (Decl, i->getElementType ().getSwiftType (), type, false );
3632
3637
IGM.DebugInfo ->emitVariableDeclaration (
3633
3638
Builder,
3634
3639
emitShadowCopy (boxWithAddr.getAddress (), i->getDebugScope (), Name, 0 ),
0 commit comments