[llvm] r258409 - [BlockPlacement] Add option to align all non-fall-through blocks.
Geoff Berry via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 21 09:25:52 PST 2016
Author: gberry
Date: Thu Jan 21 11:25:52 2016
New Revision: 258409
URL: http://llvm.org/viewvc/llvm-project?rev=258409&view=rev
Log:
[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
Modified:
llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=258409&r1=258408&r2=258409&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Thu Jan 21 11:25:52 2016
@@ -62,6 +62,13 @@ static cl::opt<unsigned> AlignAllBlock("
"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::runOnMachine
// 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.
More information about the llvm-commits
mailing list