Expose struct size threhold to allow users to tweak their own setting.
authorDevang Patel <dpatel@apple.com>
Mon, 9 Jul 2007 21:19:23 +0000 (21:19 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 9 Jul 2007 21:19:23 +0000 (21:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38472 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/Scalar.h
lib/Transforms/Scalar/ScalarReplAggregates.cpp

index a0f51fccb3617e36fc2d5c2234ec3d0d09a2b0cd..948d6b5aaed5d543a8627db20e876a72a990d2d3 100644 (file)
@@ -76,7 +76,7 @@ FunctionPass *createAggressiveDCEPass();
 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
 // if possible.
 //
-FunctionPass *createScalarReplAggregatesPass();
+FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
 
 //===----------------------------------------------------------------------===//
 //
index e31fdd16e1beee0dff1155bcbdb2e0ba94f0cafd..5e7dbc2ff8f5f9e36009ecf3797e01ee593b8b63 100644 (file)
@@ -48,7 +48,12 @@ STATISTIC(NumGlobals,   "Number of allocas copied from constant global");
 namespace {
   struct VISIBILITY_HIDDEN SROA : public FunctionPass {
     static char ID; // Pass identification, replacement for typeid
-    SROA() : FunctionPass((intptr_t)&ID) {}
+    SROA(signed T = -1) : FunctionPass((intptr_t)&ID) {
+      if (T == -1)
+        SRThreshold = 128;
+      else
+        SRThreshold = T;
+    }
 
     bool runOnFunction(Function &F);
 
@@ -87,6 +92,8 @@ namespace {
           isMemCpySrc(false), isMemCpyDst(false) {}
     };
     
+    unsigned SRThreshold;
+
     void MarkUnsafe(AllocaInfo &I) { I.isUnsafe = true; }
 
     int isSafeAllocaToScalarRepl(AllocationInst *AI);
@@ -119,7 +126,9 @@ namespace {
 }
 
 // Public interface to the ScalarReplAggregates pass
-FunctionPass *llvm::createScalarReplAggregatesPass() { return new SROA(); }
+FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) { 
+  return new SROA(Threshold);
+}
 
 
 bool SROA::runOnFunction(Function &F) {
@@ -211,7 +220,7 @@ bool SROA::performScalarRepl(Function &F) {
         (isa<StructType>(AI->getAllocatedType()) ||
          isa<ArrayType>(AI->getAllocatedType())) &&
         AI->getAllocatedType()->isSized() &&
-        TD.getTypeSize(AI->getAllocatedType()) < 128) {
+        TD.getTypeSize(AI->getAllocatedType()) < SRThreshold) {
       // Check that all of the users of the allocation are capable of being
       // transformed.
       switch (isSafeAllocaToScalarRepl(AI)) {