diff --git a/llvm/lib/CodeGen/BranchRelaxation.cpp b/llvm/lib/CodeGen/BranchRelaxation.cpp --- a/llvm/lib/CodeGen/BranchRelaxation.cpp +++ b/llvm/lib/CodeGen/BranchRelaxation.cpp @@ -132,6 +132,19 @@ assert(BlockInfo[Num].Size == computeBlockSize(MBB)); PrevNum = Num; } + + for (MachineBasicBlock &MBB : *MF) { + for (MachineBasicBlock::iterator J = MBB.getFirstTerminator(); + J != MBB.end(); J = std::next(J)) { + MachineInstr &MI = *J; + if (!MI.isConditionalBranch() && !MI.isUnconditionalBranch()) + continue; + if (MI.getOpcode() == TargetOpcode::FAULTING_OP) + continue; + MachineBasicBlock *DestBB = TII->getBranchDestBlock(MI); + assert(isBlockInRange(MI, *DestBB)); + } + } #endif }