Fix bug in BinaryFunction::fixBranches() in llvm-flo

Summary:
When the ignore-nops patch landed, it exposed a bug in fixBranches()
where it ignored empty BBs. However, we cannot ignore empty BBs when it is
reordered and its fall-through changes. We must update it with a jump to the
original fall-through. This patch fixes this.

(cherry picked from FBD2568244)
This commit is contained in:
Rafael Auler 2015-10-21 16:25:16 -07:00 committed by Maksim Panchenko
parent dc848b5376
commit 546c4e6e84
1 changed files with 1 additions and 3 deletions

View File

@ -858,8 +858,6 @@ void BinaryFunction::fixBranches() {
for (unsigned I = 0, E = BasicBlocksLayout.size(); I != E; ++I) {
BinaryBasicBlock *BB = BasicBlocksLayout[I];
if (BB->begin() == BB->end())
continue;
const MCSymbol *TBB = nullptr;
const MCSymbol *FBB = nullptr;
@ -884,7 +882,7 @@ void BinaryFunction::fixBranches() {
if (CondBranch == nullptr && UncondBranch == nullptr) {
// Case 1a: Last instruction is a return, so it does *not* fall through to
// the next block.
if (MIA->isReturn(BB->back()))
if (!BB->empty() && MIA->isReturn(BB->back()))
continue;
// Case 1b: Layout has changed and the fallthrough is not the same. Need
// to add a new unconditional branch to jump to the old fallthrough.