File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
lib/SILOptimizer/SILCombiner Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -653,8 +653,20 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
653
653
if (IEI && !OEI &&
654
654
!IEI->getLoweredConcreteType ().hasOpenedExistential ()) {
655
655
assert (!IEI->getLoweredConcreteType ().isOpenedExistential ());
656
+ Builder.setCurrentDebugScope (AS->getDebugScope ());
657
+ auto varInfo = AS->getVarInfo ();
658
+ if (varInfo) {
659
+ if (varInfo->Type == AS->getElementType ()) {
660
+ varInfo->Type = {}; // Lower the variable's type too.
661
+ } else {
662
+ // Cannot salvage the variable, its type has changed and its expression
663
+ // cannot be rewritten.
664
+ Builder.createDebugValue (AS->getLoc (), SILUndef::get (AS), *varInfo);
665
+ varInfo = {};
666
+ }
667
+ }
656
668
auto *ConcAlloc = Builder.createAllocStack (
657
- AS->getLoc (), IEI->getLoweredConcreteType (), AS-> getVarInfo () );
669
+ AS->getLoc (), IEI->getLoweredConcreteType (), varInfo );
658
670
IEI->replaceAllUsesWith (ConcAlloc);
659
671
eraseInstFromFunction (*IEI);
660
672
You can’t perform that action at this time.
0 commit comments