Fix PR1446 by not scalarrepl'ing giant structures.
authorChris Lattner <sabre@nondot.org>
Thu, 24 May 2007 18:43:04 +0000 (18:43 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 24 May 2007 18:43:04 +0000 (18:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37326 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ScalarReplAggregates.cpp

index 18e05bb2e3cc9b715017b91b98babd79eca26a65..977f22ebf61f40bb084fec1f621303a3d3d0aacb 100644 (file)
@@ -148,6 +148,8 @@ bool SROA::performScalarRepl(Function &F) {
     if (AllocationInst *A = dyn_cast<AllocationInst>(I))
       WorkList.push_back(A);
 
+  const TargetData &TD = getAnalysis<TargetData>();
+  
   // Process the worklist
   bool Changed = false;
   while (!WorkList.empty()) {
@@ -177,7 +179,9 @@ bool SROA::performScalarRepl(Function &F) {
     // value cannot be decomposed at all.
     if (!AI->isArrayAllocation() &&
         (isa<StructType>(AI->getAllocatedType()) ||
-         isa<ArrayType>(AI->getAllocatedType()))) {
+         isa<ArrayType>(AI->getAllocatedType())) &&
+        AI->getAllocatedType()->isSized() &&
+        TD.getTypeSize(AI->getAllocatedType()) < 128) {
       // Check that all of the users of the allocation are capable of being
       // transformed.
       switch (isSafeAllocaToScalarRepl(AI)) {