@@ -334,14 +334,16 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
334
334
registerLocalArchetypeRemapping (archetypeTy, replacementTy);
335
335
}
336
336
337
- // SILCloner will take care of debug scope on the instruction
338
- // and this helper will remap the auxiliary debug scope too, if there is any.
339
- void remapDebugVarInfo (DebugVarCarryingInst DbgVarInst ) {
340
- if (!DbgVarInst )
337
+ // / SILCloner will take care of debug scope on the instruction
338
+ // / and this helper will remap the auxiliary debug scope too, if there is any.
339
+ void remapDebugVariable (std::optional<SILDebugVariable> &VarInfo ) {
340
+ if (!VarInfo )
341
341
return ;
342
- auto VarInfo = DbgVarInst.getVarInfo ();
343
- if (VarInfo && VarInfo->Scope )
344
- DbgVarInst.setDebugVarScope (getOpScope (VarInfo->Scope ));
342
+ if (VarInfo->Type )
343
+ VarInfo->Type = getOpType (*VarInfo->Type );
344
+ // Don't remap locations for debug values.
345
+ if (VarInfo->Scope )
346
+ VarInfo->Scope = getOpScope (VarInfo->Scope );
345
347
}
346
348
347
349
ProtocolConformanceRef getOpConformance (Type ty,
@@ -875,8 +877,7 @@ SILCloner<ImplClass>::visitAllocStackInst(AllocStackInst *Inst) {
875
877
Loc = MandatoryInlinedLocation::getAutoGeneratedLocation ();
876
878
VarInfo = std::nullopt;
877
879
}
878
- if (VarInfo && VarInfo->Type )
879
- VarInfo->Type = getOpType (*VarInfo->Type );
880
+ remapDebugVariable (VarInfo);
880
881
auto *NewInst = getBuilder ().createAllocStack (
881
882
Loc, getOpType (Inst->getElementType ()), VarInfo,
882
883
Inst->hasDynamicLifetime (), Inst->isLexical (), Inst->isFromVarDecl (),
@@ -886,7 +887,6 @@ SILCloner<ImplClass>::visitAllocStackInst(AllocStackInst *Inst) {
886
887
true
887
888
#endif
888
889
);
889
- remapDebugVarInfo (DebugVarCarryingInst (NewInst));
890
890
recordClonedInstruction (Inst, NewInst);
891
891
}
892
892
@@ -1409,14 +1409,12 @@ SILCloner<ImplClass>::visitDebugValueInst(DebugValueInst *Inst) {
1409
1409
return ;
1410
1410
1411
1411
// Since we want the debug info to survive, we do not remap the location here.
1412
- SILDebugVariable VarInfo = * Inst->getVarInfo ();
1412
+ std::optional< SILDebugVariable> VarInfo = Inst->getVarInfo ();
1413
1413
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
1414
- if (VarInfo.Type )
1415
- VarInfo.Type = getOpType (*VarInfo.Type );
1414
+ remapDebugVariable (VarInfo);
1416
1415
auto *NewInst = getBuilder ().createDebugValue (
1417
- Inst->getLoc (), getOpValue (Inst->getOperand ()), VarInfo,
1416
+ Inst->getLoc (), getOpValue (Inst->getOperand ()), * VarInfo,
1418
1417
Inst->poisonRefs (), Inst->usesMoveableValueDebugInfo (), Inst->hasTrace ());
1419
- remapDebugVarInfo (DebugVarCarryingInst (NewInst));
1420
1418
recordClonedInstruction (Inst, NewInst);
1421
1419
}
1422
1420
template <typename ImplClass>
0 commit comments