[PATCH] D15648: Add command line options to override target preferred/minimum function/loop alignments.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 11:14:06 PST 2015


mcrosier updated this revision to Diff 43253.
mcrosier added a comment.

Address Geoff's comment.


http://reviews.llvm.org/D15648

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/MachineBlockPlacement.cpp
  lib/CodeGen/TargetLoweringBase.cpp

Index: lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -43,6 +43,14 @@
     cl::desc("Do not create extra branches to split comparison logic."),
     cl::Hidden);
 
+// These two command line options are used to override the min/preferred
+// function/loop alignment.  The value should be specified as log2(bytes).
+static cl::opt<unsigned> MinFA("min-func-alignment", cl::init(0), cl::Hidden,
+                               cl::desc("Override the minimimum function alignment"));
+
+static cl::opt<unsigned> MinLA("min-loop-alignment", cl::init(0), cl::Hidden,
+                               cl::desc("Override the minimimum loop alignment"));
+
 /// InitLibcallNames - Set default libcall names.
 ///
 static void InitLibcallNames(const char **Names, const Triple &TT) {
@@ -749,7 +757,10 @@
   JumpBufAlignment = 0;
   MinFunctionAlignment = 0;
   PrefFunctionAlignment = 0;
+  CLFunctionAlignment = MinFA;
+  MinLoopAlignment = 0;
   PrefLoopAlignment = 0;
+  CLLoopAlignment = MinLA;
   GatherAllAliasesMaxDepth = 6;
   MinStackArgumentAlignment = 1;
   InsertFencesForAtomic = false;
Index: lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- lib/CodeGen/MachineBlockPlacement.cpp
+++ lib/CodeGen/MachineBlockPlacement.cpp
@@ -1330,6 +1330,8 @@
       continue;
 
     unsigned Align = TLI->getPrefLoopAlignment(L);
+    unsigned MinAlign = TLI->getMinLoopAlignment();
+    Align = std::max(Align, MinAlign);
     if (!Align)
       continue; // Don't care about loop alignment.
 
Index: include/llvm/Target/TargetLowering.h
===================================================================
--- include/llvm/Target/TargetLowering.h
+++ include/llvm/Target/TargetLowering.h
@@ -979,14 +979,23 @@
 
   /// Return the minimum function alignment.
   unsigned getMinFunctionAlignment() const {
+    if (CLFunctionAlignment > MinFunctionAlignment)
+      return CLFunctionAlignment;
     return MinFunctionAlignment;
   }
 
   /// Return the preferred function alignment.
   unsigned getPrefFunctionAlignment() const {
     return PrefFunctionAlignment;
   }
 
+  /// Return the minimum loop alignment.
+  unsigned getMinLoopAlignment() const {
+    if (CLLoopAlignment > MinLoopAlignment)
+      return CLLoopAlignment;
+    return MinLoopAlignment;
+  }
+
   /// Return the preferred loop alignment.
   virtual unsigned getPrefLoopAlignment(MachineLoop *ML = nullptr) const {
     return PrefLoopAlignment;
@@ -1842,9 +1851,20 @@
   /// optimizing for speed).
   unsigned PrefFunctionAlignment;
 
+  /// The function alignment as specified on the command line.  This is used
+  /// for debugging and test.
+  unsigned CLFunctionAlignment;
+
+  /// The minimum loop alignment.
+  unsigned MinLoopAlignment;
+
   /// The preferred loop alignment.
   unsigned PrefLoopAlignment;
 
+  /// The loop alignment as specified on the command line.  This is used
+  /// for debugging and test.
+  unsigned CLLoopAlignment;
+
   /// Whether the DAG builder should automatically insert fences and reduce
   /// ordering for atomics.  (This will be set for for most architectures with
   /// weak memory ordering.)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15648.43253.patch
Type: text/x-patch
Size: 3301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151218/93165c02/attachment.bin>


More information about the llvm-commits mailing list