[llvm-commits] [llvm] r38472 - in /llvm/trunk: include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/ScalarReplAggregates.cpp

Devang Patel dpatel at apple.com
Mon Jul 9 14:19:24 PDT 2007


Author: dpatel
Date: Mon Jul  9 16:19:23 2007
New Revision: 38472

URL: http://llvm.org/viewvc/llvm-project?rev=38472&view=rev
Log:
Expose struct size threhold to allow users to tweak their own setting.

Modified:
    llvm/trunk/include/llvm/Transforms/Scalar.h
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp

Modified: llvm/trunk/include/llvm/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=38472&r1=38471&r2=38472&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar.h Mon Jul  9 16:19:23 2007
@@ -76,7 +76,7 @@
 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
 // if possible.
 //
-FunctionPass *createScalarReplAggregatesPass();
+FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
 
 //===----------------------------------------------------------------------===//
 //

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=38472&r1=38471&r2=38472&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Jul  9 16:19:23 2007
@@ -48,7 +48,12 @@
 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 @@
           isMemCpySrc(false), isMemCpyDst(false) {}
     };
     
+    unsigned SRThreshold;
+
     void MarkUnsafe(AllocaInfo &I) { I.isUnsafe = true; }
 
     int isSafeAllocaToScalarRepl(AllocationInst *AI);
@@ -119,7 +126,9 @@
 }
 
 // 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 @@
         (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)) {





More information about the llvm-commits mailing list