summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorGeoff Berry <gberry@codeaurora.org>2016-01-21 17:25:52 +0000
committerGeoff Berry <gberry@codeaurora.org>2016-01-21 17:25:52 +0000
commit10494aca0538f8b16fb2d6051fa18335e0f1b7ea (patch)
treeec7b95b261a734ff2261f9d8d672f49eeb021f24 /llvm/lib/CodeGen
parent486bace5ccb0021de3acd9d4a804af5f57b31367 (diff)
downloadbcm5719-llvm-10494aca0538f8b16fb2d6051fa18335e0f1b7ea.tar.gz
bcm5719-llvm-10494aca0538f8b16fb2d6051fa18335e0f1b7ea.zip
[BlockPlacement] Add option to align all non-fall-through blocks.
Summary: This option is being added for testing purposes. Reviewers: mcrosier Subscribers: mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D16410 llvm-svn: 258409
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index f5e30564501..ce920a117ae 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -62,6 +62,13 @@ static cl::opt<unsigned> AlignAllBlock("align-all-blocks",
"blocks in the function."),
cl::init(0), cl::Hidden);
+static cl::opt<unsigned> AlignAllNonFallThruBlocks(
+ "align-all-nofallthru-blocks",
+ cl::desc("Force the alignment of all "
+ "blocks that have no fall-through predecessors (i.e. don't add "
+ "nops that are executed)."),
+ cl::init(0), cl::Hidden);
+
static cl::opt<unsigned>
AlignAllLoops("align-all-loops",
cl::desc("Force the alignment of all loops in the function."),
@@ -1405,6 +1412,15 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &F) {
// Align all of the blocks in the function to a specific alignment.
for (MachineBasicBlock &MBB : F)
MBB.setAlignment(AlignAllBlock);
+ else if (AlignAllNonFallThruBlocks) {
+ // Align all of the blocks that have no fall-through predecessors to a
+ // specific alignment.
+ for (auto MBI = std::next(F.begin()), MBE = F.end(); MBI != MBE; ++MBI) {
+ auto LayoutPred = std::prev(MBI);
+ if (!LayoutPred->isSuccessor(&*MBI))
+ MBI->setAlignment(AlignAllNonFallThruBlocks);
+ }
+ }
// We always return true as we have no way to track whether the final order
// differs from the original order.
OpenPOWER on IntegriCloud