[BOLT] Fix SCTC issue with hot-cold split

Summary:
SCTC was deleting an unconditional branch to a block in the
cold area because it was the next block in the layout vector. Fix the
condition to only delete such branches when source and target are in
the same allocation area (either both hot or both cold).

(cherry picked from FBD5570300)
This commit is contained in:
Rafael Auler 2017-08-04 20:14:24 -07:00 committed by Maksim Panchenko
parent e4290d083f
commit b81ff8a8fc
1 changed files with 2 additions and 1 deletions

View File

@ -679,7 +679,8 @@ uint64_t SimplifyConditionalTailCalls::fixTailCalls(BinaryContext &BC,
PredBB->analyzeBranch(TBB, FBB, CondBranch, UncondBranch);
// Only add a new branch if the target is not the fall-through.
if (BF.getBasicBlockAfter(BB, false) != CondSucc || isValid(BB)) {
if (BF.getBasicBlockAfter(BB) != CondSucc || isValid(BB) ||
PredBB->isCold() != CondSucc->isCold()) {
if (UncondBranch) {
MIA->replaceBranchTarget(*UncondBranch,
CondSucc->getLabel(),