forked from OSchip/llvm-project
MachineBasicBlock: Factor out common code into isReturnBlock()
llvm-svn: 248617
This commit is contained in:
parent
8d0b734e71
commit
c2d4befb54
|
@ -496,6 +496,12 @@ public:
|
|||
return const_cast<MachineBasicBlock *>(this)->getLastNonDebugInstr();
|
||||
}
|
||||
|
||||
/// Convenience function that returns true if the block has no successors and
|
||||
/// contains a return instruction.
|
||||
bool isReturnBlock() const {
|
||||
return !empty() && back().isReturn();
|
||||
}
|
||||
|
||||
/// Split the critical edge from this block to the given successor block, and
|
||||
/// return the newly created block, or null if splitting is not possible.
|
||||
///
|
||||
|
|
|
@ -142,7 +142,7 @@ void AggressiveAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
|
|||
assert(!State);
|
||||
State = new AggressiveAntiDepState(TRI->getNumRegs(), BB);
|
||||
|
||||
bool IsReturnBlock = (!BB->empty() && BB->back().isReturn());
|
||||
bool IsReturnBlock = BB->isReturnBlock();
|
||||
std::vector<unsigned> &KillIndices = State->GetKillIndices();
|
||||
std::vector<unsigned> &DefIndices = State->GetDefIndices();
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ void CriticalAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
|
|||
// Clear "do not change" set.
|
||||
KeepRegs.reset();
|
||||
|
||||
bool IsReturnBlock = (BBSize != 0 && BB->back().isReturn());
|
||||
bool IsReturnBlock = BB->isReturnBlock();
|
||||
|
||||
// Examine the live-in regs of all successors.
|
||||
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
|
||||
|
|
|
@ -92,9 +92,6 @@ private:
|
|||
int &SPAdj);
|
||||
void scavengeFrameVirtualRegs(MachineFunction &Fn);
|
||||
void insertPrologEpilogCode(MachineFunction &Fn);
|
||||
|
||||
// Convenience for recognizing return blocks.
|
||||
bool isReturnBlock(const MachineBasicBlock *MBB) const;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
@ -129,10 +126,6 @@ void PEI::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||
MachineFunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
bool PEI::isReturnBlock(const MachineBasicBlock* MBB) const {
|
||||
return (MBB && !MBB->empty() && MBB->back().isReturn());
|
||||
}
|
||||
|
||||
/// Compute the set of return blocks
|
||||
void PEI::calculateSets(MachineFunction &Fn) {
|
||||
const MachineFrameInfo *MFI = Fn.getFrameInfo();
|
||||
|
@ -149,7 +142,7 @@ void PEI::calculateSets(MachineFunction &Fn) {
|
|||
// If RestoreBlock does not have any successor and is not a return block
|
||||
// then the end point is unreachable and we do not need to insert any
|
||||
// epilogue.
|
||||
if (!RestoreBlock->succ_empty() || isReturnBlock(RestoreBlock))
|
||||
if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
|
||||
RestoreBlocks.push_back(RestoreBlock);
|
||||
return;
|
||||
}
|
||||
|
@ -159,7 +152,7 @@ void PEI::calculateSets(MachineFunction &Fn) {
|
|||
for (MachineBasicBlock &MBB : Fn) {
|
||||
if (MBB.isEHFuncletEntry())
|
||||
SaveBlocks.push_back(&MBB);
|
||||
if (isReturnBlock(&MBB))
|
||||
if (MBB.isReturnBlock())
|
||||
RestoreBlocks.push_back(&MBB);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,11 +370,11 @@ void HexagonFrameLowering::emitPrologue(MachineFunction &MF,
|
|||
insertEpilogueInBlock(*EpilogB);
|
||||
} else {
|
||||
for (auto &B : MF)
|
||||
if (!B.empty() && B.back().isReturn())
|
||||
if (B.isReturnBlock())
|
||||
insertCSRRestoresInBlock(B, CSI, HRI);
|
||||
|
||||
for (auto &B : MF)
|
||||
if (!B.empty() && B.back().isReturn())
|
||||
if (B.isReturnBlock())
|
||||
insertEpilogueInBlock(B);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ bool NVPTXPrologEpilogPass::runOnMachineFunction(MachineFunction &MF) {
|
|||
|
||||
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
|
||||
// If last instruction is a return instruction, add an epilogue
|
||||
if (!I->empty() && I->back().isReturn())
|
||||
if (I->isReturnBlock())
|
||||
TFI.emitEpilogue(MF, *I);
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ static void RemoveVRSaveCode(MachineInstr *MI) {
|
|||
// epilog blocks.
|
||||
for (MachineFunction::iterator I = MF->begin(), E = MF->end(); I != E; ++I) {
|
||||
// If last instruction is a return instruction, add an epilogue
|
||||
if (!I->empty() && I->back().isReturn()) {
|
||||
if (I->isReturnBlock()) {
|
||||
bool FoundIt = false;
|
||||
for (MBBI = I->end(); MBBI != I->begin(); ) {
|
||||
--MBBI;
|
||||
|
@ -326,7 +326,7 @@ static void HandleVRSaveUpdate(MachineInstr *MI, const TargetInstrInfo &TII) {
|
|||
for (MachineFunction::const_iterator BI = MF->begin(), BE = MF->end();
|
||||
UsedRegMask != 0 && BI != BE; ++BI) {
|
||||
const MachineBasicBlock &MBB = *BI;
|
||||
if (MBB.empty() || !MBB.back().isReturn())
|
||||
if (!MBB.isReturnBlock())
|
||||
continue;
|
||||
const MachineInstr &Ret = MBB.back();
|
||||
for (unsigned I = 0, E = Ret.getNumOperands(); I != E; ++I) {
|
||||
|
|
|
@ -286,7 +286,7 @@ void PPCDAGToDAGISel::InsertVRSaveCode(MachineFunction &Fn) {
|
|||
|
||||
// Find all return blocks, outputting a restore in each epilog.
|
||||
for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
|
||||
if (!BB->empty() && BB->back().isReturn()) {
|
||||
if (BB->isReturnBlock()) {
|
||||
IP = BB->end(); --IP;
|
||||
|
||||
// Skip over all terminator instructions, which are part of the return
|
||||
|
|
Loading…
Reference in New Issue