[PATCH] D16410: [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:29:52 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL258409: [BlockPlacement] Add option to align all non-fall-through blocks. (authored by gberry).

Changed prior to commit:
  http://reviews.llvm.org/D16410?vs=45539&id=45546#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16410

Files:
  llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp

Index: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
@@ -62,6 +62,13 @@
                                                 "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 @@
     // 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16410.45546.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160121/49f16891/attachment.bin>


More information about the llvm-commits mailing list