[sil-simplify-cfg] Fix a bug in CheckedCastBrJumpThreading.

Be more careful when replacing targets of terminators. This finally implements a long-due FIXME in CheckedCastBrJumpThreading.

rdar://20345557.

Swift SVN r26725
This commit is contained in:
Roman Levenstein
2015-03-30 21:10:38 +00:00
parent b519148eb9
commit 71b0e7b4a6
4 changed files with 234 additions and 4 deletions

View File

@@ -375,8 +375,7 @@ void CheckedCastBrJumpThreading::modifyCFGForFailurePreds() {
for (auto *Pred : FailurePreds) {
TermInst *TI = Pred->getTerminator();
// Replace branch to BB by branch to TargetFailureBB.
// FIXME: Why is it valid to assume EdgeIdx=0 here?
changeBranchTarget(TI, 0, TargetFailureBB, /*PreserveArgs=*/true);
replaceBranchTarget(TI, BB, TargetFailureBB, /*PreserveArgs=*/true);
Pred = nullptr;
}
}
@@ -404,8 +403,7 @@ void CheckedCastBrJumpThreading::modifyCFGForSuccessPreds() {
for (auto *Pred : SuccessPreds) {
TermInst *TI = Pred->getTerminator();
// Replace branch to BB by branch to TargetSuccessBB.
// FIXME: Why is it valid to assume EdgeIdx=0 here?
changeBranchTarget(TI, 0, TargetSuccessBB, /*PreserveArgs=*/true);
replaceBranchTarget(TI, BB, TargetFailureBB, /*PreserveArgs=*/true);
SuccessBBArgs.push_back(DomSuccessBB->getBBArg(0));
Pred = nullptr;
}