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