forked from OSchip/llvm-project
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:
parent
dc848b5376
commit
546c4e6e84
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue