Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -1342,7 +1342,7 @@ AllocaInst *AI = cast(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)); Index: lib/Analysis/VectorUtils.cpp =================================================================== --- lib/Analysis/VectorUtils.cpp +++ lib/Analysis/VectorUtils.cpp @@ -318,8 +318,6 @@ // Strip off the size of access multiplication if we are still analyzing the // pointer. if (OrigPtr == Ptr) { - const DataLayout &DL = Lp->getHeader()->getModule()->getDataLayout(); - DL.getTypeAllocSize(PtrTy->getElementType()); if (const SCEVMulExpr *M = dyn_cast(V)) { if (M->getOperand(0)->getSCEVType() != scConstant) return nullptr; Index: lib/CodeGen/GCRootLowering.cpp =================================================================== --- lib/CodeGen/GCRootLowering.cpp +++ lib/CodeGen/GCRootLowering.cpp @@ -170,8 +170,7 @@ for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I) if (!InitedRoots.count(*I)) { StoreInst *SI = new StoreInst( - ConstantPointerNull::get(cast( - cast((*I)->getType())->getElementType())), + ConstantPointerNull::get(cast((*I)->getAllocatedType())), *I); SI->insertAfter(*I); MadeChange = true; Index: lib/CodeGen/SelectionDAG/FastISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/FastISel.cpp +++ lib/CodeGen/SelectionDAG/FastISel.cpp @@ -880,9 +880,8 @@ unsigned NumArgs) { ImmutableCallSite CS(CI); - PointerType *PT = cast(CS.getCalledValue()->getType()); - FunctionType *FTy = cast(PT->getElementType()); - Type *RetTy = FTy->getReturnType(); + FunctionType *FTy = CS.getFunctionType(); + Type *RetTy = CS.getType(); ArgListTy Args; Args.reserve(NumArgs); @@ -1010,9 +1009,8 @@ bool FastISel::lowerCall(const CallInst *CI) { ImmutableCallSite CS(CI); - PointerType *PT = cast(CS.getCalledValue()->getType()); - FunctionType *FuncTy = cast(PT->getElementType()); - Type *RetTy = FuncTy->getReturnType(); + FunctionType *FuncTy = CS.getFunctionType(); + Type *RetTy = CS.getType(); ArgListTy Args; ArgListEntry Entry; Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -5383,9 +5383,8 @@ void SelectionDAGBuilder::LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool isTailCall, const BasicBlock *EHPadBB) { - PointerType *PT = cast(CS.getCalledValue()->getType()); - FunctionType *FTy = cast(PT->getElementType()); - Type *RetTy = FTy->getReturnType(); + FunctionType *FTy = CS.getFunctionType(); + Type *RetTy = CS.getType(); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Index: lib/Target/ARM/ARMFastISel.cpp =================================================================== --- lib/Target/ARM/ARMFastISel.cpp +++ lib/Target/ARM/ARMFastISel.cpp @@ -2295,8 +2295,7 @@ // TODO: Avoid some calling conventions? - PointerType *PT = cast(CS.getCalledValue()->getType()); - FunctionType *FTy = cast(PT->getElementType()); + FunctionType *FTy = CS.getFunctionType(); bool isVarArg = FTy->isVarArg(); // Handle *simple* calls for now. Index: lib/Target/Mips/Mips16HardFloat.cpp =================================================================== --- lib/Target/Mips/Mips16HardFloat.cpp +++ lib/Target/Mips/Mips16HardFloat.cpp @@ -427,15 +427,9 @@ Value *F = (M->getOrInsertFunction(Name, A, MyVoid, T, nullptr)); CallInst::Create(F, Params, "", &Inst ); } else if (const CallInst *CI = dyn_cast(I)) { - const Value* V = CI->getCalledValue(); - Type* T = nullptr; - if (V) T = V->getType(); - PointerType *PFT = nullptr; - if (T) PFT = dyn_cast(T); - FunctionType *FT = nullptr; - if (PFT) FT = dyn_cast(PFT->getElementType()); + FunctionType *FT = CI->getFunctionType(); Function *F_ = CI->getCalledFunction(); - if (FT && needsFPReturnHelper(*FT) && + if (needsFPReturnHelper(*FT) && !(F_ && isIntrinsicInline(F_))) { Modified=true; F.addFnAttr("saveS2"); Index: lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- lib/Transforms/IPO/GlobalOpt.cpp +++ lib/Transforms/IPO/GlobalOpt.cpp @@ -2568,7 +2568,7 @@ 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(Ty, false, GlobalValue::InternalLinkage, UndefValue::get(Ty), AI->getName())); Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp =================================================================== --- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1777,8 +1777,7 @@ auto InsertClobbersAt = [&](Instruction *IP) { for (auto *AI : ToClobber) { - auto AIType = cast(AI->getType()); - auto PT = cast(AIType->getElementType()); + auto PT = cast(AI->getAllocatedType()); Constant *CPN = ConstantPointerNull::get(PT); StoreInst *Store = new StoreInst(CPN, AI); Store->insertBefore(IP); Index: lib/Transforms/Scalar/ScalarReplAggregates.cpp =================================================================== --- lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -710,7 +710,7 @@ PointerType* SPTy = cast(SrcPtr->getType()); PointerType* AIPTy = cast(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 @@ PointerType* DPTy = cast(MTI->getDest()->getType()); PointerType* AIPTy = cast(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); @@ -1366,7 +1366,7 @@ continue; } - Type *LoadTy = cast(PN->getType())->getElementType(); + Type *LoadTy = AI->getAllocatedType(); PHINode *NewPN = PHINode::Create(LoadTy, PN->getNumIncomingValues(), PN->getName()+".ld", PN); @@ -2219,8 +2219,7 @@ // 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); @@ -2244,8 +2243,7 @@ OtherPtr->getName()+"."+Twine(i), MI); uint64_t EltOffset; - PointerType *OtherPtrTy = cast(OtherPtr->getType()); - Type *OtherTy = OtherPtrTy->getElementType(); + Type *OtherTy = AI->getAllocatedType(); if (StructType *ST = dyn_cast(OtherTy)) { EltOffset = DL.getStructLayout(ST)->getElementOffset(i); } else { @@ -2262,7 +2260,7 @@ } Value *EltPtr = NewElts[i]; - Type *EltTy = cast(EltPtr->getType())->getElementType(); + Type *EltTy = NewElts[i]->getAllocatedType(); // If we got down to a scalar, insert a load or store as appropriate. if (EltTy->isSingleValueType()) { @@ -2494,8 +2492,7 @@ // 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(SrcField->getType())->getElementType(); + Type *FieldTy = NewElts[i]->getAllocatedType(); uint64_t FieldSizeBits = DL.getTypeSizeInBits(FieldTy); // Ignore zero sized fields like {}, they obviously contain no data.