[llvm] r258028 - [opaque pointer types] Alloca: use getAllocatedType() instead of getType()->getPointerElementType().
Eduard Burtescu via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 17 16:10:01 PST 2016
Author: eddyb
Date: Sun Jan 17 18:10:01 2016
New Revision: 258028
URL: http://llvm.org/viewvc/llvm-project?rev=258028&view=rev
Log:
[opaque pointer types] Alloca: use getAllocatedType() instead of getType()->getPointerElementType().
Reviewers: mjacob
Subscribers: llvm-commits, dblaikie
Differential Revision: http://reviews.llvm.org/D16272
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/lib/CodeGen/GCRootLowering.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=258028&r1=258027&r2=258028&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Sun Jan 17 18:10:01 2016
@@ -1342,7 +1342,7 @@ static void computeKnownBitsFromOperator
AllocaInst *AI = cast<AllocaInst>(I);
unsigned Align = AI->getAlignment();
if (Align == 0)
- Align = Q.DL.getABITypeAlignment(AI->getType()->getElementType());
+ Align = Q.DL.getABITypeAlignment(AI->getAllocatedType());
if (Align > 0)
KnownZero = APInt::getLowBitsSet(BitWidth, countTrailingZeros(Align));
Modified: llvm/trunk/lib/CodeGen/GCRootLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCRootLowering.cpp?rev=258028&r1=258027&r2=258028&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GCRootLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/GCRootLowering.cpp Sun Jan 17 18:10:01 2016
@@ -170,8 +170,7 @@ static bool InsertRootInitializers(Funct
for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I)
if (!InitedRoots.count(*I)) {
StoreInst *SI = new StoreInst(
- ConstantPointerNull::get(cast<PointerType>(
- cast<PointerType>((*I)->getType())->getElementType())),
+ ConstantPointerNull::get(cast<PointerType>((*I)->getAllocatedType())),
*I);
SI->insertAfter(*I);
MadeChange = true;
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=258028&r1=258027&r2=258028&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Sun Jan 17 18:10:01 2016
@@ -2568,7 +2568,7 @@ bool Evaluator::EvaluateBlock(BasicBlock
DEBUG(dbgs() << "Found an array alloca. Can not evaluate.\n");
return false; // Cannot handle array allocs.
}
- Type *Ty = AI->getType()->getElementType();
+ Type *Ty = AI->getAllocatedType();
AllocaTmps.push_back(
make_unique<GlobalVariable>(Ty, false, GlobalValue::InternalLinkage,
UndefValue::get(Ty), AI->getName()));
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=258028&r1=258027&r2=258028&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Sun Jan 17 18:10:01 2016
@@ -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);
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=258028&r1=258027&r2=258028&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Sun Jan 17 18:10:01 2016
@@ -710,7 +710,7 @@ void ConvertToScalarInfo::ConvertUsesToS
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::ConvertUsesToS
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(
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(MemIn
// 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(MemIn
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(MemIn
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(LoadI
// 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.
More information about the llvm-commits
mailing list