From 15c82779033826a0958182b746b03a22ad04a16a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 2 Feb 2009 20:44:45 +0000 Subject: [PATCH] inline SROA::ConvertToScalar, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63544 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/ScalarReplAggregates.cpp | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 0765e12876b..012769568d3 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -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