RegionCloner: Split edges from non cond_br terminators to exit blocks

When we clone the exiting block such edges become critical and we don't like
critical non cond_br edges (updating SSA needs to put arguments somewhere and
such).

radar://20114457

Swift SVN r25982
This commit is contained in:
Arnold Schwaighofer
2015-03-11 17:25:16 +00:00
parent b3c0d9a0c9
commit 2106b44704
2 changed files with 62 additions and 0 deletions

View File

@@ -1264,6 +1264,16 @@ public:
for (auto *BB : OutsideBBs)
BBMap[BB] = BB;
// We need to split any edge from a non cond_br basic block leading to a
// exit block. After cloning this edge will become critical if it came from
// inside the cloned region. The SSAUpdater can't handle critical non
// cond_br edges.
for (auto *BB : OutsideBBs)
for (auto *Pred : BB->getPreds())
if (!isa<CondBranchInst>(Pred->getTerminator()) &&
!isa<BranchInst>(Pred->getTerminator()))
splitEdgesFromTo(Pred, BB, &DomTree, nullptr);
// Create the cloned start basic block.
auto *ClonedStartBB = new (Mod) SILBasicBlock(CurFun);
BBMap[StartBB] = ClonedStartBB;