Skip to content

Commit

Permalink
[MBP] Split placement and alignment into two functions. NFC.
Browse files Browse the repository at this point in the history
Cut and Paste.

llvm-svn: 268067
  • Loading branch information
Haicheng Wu committed Apr 29, 2016
1 parent 38e496b commit e749ce5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/CodeGen/MachineBlockPlacement.cpp
Expand Up @@ -300,6 +300,7 @@ class MachineBlockPlacement : public MachineFunctionPass {
void rotateLoopWithProfile(BlockChain &LoopChain, MachineLoop &L,
const BlockFilterSet &LoopBlockSet);
void buildCFGChains(MachineFunction &F);
void alignBlocks(MachineFunction &F);

public:
static char ID; // Pass identification, replacement for typeid
Expand Down Expand Up @@ -1357,7 +1358,9 @@ void MachineBlockPlacement::buildCFGChains(MachineFunction &F) {
MachineBasicBlock *TBB = nullptr, *FBB = nullptr; // For AnalyzeBranch.
if (!TII->AnalyzeBranch(F.back(), TBB, FBB, Cond))
F.back().updateTerminator();
}

void MachineBlockPlacement::alignBlocks(MachineFunction &F) {
// Walk through the backedges of the function now that we have fully laid out
// the basic blocks and align the destination of each backedge. We don't rely
// exclusively on the loop info here so that we can align backedges in
Expand All @@ -1366,6 +1369,7 @@ void MachineBlockPlacement::buildCFGChains(MachineFunction &F) {
// FIXME: Use Function::optForSize().
if (F.getFunction()->hasFnAttribute(Attribute::OptimizeForSize))
return;
BlockChain &FunctionChain = *BlockToChain[&F.front()];
if (FunctionChain.begin() == FunctionChain.end())
return; // Empty chain.

Expand Down Expand Up @@ -1442,6 +1446,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &F) {
assert(BlockToChain.empty());

buildCFGChains(F);
alignBlocks(F);

BlockToChain.clear();
ChainAllocator.DestroyAll();
Expand Down

0 comments on commit e749ce5

Please sign in to comment.