diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-01-18 00:10:01 +0000 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-01-18 00:10:01 +0000 |
| commit | 90c4449128ab600d5aef592c063e1044d0c8e330 (patch) | |
| tree | 538d75e667977dc86ba83c8ac25572a7229a4f34 /llvm/lib/Transforms/Scalar | |
| parent | 6435c6ede034361f1e4dfdff5b6584418c27cb51 (diff) | |
| download | bcm5719-llvm-90c4449128ab600d5aef592c063e1044d0c8e330.tar.gz bcm5719-llvm-90c4449128ab600d5aef592c063e1044d0c8e330.zip | |
[opaque pointer types] Alloca: use getAllocatedType() instead of getType()->getPointerElementType().
Reviewers: mjacob
Subscribers: llvm-commits, dblaikie
Differential Revision: http://reviews.llvm.org/D16272
llvm-svn: 258028
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 20 |
2 files changed, 10 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index d77d5745e60..a1c9dc10325 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1777,8 +1777,7 @@ static void relocationViaAlloca( auto InsertClobbersAt = [&](Instruction *IP) { for (auto *AI : ToClobber) { - auto AIType = cast<PointerType>(AI->getType()); - auto PT = cast<PointerType>(AIType->getElementType()); + auto PT = cast<PointerType>(AI->getAllocatedType()); Constant *CPN = ConstantPointerNull::get(PT); StoreInst *Store = new StoreInst(CPN, AI); Store->insertBefore(IP); diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 774538eaa81..c5241ce1356 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -710,7 +710,7 @@ void ConvertToScalarInfo::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, PointerType* SPTy = cast<PointerType>(SrcPtr->getType()); PointerType* AIPTy = cast<PointerType>(NewAI->getType()); if (SPTy->getAddressSpace() != AIPTy->getAddressSpace()) { - AIPTy = PointerType::get(AIPTy->getElementType(), + AIPTy = PointerType::get(NewAI->getAllocatedType(), SPTy->getAddressSpace()); } SrcPtr = Builder.CreateBitCast(SrcPtr, AIPTy); @@ -727,7 +727,7 @@ void ConvertToScalarInfo::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, PointerType* DPTy = cast<PointerType>(MTI->getDest()->getType()); PointerType* AIPTy = cast<PointerType>(NewAI->getType()); if (DPTy->getAddressSpace() != AIPTy->getAddressSpace()) { - AIPTy = PointerType::get(AIPTy->getElementType(), + AIPTy = PointerType::get(NewAI->getAllocatedType(), DPTy->getAddressSpace()); } Value *DstPtr = Builder.CreateBitCast(MTI->getDest(), AIPTy); @@ -1357,7 +1357,7 @@ static bool tryToMakeAllocaBePromotable(AllocaInst *AI, const DataLayout &DL) { continue; } - Type *LoadTy = cast<PointerType>(PN->getType())->getElementType(); + Type *LoadTy = AI->getAllocatedType(); PHINode *NewPN = PHINode::Create(LoadTy, PN->getNumIncomingValues(), PN->getName()+".ld", PN); @@ -2210,8 +2210,7 @@ SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *Inst, // If the pointer is not the right type, insert a bitcast to the right // type. - Type *NewTy = - PointerType::get(AI->getType()->getElementType(), AddrSpace); + Type *NewTy = PointerType::get(AI->getAllocatedType(), AddrSpace); if (OtherPtr->getType() != NewTy) OtherPtr = new BitCastInst(OtherPtr, NewTy, OtherPtr->getName(), MI); @@ -2235,8 +2234,8 @@ SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *Inst, OtherPtr->getName()+"."+Twine(i), MI); uint64_t EltOffset; - PointerType *OtherPtrTy = cast<PointerType>(OtherPtr->getType()); - Type *OtherTy = OtherPtrTy->getElementType(); + assert(AI->getType() == OtherPtr->getType()); + Type *OtherTy = AI->getAllocatedType(); if (StructType *ST = dyn_cast<StructType>(OtherTy)) { EltOffset = DL.getStructLayout(ST)->getElementOffset(i); } else { @@ -2252,8 +2251,8 @@ SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *Inst, OtherEltAlign = (unsigned)MinAlign(OtherEltAlign, EltOffset); } - Value *EltPtr = NewElts[i]; - Type *EltTy = cast<PointerType>(EltPtr->getType())->getElementType(); + AllocaInst *EltPtr = NewElts[i]; + Type *EltTy = EltPtr->getAllocatedType(); // If we got down to a scalar, insert a load or store as appropriate. if (EltTy->isSingleValueType()) { @@ -2485,8 +2484,7 @@ SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocaInst *AI, // Load the value from the alloca. If the NewElt is an aggregate, cast // the pointer to an integer of the same size before doing the load. Value *SrcField = NewElts[i]; - Type *FieldTy = - cast<PointerType>(SrcField->getType())->getElementType(); + Type *FieldTy = NewElts[i]->getAllocatedType(); uint64_t FieldSizeBits = DL.getTypeSizeInBits(FieldTy); // Ignore zero sized fields like {}, they obviously contain no data. |

