diff options
author | Quentin Colombet <qcolombet@apple.com> | 2016-05-02 22:58:59 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2016-05-02 22:58:59 +0000 |
commit | 776e6de51626b01b6e4d062c243e48bcc9446884 (patch) | |
tree | ee315b33525a5506702831b78fd6e1c2572561bd /llvm/lib | |
parent | 4e1d389ac5cf5048d2c4e90caa2de672d7445148 (diff) | |
download | bcm5719-llvm-776e6de51626b01b6e4d062c243e48bcc9446884.tar.gz bcm5719-llvm-776e6de51626b01b6e4d062c243e48bcc9446884.zip |
[MachineBlockPlacement] Let the target optimize the branches at the end.
After the layout of the basic blocks is set, the target may be able to get rid
of unconditional branches to fallthrough blocks that the generic code does not
catch. This happens any time TargetInstrInfo::AnalyzeBranch is not able to
analyze all the branches involved in the terminators sequence, while still
understanding a few of them.
In such situation, AnalyzeBranch can directly modify the branches if it has been
instructed to do so.
This patch takes advantage of that.
llvm-svn: 268328
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index baa9df6c5f1..fb722a166a0 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -1358,6 +1358,19 @@ void MachineBlockPlacement::buildCFGChains(MachineFunction &F) { MachineBasicBlock *TBB = nullptr, *FBB = nullptr; // For AnalyzeBranch. if (!TII->AnalyzeBranch(F.back(), TBB, FBB, Cond)) F.back().updateTerminator(); + + // Now that all the basic blocks in the chain have the proper layout, + // make a final call to AnalyzeBranch with AllowModify set. + // Indeed, the target may be able to optimize the branches in a way we + // cannot because all branches may not be analyzable. + // E.g., the target may be able to remove an unconditional branch to + // a fallthrough when it occurs after predicated terminators. + for (MachineBasicBlock *ChainBB : FunctionChain) { + Cond.clear(); + TBB = nullptr; + FBB = nullptr; // For AnalyzeBranch. + (void)TII->AnalyzeBranch(*ChainBB, TBB, FBB, Cond, /*AllowModify*/ true); + } } void MachineBlockPlacement::alignBlocks(MachineFunction &F) { |