inline SROA::ConvertToScalar, no functionality change.
authorChris Lattner <sabre@nondot.org>
Mon, 2 Feb 2009 20:44:45 +0000 (20:44 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 2 Feb 2009 20:44:45 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63544 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ScalarReplAggregates.cpp

index 0765e12876b875f2109c3bf2301ea5a8ad8edc9b..012769568d335701a3a44a31443eb34cb5a06315 100644 (file)
@@ -127,7 +127,6 @@ namespace {
     
     bool CanConvertToScalar(Value *V, bool &IsNotTrivial, const Type *&ResTy,
                             uint64_t Offset);
-    void ConvertToScalar(AllocationInst *AI, const Type *Ty);
     void ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset);
     Value *ConvertUsesOfLoadToScalar(LoadInst *LI, AllocaInst *NewAI, 
                                      uint64_t Offset);
@@ -269,6 +268,8 @@ bool SROA::performScalarRepl(Function &F) {
       Changed = true;
       continue;
     }
+    
+    
 
     // If we can turn this aggregate value (potentially with casts) into a
     // simple scalar value that can be mem2reg'd into a register value.
@@ -277,11 +278,18 @@ bool SROA::performScalarRepl(Function &F) {
     // that we can't just check based on the type: the alloca may be of an i32
     // but that has pointer arithmetic to set byte 3 of it or something.
     bool IsNotTrivial = false;
-    const Type *ActualType = 0;
-    if (CanConvertToScalar(AI, IsNotTrivial, ActualType, 0))
-      if (IsNotTrivial && ActualType &&
-          TD->getTypeSizeInBits(ActualType) < SRThreshold*8) {
-        ConvertToScalar(AI, ActualType);
+    const Type *ActualTy = 0;
+    if (CanConvertToScalar(AI, IsNotTrivial, ActualTy, 0))
+      if (IsNotTrivial && ActualTy &&
+          TD->getTypeSizeInBits(ActualTy) < SRThreshold*8) {
+        DOUT << "CONVERT TO SCALAR: " << *AI << "  TYPE = " << *ActualTy <<"\n";
+        ++NumConverted;
+        
+        // Create and insert the alloca.
+        AllocaInst *NewAI = new AllocaInst(ActualTy, 0, AI->getName(),
+                                           AI->getParent()->begin());
+        ConvertUsesToScalar(AI, NewAI, 0);
+        AI->eraseFromParent();
         Changed = true;
         continue;
       }
@@ -1263,20 +1271,6 @@ bool SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial,
   return true;
 }
 
-/// ConvertToScalar - The specified alloca passes the CanConvertToScalar
-/// predicate and is non-trivial.  Convert it to something that can be trivially
-/// promoted into a register by mem2reg.
-void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) {
-  DOUT << "CONVERT TO SCALAR: " << *AI << "  TYPE = " << *ActualTy << "\n";
-  ++NumConverted;
-  
-  // Create and insert the alloca.
-  AllocaInst *NewAI = new AllocaInst(ActualTy, 0, AI->getName(),
-                                     AI->getParent()->begin());
-  ConvertUsesToScalar(AI, NewAI, 0);
-  AI->eraseFromParent();
-}
-
 
 /// ConvertUsesToScalar - Convert all of the users of Ptr to use the new alloca
 /// directly.  This happens when we are converting an "integer union" to a