Add command line options to force function/loop alignments.
authorChad Rosier <mcrosier@codeaurora.org>
Tue, 29 Dec 2015 18:18:07 +0000 (18:18 +0000)
committerChad Rosier <mcrosier@codeaurora.org>
Tue, 29 Dec 2015 18:18:07 +0000 (18:18 +0000)
These are being added for testing purposes.
http://reviews.llvm.org/D15648

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256571 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineBlockPlacement.cpp
lib/CodeGen/MachineFunction.cpp

index fcddf346cf680cf2221e730a86f3b047425161d7..f5e3056450116514c2960b7c7794a248257bef1b 100644 (file)
@@ -62,6 +62,11 @@ static cl::opt<unsigned> AlignAllBlock("align-all-blocks",
                                                 "blocks in the function."),
                                        cl::init(0), cl::Hidden);
 
                                                 "blocks in the function."),
                                        cl::init(0), cl::Hidden);
 
+static cl::opt<unsigned>
+    AlignAllLoops("align-all-loops",
+                  cl::desc("Force the alignment of all loops in the function."),
+                  cl::init(0), cl::Hidden);
+
 // FIXME: Find a good default for this flag and remove the flag.
 static cl::opt<unsigned> ExitBlockBias(
     "block-placement-exit-block-bias",
 // FIXME: Find a good default for this flag and remove the flag.
 static cl::opt<unsigned> ExitBlockBias(
     "block-placement-exit-block-bias",
@@ -1329,6 +1334,11 @@ void MachineBlockPlacement::buildCFGChains(MachineFunction &F) {
     if (!L)
       continue;
 
     if (!L)
       continue;
 
+    if (AlignAllLoops) {
+      ChainBB->setAlignment(AlignAllLoops);
+      continue;
+    }
+
     unsigned Align = TLI->getPrefLoopAlignment(L);
     if (!Align)
       continue; // Don't care about loop alignment.
     unsigned Align = TLI->getPrefLoopAlignment(L);
     if (!Align)
       continue; // Don't care about loop alignment.
index 80d30a5b131ad217908b88e436f68f6491534c13..ca4bb1c6ad493bb2134217a7be66679f1e21723b 100644 (file)
@@ -47,6 +47,11 @@ using namespace llvm;
 
 #define DEBUG_TYPE "codegen"
 
 
 #define DEBUG_TYPE "codegen"
 
+static cl::opt<unsigned>
+    AlignAllFunctions("align-all-functions",
+                      cl::desc("Force the alignment of all functions."),
+                      cl::init(0), cl::Hidden);
+
 void MachineFunctionInitializer::anchor() {}
 
 //===----------------------------------------------------------------------===//
 void MachineFunctionInitializer::anchor() {}
 
 //===----------------------------------------------------------------------===//
@@ -87,6 +92,9 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
     Alignment = std::max(Alignment,
                          STI->getTargetLowering()->getPrefFunctionAlignment());
 
     Alignment = std::max(Alignment,
                          STI->getTargetLowering()->getPrefFunctionAlignment());
 
+  if (AlignAllFunctions)
+    Alignment = AlignAllFunctions;
+
   FunctionNumber = FunctionNum;
   JumpTableInfo = nullptr;
 
   FunctionNumber = FunctionNum;
   JumpTableInfo = nullptr;