[llvm] r248617 - MachineBasicBlock: Factor out common code into isReturnBlock()
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 14:25:19 PDT 2015
Author: matze
Date: Fri Sep 25 16:25:19 2015
New Revision: 248617
URL: http://llvm.org/viewvc/llvm-project?rev=248617&view=rev
Log:
MachineBasicBlock: Factor out common code into isReturnBlock()
Modified:
llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp
llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp
llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
llvm/trunk/lib/Target/Hexagon/HexagonFrameLowering.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp
llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp
llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Fri Sep 25 16:25:19 2015
@@ -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.
///
Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original)
+++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Fri Sep 25 16:25:19 2015
@@ -142,7 +142,7 @@ void AggressiveAntiDepBreaker::StartBloc
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();
Modified: llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp (original)
+++ llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp Fri Sep 25 16:25:19 2015
@@ -52,7 +52,7 @@ void CriticalAntiDepBreaker::StartBlock(
// 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(),
Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Fri Sep 25 16:25:19 2015
@@ -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
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
// 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
for (MachineBasicBlock &MBB : Fn) {
if (MBB.isEHFuncletEntry())
SaveBlocks.push_back(&MBB);
- if (isReturnBlock(&MBB))
+ if (MBB.isReturnBlock())
RestoreBlocks.push_back(&MBB);
}
}
Modified: llvm/trunk/lib/Target/Hexagon/HexagonFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonFrameLowering.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonFrameLowering.cpp Fri Sep 25 16:25:19 2015
@@ -370,11 +370,11 @@ void HexagonFrameLowering::emitPrologue(
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);
}
}
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp Fri Sep 25 16:25:19 2015
@@ -72,7 +72,7 @@ bool NVPTXPrologEpilogPass::runOnMachine
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);
}
Modified: llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp Fri Sep 25 16:25:19 2015
@@ -270,7 +270,7 @@ static void RemoveVRSaveCode(MachineInst
// 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(MachineIn
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) {
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp?rev=248617&r1=248616&r2=248617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Fri Sep 25 16:25:19 2015
@@ -286,7 +286,7 @@ void PPCDAGToDAGISel::InsertVRSaveCode(M
// 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
More information about the llvm-commits
mailing list