[SILOptimizer] Fix a bug in edge-splitting wherein we did not create a new phi argument for blocks

Exposed in stack promotion / when doing stack nesting

rdar://problem/48603037
This commit is contained in:
Joe Shajrawi
2019-03-05 16:50:34 -08:00
parent 0d951bf3db
commit 7760aa56de
2 changed files with 83 additions and 2 deletions

View File

@@ -50,8 +50,10 @@ void swift::changeBranchTarget(TermInst *T, unsigned edgeIdx,
case TermKind::BranchInst: {
auto *BI = cast<BranchInst>(T);
SmallVector<SILValue, 8> args;
for (auto arg : BI->getArgs())
args.push_back(arg);
if (preserveArgs) {
for (auto arg : BI->getArgs())
args.push_back(arg);
}
B.createBranch(T->getLoc(), newDest, args);
BI->dropAllReferences();
BI->eraseFromParent();