SROA: Simplify code. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166375 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2012-10-20 12:04:57 +00:00
parent 82a1833865
commit 2a13242b20

View File

@ -2888,10 +2888,7 @@ private:
Value *NewPtr = getAdjustedAllocaPtr(PtrBuilder, OldPtr->getType()); Value *NewPtr = getAdjustedAllocaPtr(PtrBuilder, OldPtr->getType());
// Replace the operands which were using the old pointer. // Replace the operands which were using the old pointer.
User::op_iterator OI = PN.op_begin(), OE = PN.op_end(); std::replace(PN.op_begin(), PN.op_end(), cast<Value>(OldPtr), NewPtr);
for (; OI != OE; ++OI)
if (*OI == OldPtr)
*OI = NewPtr;
DEBUG(dbgs() << " to: " << PN << "\n"); DEBUG(dbgs() << " to: " << PN << "\n");
deleteIfTriviallyDead(OldPtr); deleteIfTriviallyDead(OldPtr);
@ -3261,11 +3258,7 @@ static Type *getTypePartition(const DataLayout &TD, Type *Ty,
} }
// Try to build up a sub-structure. // Try to build up a sub-structure.
SmallVector<Type *, 4> ElementTys; StructType *SubTy = StructType::get(STy->getContext(), makeArrayRef(EI, EE),
do {
ElementTys.push_back(*EI++);
} while (EI != EE);
StructType *SubTy = StructType::get(STy->getContext(), ElementTys,
STy->isPacked()); STy->isPacked());
const StructLayout *SubSL = TD.getStructLayout(SubTy); const StructLayout *SubSL = TD.getStructLayout(SubTy);
if (Size != SubSL->getSizeInBytes()) if (Size != SubSL->getSizeInBytes())