}
// Create the temporary.
- Address temp = CGF.CreateTempAlloca(destType->getElementType(),
- CGF.getPointerAlign(),
- "icr.temp");
+ Address temp = CGF.CreateTempAlloca(destType->getPointerElementType(),
+ CGF.getPointerAlign(), "icr.temp");
// Loading an l-value can introduce a cleanup if the l-value is __weak,
// and that cleanup will be conditional if we can't prove that the l-value
// isn't null, so we need to register a dominating point so that the cleanups
// Zero-initialize it if we're not doing a copy-initialization.
bool shouldCopy = CRE->shouldCopy();
if (!shouldCopy) {
- llvm::Value *null =
- llvm::ConstantPointerNull::get(
- cast<llvm::PointerType>(destType->getElementType()));
+ llvm::Value *null = llvm::ConstantPointerNull::get(
+ cast<llvm::PointerType>(destType->getPointerElementType()));
CGF.Builder.CreateStore(null, temp);
}
assert(srcRV.isScalar());
llvm::Value *src = srcRV.getScalarVal();
- src = CGF.Builder.CreateBitCast(src, destType->getElementType(),
+ src = CGF.Builder.CreateBitCast(src, destType->getPointerElementType(),
"icr.cast");
// Use an ordinary store, not a store-to-lvalue.
#ifndef NDEBUG
// Assert that these structs have equivalent element types.
llvm::StructType *FullTy = CallInfo.getArgStruct();
- llvm::StructType *DeclaredTy = cast<llvm::StructType>(
- cast<llvm::PointerType>(LastParamTy)->getElementType());
+ llvm::StructType *DeclaredTy =
+ cast<llvm::StructType>(LastParamTy->getPointerElementType());
assert(DeclaredTy->getNumElements() == FullTy->getNumElements());
for (llvm::StructType::element_iterator DI = DeclaredTy->element_begin(),
DE = DeclaredTy->element_end(),
SanitizerHandler::CFICheckFail, {}, {});
}
- return Builder.CreateBitCast(
- Builder.CreateExtractValue(CheckedLoad, 0),
- cast<llvm::PointerType>(VTable->getType())->getElementType());
+ return Builder.CreateBitCast(Builder.CreateExtractValue(CheckedLoad, 0),
+ VTable->getType()->getPointerElementType());
}
void CodeGenFunction::EmitForwardingCallToLambda(
}
}
if (!SelValue) {
- SelValue = llvm::GlobalAlias::create(
- SelectorTy->getElementType(), 0, llvm::GlobalValue::PrivateLinkage,
- ".objc_selector_" + Sel.getAsString(), &TheModule);
+ SelValue = llvm::GlobalAlias::create(SelectorTy->getPointerElementType(), 0,
+ llvm::GlobalValue::PrivateLinkage,
+ ".objc_selector_" + Sel.getAsString(),
+ &TheModule);
Types.emplace_back(TypeEncoding, SelValue);
}
if (IsClassMessage) {
if (!MetaClassPtrAlias) {
MetaClassPtrAlias = llvm::GlobalAlias::create(
- IdTy->getElementType(), 0, llvm::GlobalValue::InternalLinkage,
+ IdTy->getPointerElementType(), 0,
+ llvm::GlobalValue::InternalLinkage,
".objc_metaclass_ref" + Class->getNameAsString(), &TheModule);
}
ReceiverClass = MetaClassPtrAlias;
} else {
if (!ClassPtrAlias) {
ClassPtrAlias = llvm::GlobalAlias::create(
- IdTy->getElementType(), 0, llvm::GlobalValue::InternalLinkage,
+ IdTy->getPointerElementType(), 0,
+ llvm::GlobalValue::InternalLinkage,
".objc_class_ref" + Class->getNameAsString(), &TheModule);
}
ReceiverClass = ClassPtrAlias;
GenerateProtocolHolderCategory();
llvm::StructType *selStructTy =
- dyn_cast<llvm::StructType>(SelectorTy->getElementType());
+ dyn_cast<llvm::StructType>(SelectorTy->getPointerElementType());
llvm::Type *selStructPtrTy = SelectorTy;
if (!selStructTy) {
selStructTy = llvm::StructType::get(CGM.getLLVMContext(),
}
llvm::Value *Size;
llvm::Value *SizeInChars;
- auto *ElemType =
- cast<llvm::PointerType>(OrigAddresses[N].first.getPointer(CGF)->getType())
- ->getElementType();
+ auto *ElemType = OrigAddresses[N]
+ .first.getPointer(CGF)
+ ->getType()
+ ->getPointerElementType();
auto *ElemSizeOf = llvm::ConstantExpr::getSizeOf(ElemType);
if (AsArraySection) {
Size = CGF.Builder.CreatePtrDiff(OrigAddresses[N].second.getPointer(CGF),
// pad. The best solution is to fix the personality function.
} else {
// Pull the pointer for the reference type off.
- llvm::Type *PtrTy =
- cast<llvm::PointerType>(LLVMCatchTy)->getElementType();
+ llvm::Type *PtrTy = LLVMCatchTy->getPointerElementType();
// Create the temporary and write the adjusted pointer into it.
Address ExnPtrTmp =
unsigned ToAS) const {
// Single value types.
if (Ty->isPointerTy() && Ty->getPointerAddressSpace() == FromAS)
- return llvm::PointerType::get(
- cast<llvm::PointerType>(Ty)->getElementType(), ToAS);
+ return llvm::PointerType::get(Ty->getPointerElementType(), ToAS);
return Ty;
}
return llvm::ConstantPointerNull::get(PT);
auto &Ctx = CGM.getContext();
- auto NPT = llvm::PointerType::get(PT->getElementType(),
+ auto NPT = llvm::PointerType::get(PT->getPointerElementType(),
Ctx.getTargetAddressSpace(LangAS::opencl_generic));
return llvm::ConstantExpr::getAddrSpaceCast(
llvm::ConstantPointerNull::get(NPT), PT);
auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);
if (LTy->isPointerTy() && LTy->getPointerAddressSpace() == DefaultAS) {
- LTy = llvm::PointerType::get(
- cast<llvm::PointerType>(LTy)->getElementType(), GlobalAS);
+ LTy = llvm::PointerType::get(LTy->getPointerElementType(), GlobalAS);
return ABIArgInfo::getDirect(LTy, 0, nullptr, false);
}
}
return false;
if (const auto *PtrT = dyn_cast<PointerType>(V->getType()))
- return PtrT->getElementType()->isSized();
+ return PtrT->getPointerElementType()->isSized();
return false;
};
auto Make = [](ArrayRef<Value *>, ArrayRef<Type *> Ts) {
// Deal with the pointer
PointerType *PtrTy = cast<PointerType>(DataPtr->getType());
- Type *EltTy = PtrTy->getElementType();
+ Type *EltTy = PtrTy->getPointerElementType();
auto *RetType = FixedVectorType::get(EltTy, Rows * Columns);
/// statepoint.
Type *getActualReturnType() const {
auto *CalleeTy =
- cast<PointerType>(getActualCalledOperand()->getType())->getElementType();
+ getActualCalledOperand()->getType()->getPointerElementType();
return cast<FunctionType>(CalleeTy)->getReturnType();
}
for (SetVector<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end();
I1 != E; ++I1) {
auto I1Size = LocationSize::afterPointer();
- Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
+ Type *I1ElTy = (*I1)->getType()->getPointerElementType();
if (I1ElTy->isSized())
I1Size = LocationSize::precise(DL.getTypeStoreSize(I1ElTy));
for (SetVector<Value *>::iterator I2 = Pointers.begin(); I2 != I1; ++I2) {
auto I2Size = LocationSize::afterPointer();
- Type *I2ElTy = cast<PointerType>((*I2)->getType())->getElementType();
+ Type *I2ElTy = (*I2)->getType()->getPointerElementType();
if (I2ElTy->isSized())
I2Size = LocationSize::precise(DL.getTypeStoreSize(I2ElTy));
for (CallBase *Call : Calls) {
for (auto Pointer : Pointers) {
auto Size = LocationSize::afterPointer();
- Type *ElTy = cast<PointerType>(Pointer->getType())->getElementType();
+ Type *ElTy = Pointer->getType()->getPointerElementType();
if (ElTy->isSized())
Size = LocationSize::precise(DL.getTypeStoreSize(ElTy));
if (auto *GV = dyn_cast<GlobalValue>(Ptr))
SrcElemTy = GV->getValueType();
else if (!PTy->isOpaque())
- SrcElemTy = PTy->getElementType();
+ SrcElemTy = PTy->getNonOpaquePointerElementType();
else
SrcElemTy = Type::getInt8Ty(Ptr->getContext());
// Always use i8 element type for opaque pointer inductions.
PointerType *PtrTy = cast<PointerType>(PhiTy);
- Type *ElementType = PtrTy->isOpaque() ? Type::getInt8Ty(PtrTy->getContext())
- : PtrTy->getElementType();
+ Type *ElementType = PtrTy->isOpaque()
+ ? Type::getInt8Ty(PtrTy->getContext())
+ : PtrTy->getNonOpaquePointerElementType();
if (!ElementType->isSized())
return false;
continue;
// Also make sure step was increased the same with sizeof allocated
// element type.
- const PointerType *GEPT = dyn_cast<PointerType>(GEP->getType());
- if (Ty->getElementType() != GEPT->getElementType())
+ if (Ty->getElementType() != GEP->getType()->getPointerElementType())
continue;
// FIXME: Since gep indices are silently zext to the indexing type,
ExplicitTypeLoc,
typeComparisonErrorMessage(
"explicit pointee type doesn't match operand's pointee type", Ty,
- PTy->getElementType()));
+ PTy->getNonOpaquePointerElementType()));
}
- if (!IsAlias && !PTy->getElementType()->isFunctionTy()) {
+ if (!IsAlias && !PTy->getPointerElementType()->isFunctionTy()) {
return error(ExplicitTypeLoc,
"explicit pointee type should be a function type");
}
ExplicitTypeLoc,
typeComparisonErrorMessage(
"explicit pointee type doesn't match operand's pointee type",
- Ty, BasePointerType->getElementType()));
+ Ty, BasePointerType->getNonOpaquePointerElementType()));
}
unsigned GEPWidth =
ExplicitTypeLoc,
typeComparisonErrorMessage(
"explicit pointee type doesn't match operand's pointee type", Ty,
- cast<PointerType>(Val->getType())->getElementType()));
+ Val->getType()->getNonOpaquePointerElementType()));
}
SmallPtrSet<Type *, 4> Visited;
if (!Alignment && !Ty->isSized(&Visited))
ExplicitTypeLoc,
typeComparisonErrorMessage(
"explicit pointee type doesn't match operand's pointee type", Ty,
- BasePointerType->getElementType()));
+ BasePointerType->getNonOpaquePointerElementType()));
}
SmallVector<Value*, 16> Indices;
PointerType *OrigPtrTy = cast<PointerType>(Elt0FullTy->getScalarType());
if (!PointeeType)
- PointeeType = OrigPtrTy->getElementType();
+ PointeeType = OrigPtrTy->getPointerElementType();
else if (!OrigPtrTy->isOpaqueOrPointeeTypeMatches(PointeeType))
return error("Explicit gep operator type does not match pointee type "
"of pointer operand");
ConstrStr += (char)Record[3+AsmStrSize+i];
UpgradeInlineAsmString(&AsmStr);
// FIXME: support upgrading in opaque pointers mode.
- V = InlineAsm::get(
- cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),
- AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
+ V = InlineAsm::get(cast<FunctionType>(CurTy->getPointerElementType()),
+ AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
break;
}
// This version adds support for the asm dialect keywords (e.g.,
ConstrStr += (char)Record[3+AsmStrSize+i];
UpgradeInlineAsmString(&AsmStr);
// FIXME: support upgrading in opaque pointers mode.
- V = InlineAsm::get(
- cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),
- AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
- InlineAsm::AsmDialect(AsmDialect));
+ V = InlineAsm::get(cast<FunctionType>(CurTy->getPointerElementType()),
+ AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
+ InlineAsm::AsmDialect(AsmDialect));
break;
}
// This version adds support for the unwind keyword.
ConstrStr += (char)Record[OpNum + AsmStrSize + i];
UpgradeInlineAsmString(&AsmStr);
// FIXME: support upgrading in opaque pointers mode.
- V = InlineAsm::get(
- cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),
- AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
- InlineAsm::AsmDialect(AsmDialect), CanThrow);
+ V = InlineAsm::get(cast<FunctionType>(CurTy->getPointerElementType()),
+ AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
+ InlineAsm::AsmDialect(AsmDialect), CanThrow);
break;
}
// This version adds explicit function type.
if (!Ty->isPointerTy())
return error("Invalid type for value");
AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
- Ty = cast<PointerType>(Ty)->getElementType();
+ Ty = Ty->getPointerElementType();
}
uint64_t RawLinkage = Record[3];
if (!FTy)
return error("Invalid record");
if (auto *PTy = dyn_cast<PointerType>(FTy))
- FTy = PTy->getElementType();
+ FTy = PTy->getPointerElementType();
if (!isa<FunctionType>(FTy))
return error("Invalid type for value");
Func->removeParamAttr(i, Kind);
Type *PTy = cast<FunctionType>(FTy)->getParamType(i);
- Type *PtrEltTy = cast<PointerType>(PTy)->getElementType();
+ Type *PtrEltTy = PTy->getPointerElementType();
Attribute NewAttr;
switch (Kind) {
case Attribute::ByVal:
auto *PTy = dyn_cast<PointerType>(Ty);
if (!PTy)
return error("Invalid type for value");
- Ty = PTy->getElementType();
+ Ty = PTy->getPointerElementType();
AddrSpace = PTy->getAddressSpace();
} else {
AddrSpace = Record[OpNum++];
CB->removeParamAttr(i, Kind);
- Type *PtrEltTy = cast<PointerType>(ArgsTys[i])->getElementType();
+ Type *PtrEltTy = ArgsTys[i]->getPointerElementType();
Attribute NewAttr;
switch (Kind) {
case Attribute::ByVal:
case Intrinsic::preserve_array_access_index:
case Intrinsic::preserve_struct_access_index:
if (!CB->getAttributes().getParamElementType(0)) {
- Type *ElTy = cast<PointerType>(ArgsTys[0])->getElementType();
+ Type *ElTy = ArgsTys[0]->getPointerElementType();
Attribute NewAttr = Attribute::get(Context, Attribute::ElementType, ElTy);
CB->addParamAttr(0, NewAttr);
}
return error("Invalid record");
if (!Ty) {
- Ty = cast<PointerType>(BasePtr->getType()->getScalarType())
- ->getElementType();
+ Ty = BasePtr->getType()->getScalarType()->getPointerElementType();
} else if (!cast<PointerType>(BasePtr->getType()->getScalarType())
->isOpaqueOrPointeeTypeMatches(Ty)) {
return error(
if (!CalleeTy)
return error("Callee is not a pointer");
if (!FTy) {
- FTy = dyn_cast<FunctionType>(
- cast<PointerType>(Callee->getType())->getElementType());
+ FTy =
+ dyn_cast<FunctionType>(Callee->getType()->getPointerElementType());
if (!FTy)
return error("Callee is not of pointer to function type");
} else if (!CalleeTy->isOpaqueOrPointeeTypeMatches(FTy))
if (!OpTy)
return error("Callee is not a pointer type");
if (!FTy) {
- FTy = dyn_cast<FunctionType>(
- cast<PointerType>(Callee->getType())->getElementType());
+ FTy =
+ dyn_cast<FunctionType>(Callee->getType()->getPointerElementType());
if (!FTy)
return error("Callee is not of pointer to function type");
} else if (!OpTy->isOpaqueOrPointeeTypeMatches(FTy))
auto *PTy = dyn_cast_or_null<PointerType>(Ty);
if (!PTy)
return error("Old-style alloca with a non-pointer type");
- Ty = PTy->getElementType();
+ Ty = PTy->getPointerElementType();
}
Type *OpTy = getTypeByID(Record[1]);
Value *Size = getFnValueByID(Record[2], OpTy);
if (OpNum + 3 == Record.size()) {
Ty = getTypeByID(Record[OpNum++]);
} else {
- Ty = cast<PointerType>(Op->getType())->getElementType();
+ Ty = Op->getType()->getPointerElementType();
}
if (Error Err = typeCheckLoadStoreInst(Ty, Op->getType()))
if (OpNum + 5 == Record.size()) {
Ty = getTypeByID(Record[OpNum++]);
} else {
- Ty = cast<PointerType>(Op->getType())->getElementType();
+ Ty = Op->getType()->getPointerElementType();
}
if (Error Err = typeCheckLoadStoreInst(Ty, Op->getType()))
(BitCode == bitc::FUNC_CODE_INST_STORE
? getValueTypePair(Record, OpNum, NextValueNo, Val)
: popValue(Record, OpNum, NextValueNo,
- cast<PointerType>(Ptr->getType())->getElementType(),
- Val)) ||
+ Ptr->getType()->getPointerElementType(), Val)) ||
OpNum + 2 != Record.size())
return error("Invalid record");
(BitCode == bitc::FUNC_CODE_INST_STOREATOMIC
? getValueTypePair(Record, OpNum, NextValueNo, Val)
: popValue(Record, OpNum, NextValueNo,
- cast<PointerType>(Ptr->getType())->getElementType(),
- Val)) ||
+ Ptr->getType()->getPointerElementType(), Val)) ||
OpNum + 4 != Record.size())
return error("Invalid record");
if (!OpTy)
return error("Callee is not a pointer type");
if (!FTy) {
- FTy = dyn_cast<FunctionType>(
- cast<PointerType>(Callee->getType())->getElementType());
+ FTy =
+ dyn_cast<FunctionType>(Callee->getType()->getPointerElementType());
if (!FTy)
return error("Callee is not of pointer to function type");
} else if (!OpTy->isOpaqueOrPointeeTypeMatches(FTy))
} else {
// POINTER: [pointee type, address space]
Code = bitc::TYPE_CODE_POINTER;
- TypeVals.push_back(VE.getTypeID(PTy->getElementType()));
+ TypeVals.push_back(VE.getTypeID(PTy->getNonOpaquePointerElementType()));
TypeVals.push_back(AddressSpace);
if (AddressSpace == 0)
AbbrevToUse = PtrAbbrev;
PointerType *PtrTy = dyn_cast<PointerType>(OpTy);
if (!PtrTy)
report_fatal_error("Indirect operand for inline asm not a pointer!");
- OpTy = PtrTy->getElementType();
+ OpTy = PtrTy->getPointerElementType();
}
// FIXME: Support aggregate input operands
OpDescriptor llvm::fuzzerop::gepDescriptor(unsigned Weight) {
auto buildGEP = [](ArrayRef<Value *> Srcs, Instruction *Inst) {
- Type *Ty = cast<PointerType>(Srcs[0]->getType())->getElementType();
+ Type *Ty = Srcs[0]->getType()->getPointerElementType();
auto Indices = makeArrayRef(Srcs).drop_front(1);
return GetElementPtrInst::Create(Ty, Srcs[0], Indices, "G", Inst);
};
IP = ++I->getIterator();
assert(IP != BB.end() && "guaranteed by the findPointer");
}
- auto *NewLoad = new LoadInst(
- cast<PointerType>(Ptr->getType())->getElementType(), Ptr, "L", &*IP);
+ auto *NewLoad =
+ new LoadInst(Ptr->getType()->getPointerElementType(), Ptr, "L", &*IP);
// Only sample this load if it really matches the descriptor
if (Pred.matches(Srcs, NewLoad))
if (auto PtrTy = dyn_cast<PointerType>(Inst->getType())) {
// We can never generate loads from non first class or non sized types
- if (!PtrTy->getElementType()->isSized() ||
- !PtrTy->getElementType()->isFirstClassType())
+ Type *ElemTy = PtrTy->getPointerElementType();
+ if (!ElemTy->isSized() || !ElemTy->isFirstClassType())
return false;
// TODO: Check if this is horribly expensive.
- return Pred.matches(Srcs, UndefValue::get(PtrTy->getElementType()));
+ return Pred.matches(Srcs, UndefValue::get(ElemTy));
}
return false;
};
OS << " addrspace(" << AddressSpace << ')';
return;
}
- print(PTy->getElementType(), OS);
+ print(PTy->getNonOpaquePointerElementType(), OS);
if (unsigned AddressSpace = PTy->getAddressSpace())
OS << " addrspace(" << AddressSpace << ')';
OS << '*';
if (F.getCallingConv() == CallingConv::X86_INTR &&
!F.arg_empty() && !F.hasParamAttribute(0, Attribute::ByVal)) {
- Type *ByValTy = cast<PointerType>(F.getArg(0)->getType())->getElementType();
+ Type *ByValTy = F.getArg(0)->getType()->getPointerElementType();
Attribute NewAttr = Attribute::getWithByValType(F.getContext(), ByValTy);
F.addParamAttr(0, NewAttr);
}
if (PointerType *DPTy = dyn_cast<PointerType>(DestTy))
if (PTy->getAddressSpace() == DPTy->getAddressSpace() &&
!PTy->isOpaque() && !DPTy->isOpaque() &&
- PTy->getElementType()->isSized()) {
+ PTy->getNonOpaquePointerElementType()->isSized()) {
SmallVector<Value*, 8> IdxList;
Value *Zero =
Constant::getNullValue(Type::getInt32Ty(DPTy->getContext()));
IdxList.push_back(Zero);
- Type *ElTy = PTy->getElementType();
- while (ElTy && ElTy != DPTy->getElementType()) {
+ Type *ElTy = PTy->getNonOpaquePointerElementType();
+ while (ElTy && ElTy != DPTy->getNonOpaquePointerElementType()) {
ElTy = GetElementPtrInst::getTypeAtIndex(ElTy, (uint64_t)0);
IdxList.push_back(Zero);
}
- if (ElTy == DPTy->getElementType())
+ if (ElTy == DPTy->getNonOpaquePointerElementType())
// This GEP is inbounds because all indices are zero.
- return ConstantExpr::getInBoundsGetElementPtr(PTy->getElementType(),
- V, IdxList);
+ return ConstantExpr::getInBoundsGetElementPtr(
+ PTy->getNonOpaquePointerElementType(), V, IdxList);
}
// Handle casts from one vector constant to another. We know that the src
PointerType *DstPtrTy = dyn_cast<PointerType>(CE->getType());
if (SrcPtrTy && DstPtrTy) {
ArrayType *SrcArrayTy =
- dyn_cast<ArrayType>(SrcPtrTy->getElementType());
+ dyn_cast<ArrayType>(SrcPtrTy->getPointerElementType());
ArrayType *DstArrayTy =
- dyn_cast<ArrayType>(DstPtrTy->getElementType());
+ dyn_cast<ArrayType>(DstPtrTy->getPointerElementType());
if (SrcArrayTy && DstArrayTy
&& SrcArrayTy->getElementType() == DstArrayTy->getElementType()
&& SrcPtrTy->getAddressSpace() == DstPtrTy->getAddressSpace())
LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy) {
auto *Ty = unwrap<Type>(WrappedTy);
if (auto *PTy = dyn_cast<PointerType>(Ty))
- return wrap(PTy->getElementType());
+ return wrap(PTy->getPointerElementType());
if (auto *ATy = dyn_cast<ArrayType>(Ty))
return wrap(ATy->getElementType());
return wrap(cast<VectorType>(Ty)->getElementType());
// Opaque pointer doesn't have pointee type information, so we just mangle
// address space for opaque pointer.
if (!PTyp->isOpaque())
- Result += getMangledTypeStr(PTyp->getElementType(), HasUnnamedType);
+ Result += getMangledTypeStr(PTyp->getNonOpaquePointerElementType(),
+ HasUnnamedType);
} else if (ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
Result += "a" + utostr(ATyp->getNumElements()) +
getMangledTypeStr(ATyp->getElementType(), HasUnnamedType);
if (!PT || PT->getAddressSpace() != D.Pointer_AddressSpace)
return true;
if (!PT->isOpaque())
- return matchIntrinsicType(PT->getElementType(), Infos, ArgTys,
- DeferredChecks, IsDeferredCheck);
+ return matchIntrinsicType(PT->getNonOpaquePointerElementType(), Infos,
+ ArgTys, DeferredChecks, IsDeferredCheck);
// Consume IIT descriptors relating to the pointer element type.
while (Infos.front().Kind == IITDescriptor::Pointer)
Infos = Infos.slice(1);
return IsDeferredCheck || DeferCheck(Ty);
Type * ReferenceType = ArgTys[D.getArgumentNumber()];
PointerType *ThisArgType = dyn_cast<PointerType>(Ty);
- return (!ThisArgType || ThisArgType->getElementType() != ReferenceType);
+ return (!ThisArgType ||
+ ThisArgType->getPointerElementType() != ReferenceType);
}
case IITDescriptor::PtrToElt: {
if (D.getArgumentNumber() >= ArgTys.size())
const Twine &Name) {
// Extract out the type of the callee.
auto *FuncPtrType = cast<PointerType>(ActualCallee->getType());
- assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
+ assert(isa<FunctionType>(FuncPtrType->getPointerElementType()) &&
"actual callee must be a callable value");
Module *M = Builder->GetInsertBlock()->getParent()->getParent();
ArrayRef<T3> GCArgs, const Twine &Name) {
// Extract out the type of the callee.
auto *FuncPtrType = cast<PointerType>(ActualInvokee->getType());
- assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
+ assert(isa<FunctionType>(FuncPtrType->getPointerElementType()) &&
"actual callee must be a callable value");
Module *M = Builder->GetInsertBlock()->getParent()->getParent();
const Twine &Name) {
assert(LHS->getType() == RHS->getType() &&
"Pointer subtraction operand types must match!");
- auto *ArgType = cast<PointerType>(LHS->getType());
+ auto *ArgElemType = LHS->getType()->getPointerElementType();
Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context));
Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context));
Value *Difference = CreateSub(LHS_int, RHS_int);
- return CreateExactSDiv(Difference,
- ConstantExpr::getSizeOf(ArgType->getElementType()),
+ return CreateExactSDiv(Difference, ConstantExpr::getSizeOf(ArgElemType),
Name);
}
"Attribute 'preallocated' does not support unsized types!", V);
}
if (!PTy->isOpaque()) {
- if (!isa<PointerType>(PTy->getElementType()))
+ if (!isa<PointerType>(PTy->getNonOpaquePointerElementType()))
Assert(!Attrs.hasAttribute(Attribute::SwiftError),
"Attribute 'swifterror' only applies to parameters "
"with pointer to pointer type!",
V);
if (Attrs.hasAttribute(Attribute::ByRef)) {
- Assert(Attrs.getByRefType() == PTy->getElementType(),
+ Assert(Attrs.getByRefType() == PTy->getNonOpaquePointerElementType(),
"Attribute 'byref' type does not match parameter!", V);
}
if (Attrs.hasAttribute(Attribute::ByVal) && Attrs.getByValType()) {
- Assert(Attrs.getByValType() == PTy->getElementType(),
+ Assert(Attrs.getByValType() == PTy->getNonOpaquePointerElementType(),
"Attribute 'byval' type does not match parameter!", V);
}
if (Attrs.hasAttribute(Attribute::Preallocated)) {
- Assert(Attrs.getPreallocatedType() == PTy->getElementType(),
+ Assert(Attrs.getPreallocatedType() ==
+ PTy->getNonOpaquePointerElementType(),
"Attribute 'preallocated' type does not match parameter!", V);
}
if (Attrs.hasAttribute(Attribute::InAlloca)) {
- Assert(Attrs.getInAllocaType() == PTy->getElementType(),
+ Assert(Attrs.getInAllocaType() == PTy->getNonOpaquePointerElementType(),
"Attribute 'inalloca' type does not match parameter!", V);
}
if (Attrs.hasAttribute(Attribute::ElementType)) {
- Assert(Attrs.getElementType() == PTy->getElementType(),
+ Assert(Attrs.getElementType() == PTy->getNonOpaquePointerElementType(),
"Attribute 'elementtype' type does not match parameter!", V);
}
}
const Value *Target = Call.getArgOperand(2);
auto *PT = dyn_cast<PointerType>(Target->getType());
- Assert(PT && PT->getElementType()->isFunctionTy(),
+ Assert(PT && PT->getPointerElementType()->isFunctionTy(),
"gc.statepoint callee must be of function pointer type", Call, Target);
- FunctionType *TargetFuncType = cast<FunctionType>(PT->getElementType());
+ FunctionType *TargetFuncType =
+ cast<FunctionType>(PT->getPointerElementType());
const int NumCallArgs = cast<ConstantInt>(Call.getArgOperand(3))->getZExtValue();
Assert(NumCallArgs >= 0,
// Assert that result type matches wrapped callee.
const Value *Target = StatepointCall->getArgOperand(2);
auto *PT = cast<PointerType>(Target->getType());
- auto *TargetFuncType = cast<FunctionType>(PT->getElementType());
+ auto *TargetFuncType = cast<FunctionType>(PT->getPointerElementType());
Assert(Call.getType() == TargetFuncType->getReturnType(),
"gc.result result type does not match wrapped callee", Call);
break;
PointerType *Op0PtrTy =
cast<PointerType>(Call.getArgOperand(0)->getType());
if (!Op0PtrTy->isOpaque())
- Op0ElemTy = Op0PtrTy->getElementType();
+ Op0ElemTy = Op0PtrTy->getNonOpaquePointerElementType();
break;
}
case Intrinsic::matrix_column_major_store: {
PointerType *Op1PtrTy =
cast<PointerType>(Call.getArgOperand(1)->getType());
if (!Op1PtrTy->isOpaque())
- Op1ElemTy = Op1PtrTy->getElementType();
+ Op1ElemTy = Op1PtrTy->getNonOpaquePointerElementType();
break;
}
default:
case Intrinsic::aarch64_ldxr: {
PointerType *PtrTy = cast<PointerType>(I.getArgOperand(0)->getType());
Info.opc = ISD::INTRINSIC_W_CHAIN;
- Info.memVT = MVT::getVT(PtrTy->getElementType());
+ Info.memVT = MVT::getVT(PtrTy->getPointerElementType());
Info.ptrVal = I.getArgOperand(0);
Info.offset = 0;
- Info.align = DL.getABITypeAlign(PtrTy->getElementType());
+ Info.align = DL.getABITypeAlign(PtrTy->getPointerElementType());
Info.flags = MachineMemOperand::MOLoad | MachineMemOperand::MOVolatile;
return true;
}
case Intrinsic::aarch64_stxr: {
PointerType *PtrTy = cast<PointerType>(I.getArgOperand(1)->getType());
Info.opc = ISD::INTRINSIC_W_CHAIN;
- Info.memVT = MVT::getVT(PtrTy->getElementType());
+ Info.memVT = MVT::getVT(PtrTy->getPointerElementType());
Info.ptrVal = I.getArgOperand(1);
Info.offset = 0;
- Info.align = DL.getABITypeAlign(PtrTy->getElementType());
+ Info.align = DL.getABITypeAlign(PtrTy->getPointerElementType());
Info.flags = MachineMemOperand::MOStore | MachineMemOperand::MOVolatile;
return true;
}
Info.memVT = MVT::getVT(I.getType());
Info.ptrVal = I.getArgOperand(1);
Info.offset = 0;
- Info.align = DL.getABITypeAlign(PtrTy->getElementType());
+ Info.align = DL.getABITypeAlign(PtrTy->getPointerElementType());
Info.flags = MachineMemOperand::MOLoad | MachineMemOperand::MONonTemporal;
return true;
}
Info.memVT = MVT::getVT(I.getOperand(0)->getType());
Info.ptrVal = I.getArgOperand(2);
Info.offset = 0;
- Info.align = DL.getABITypeAlign(PtrTy->getElementType());
+ Info.align = DL.getABITypeAlign(PtrTy->getPointerElementType());
Info.flags = MachineMemOperand::MOStore | MachineMemOperand::MONonTemporal;
return true;
}
if (auto PtrTy = dyn_cast<PointerType>(Arg.getType())) {
if (PtrTy->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
// FIXME: Should report this for all address spaces
- PointeeAlign = DL.getValueOrABITypeAlignment(Arg.getParamAlign(),
- PtrTy->getElementType());
+ PointeeAlign = DL.getValueOrABITypeAlignment(
+ Arg.getParamAlign(), PtrTy->getPointerElementType());
}
}
// FIXME: Need to distinguish in memory alignment from pointer alignment.
if (auto PtrTy = dyn_cast<PointerType>(Ty)) {
if (PtrTy->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
- PointeeAlign = DL.getValueOrABITypeAlignment(Arg.getParamAlign(),
- PtrTy->getElementType());
+ PointeeAlign = DL.getValueOrABITypeAlignment(
+ Arg.getParamAlign(), PtrTy->getPointerElementType());
}
}
PointerType *ArgType = cast<PointerType>(Arg.getType());
- auto *EltTy = ArgType->getElementType();
+ auto *EltTy = ArgType->getPointerElementType();
const auto Align =
DL->getValueOrABITypeAlignment(Arg.getParamAlign(), EltTy);
auto &DL = I.getCalledFunction()->getParent()->getDataLayout();
PointerType *PtrTy = cast<PointerType>(I.getArgOperand(0)->getType());
Info.opc = ISD::INTRINSIC_W_CHAIN;
- Info.memVT = MVT::getVT(PtrTy->getElementType());
+ Info.memVT = MVT::getVT(PtrTy->getPointerElementType());
Info.ptrVal = I.getArgOperand(0);
Info.offset = 0;
- Info.align = DL.getABITypeAlign(PtrTy->getElementType());
+ Info.align = DL.getABITypeAlign(PtrTy->getPointerElementType());
Info.flags = MachineMemOperand::MOLoad | MachineMemOperand::MOVolatile;
return true;
}
auto &DL = I.getCalledFunction()->getParent()->getDataLayout();
PointerType *PtrTy = cast<PointerType>(I.getArgOperand(1)->getType());
Info.opc = ISD::INTRINSIC_W_CHAIN;
- Info.memVT = MVT::getVT(PtrTy->getElementType());
+ Info.memVT = MVT::getVT(PtrTy->getPointerElementType());
Info.ptrVal = I.getArgOperand(1);
Info.offset = 0;
- Info.align = DL.getABITypeAlign(PtrTy->getElementType());
+ Info.align = DL.getABITypeAlign(PtrTy->getPointerElementType());
Info.flags = MachineMemOperand::MOStore | MachineMemOperand::MOVolatile;
return true;
}
// Calculate symbol size
const DataLayout &DL = Global.getParent()->getDataLayout();
- uint32_t Size = DL.getTypeAllocSize(Global.getType()->getElementType());
+ uint32_t Size =
+ DL.getTypeAllocSize(Global.getType()->getPointerElementType());
DataSecEntries[std::string(SecName)]->addDataSecEntry(VarId,
Asm->getSymbol(&Global), Size);
// we don't need to do pointer casts.
auto *PtrTy = cast<PointerType>(Ptr->getType());
if (!PtrTy->isOpaque()) {
- Type *ElemTy = PtrTy->getElementType();
+ Type *ElemTy = PtrTy->getNonOpaquePointerElementType();
int ElemSize = HVC.getAllocSizeOf(ElemTy);
if (Adjust % ElemSize == 0 && Adjust != 0) {
Value *Tmp0 =
if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() !=
NVPTX::CUDA) {
- Type *ETy = PTy->getElementType();
+ Type *ETy = PTy->getPointerElementType();
int addrSpace = PTy->getAddressSpace();
switch (addrSpace) {
default:
// param has byVal attribute. So should be a pointer
auto *PTy = dyn_cast<PointerType>(Ty);
assert(PTy && "Param with byval attribute should be a pointer type");
- Type *ETy = PTy->getElementType();
+ Type *ETy = PTy->getPointerElementType();
if (isABI || isKernelFunc) {
// Just print .param .align <a> .b8 .param[size];
}
auto *PTy = dyn_cast<PointerType>(Ty);
assert(PTy && "Param with byval attribute should be a pointer type");
- Type *ETy = PTy->getElementType();
+ Type *ETy = PTy->getPointerElementType();
Align align = Outs[OIdx].Flags.getNonZeroByValAlign();
unsigned sz = DL.getTypeAllocSize(ETy);
SmallVector<uint64_t, 16> Offsets;
auto *PTy = dyn_cast<PointerType>(Args[i].Ty);
assert(PTy && "Type of a byval parameter should be pointer");
- ComputePTXValueVTs(*this, DL, PTy->getElementType(), VTs, &Offsets, 0);
+ ComputePTXValueVTs(*this, DL, PTy->getPointerElementType(), VTs, &Offsets,
+ 0);
// declare .param .align <align> .b8 .param<n>[<size>];
unsigned sz = Outs[OIdx].Flags.getByValSize();
if (!context)
return false;
- auto *STy = dyn_cast<StructType>(PTy->getElementType());
+ auto *STy = dyn_cast<StructType>(PTy->getPointerElementType());
if (!STy || STy->isLiteral())
return false;
assert(PType && "Expecting pointer type in handleByValParam");
- Type *StructType = PType->getElementType();
+ Type *StructType = PType->getPointerElementType();
auto IsALoadChain = [&](Value *Start) {
SmallVector<Value *, 16> ValuesToCheck = {Start};
assert(EnableQuadwordAtomics && Subtarget.hasQuadwordAtomics() &&
"Only support quadword now");
Module *M = Builder.GetInsertBlock()->getParent()->getParent();
- Type *ValTy = cast<PointerType>(AlignedAddr->getType())->getElementType();
+ Type *ValTy = AlignedAddr->getType()->getPointerElementType();
assert(ValTy->getPrimitiveSizeInBits() == 128);
Function *RMW = Intrinsic::getDeclaration(
M, getIntrinsicForAtomicRMWBinOp128(AI->getOperation()));
assert(EnableQuadwordAtomics && Subtarget.hasQuadwordAtomics() &&
"Only support quadword now");
Module *M = Builder.GetInsertBlock()->getParent()->getParent();
- Type *ValTy = cast<PointerType>(AlignedAddr->getType())->getElementType();
+ Type *ValTy = AlignedAddr->getType()->getPointerElementType();
assert(ValTy->getPrimitiveSizeInBits() == 128);
Function *IntCmpXchg =
Intrinsic::getDeclaration(M, Intrinsic::ppc_cmpxchg_i128);
case Intrinsic::riscv_masked_cmpxchg_i32: {
PointerType *PtrTy = cast<PointerType>(I.getArgOperand(0)->getType());
Info.opc = ISD::INTRINSIC_W_CHAIN;
- Info.memVT = MVT::getVT(PtrTy->getElementType());
+ Info.memVT = MVT::getVT(PtrTy->getPointerElementType());
Info.ptrVal = I.getArgOperand(0);
Info.offset = 0;
Info.align = Align(4);
// sret only allowed on first argument
assert(Outs[realArgIdx].OrigArgIndex == 0);
PointerType *Ty = cast<PointerType>(CLI.getArgs()[0].Ty);
- Type *ElementTy = Ty->getElementType();
+ Type *ElementTy = Ty->getPointerElementType();
SRetArgSize = DAG.getDataLayout().getTypeAllocSize(ElementTy);
continue;
}
if (Ty->isPointerTy()) {
auto *PtrTy = cast<PointerType>(Ty);
- Type *PointeeTy = PtrTy->getElementType();
+ Type *PointeeTy = PtrTy->getPointerElementType();
auto Name = solveTypeName(PointeeTy);
if (Name == "UnknownType")
return "PointerType";
IRBuilder<> Builder(F.getEntryBlock().getFirstNonPHIOrDbg());
auto ArgTy = cast<PointerType>(Arg.getType());
- auto ValueTy = ArgTy->getElementType();
+ auto ValueTy = ArgTy->getPointerElementType();
// Reduce to the alloca case:
for (const auto &ArgIndex : ArgIndices) {
// not allowed to dereference ->begin() if size() is 0
Params.push_back(GetElementPtrInst::getIndexedType(
- cast<PointerType>(I->getType())->getElementType(),
- ArgIndex.second));
+ I->getType()->getPointerElementType(), ArgIndex.second));
ArgAttrVec.push_back(AttributeSet());
assert(Params.back());
}
Ops.push_back(ConstantInt::get(IdxTy, II));
// Keep track of the type we're currently indexing.
if (auto *ElPTy = dyn_cast<PointerType>(ElTy))
- ElTy = ElPTy->getElementType();
+ ElTy = ElPTy->getPointerElementType();
else
ElTy = GetElementPtrInst::getTypeAtIndex(ElTy, II);
}
SmallPtrSet<Argument *, 8> ArgsToPromote;
SmallPtrSet<Argument *, 8> ByValArgsToTransform;
for (Argument *PtrArg : PointerArgs) {
- Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
+ Type *AgTy = PtrArg->getType()->getPointerElementType();
// Replace sret attribute with noalias. This reduces register pressure by
// avoiding a register copy.
if (!Call.isByValArgument(ix))
return false;
- Type *SrcElemTy = SrcTy->getElementType();
+ Type *SrcElemTy = SrcTy->getNonOpaquePointerElementType();
Type *DstElemTy = Call.getParamByValType(ix);
if (!SrcElemTy->isSized() || !DstElemTy->isSized())
return false;
Call.removeParamAttr(ix, Attribute::ByVal);
Call.addParamAttr(
ix, Attribute::getWithByValType(
- Call.getContext(), NewTy->getElementType()));
+ Call.getContext(), NewTy->getPointerElementType()));
}
Changed = true;
}
// sized type and the sized type has to have the same size as the old type.
if (ParamTy != ActTy && CallerPAL.hasParamAttr(i, Attribute::ByVal)) {
PointerType *ParamPTy = dyn_cast<PointerType>(ParamTy);
- if (!ParamPTy || !ParamPTy->getElementType()->isSized())
+ if (!ParamPTy || !ParamPTy->getPointerElementType()->isSized())
return false;
Type *CurElTy = Call.getParamByValType(i);
if (DL.getTypeAllocSize(CurElTy) !=
- DL.getTypeAllocSize(ParamPTy->getElementType()))
+ DL.getTypeAllocSize(ParamPTy->getPointerElementType()))
return false;
}
}
// call. We don't want to introduce a varargs call where one doesn't
// already exist.
PointerType *APTy = cast<PointerType>(Call.getCalledOperand()->getType());
- if (FT->isVarArg()!=cast<FunctionType>(APTy->getElementType())->isVarArg())
+ if (FT->isVarArg()!=cast<FunctionType>(APTy->getPointerElementType())->isVarArg())
return false;
// If both the callee and the cast type are varargs, we still have to make
// sure the number of fixed parameters are the same or we have the same
// ABI issues as if we introduce a varargs call.
if (FT->isVarArg() &&
- cast<FunctionType>(APTy->getElementType())->isVarArg() &&
+ cast<FunctionType>(APTy->getPointerElementType())->isVarArg() &&
FT->getNumParams() !=
- cast<FunctionType>(APTy->getElementType())->getNumParams())
+ cast<FunctionType>(APTy->getPointerElementType())->getNumParams())
return false;
}
// Get the type really allocated and the type casted to.
Type *AllocElTy = AI.getAllocatedType();
- Type *CastElTy = PTy->getElementType();
+ Type *CastElTy = PTy->getPointerElementType();
if (!AllocElTy->isSized() || !CastElTy->isSized()) return nullptr;
// This optimisation does not work for cases where the cast type
if (SrcPTy->isOpaque() || DstPTy->isOpaque())
return nullptr;
- Type *DstElTy = DstPTy->getElementType();
- Type *SrcElTy = SrcPTy->getElementType();
+ Type *DstElTy = DstPTy->getNonOpaquePointerElementType();
+ Type *SrcElTy = SrcPTy->getNonOpaquePointerElementType();
// When the type pointed to is not sized the cast cannot be
// turned into a gep.
// If we found a path from the src to dest, create the getelementptr now.
if (SrcElTy == DstElTy) {
SmallVector<Value *, 8> Idxs(NumZeros + 1, Builder.getInt32(0));
- GetElementPtrInst *GEP =
- GetElementPtrInst::Create(SrcPTy->getElementType(), Src, Idxs);
+ GetElementPtrInst *GEP = GetElementPtrInst::Create(
+ SrcPTy->getNonOpaquePointerElementType(), Src, Idxs);
// If the source pointer is dereferenceable, then assume it points to an
// allocated object and apply "inbounds" to the GEP.
#ifndef NDEBUG
auto *PT = cast<PointerType>(I.getType());
auto *NT = cast<PointerType>(V->getType());
- assert(PT != NT && PT->getElementType() == NT->getElementType() &&
+ assert(PT != NT &&
+ PT->getPointerElementType() == NT->getPointerElementType() &&
"Invalid usage");
#endif
WorkMap[&I] = V;
Type *
InstCombinerImpl::FindElementAtOffset(PointerType *PtrTy, int64_t IntOffset,
SmallVectorImpl<Value *> &NewIndices) {
- Type *Ty = PtrTy->getElementType();
+ Type *Ty = PtrTy->getPointerElementType();
if (!Ty->isSized())
return nullptr;
// type. For now, skip these.
if (StrippedPtr != PtrOp && !StrippedPtrTy->isOpaque()) {
bool HasZeroPointerIndex = false;
- Type *StrippedPtrEltTy = StrippedPtrTy->getElementType();
+ Type *StrippedPtrEltTy = StrippedPtrTy->getNonOpaquePointerElementType();
if (auto *C = dyn_cast<ConstantInt>(GEP.getOperand(1)))
HasZeroPointerIndex = C->isZero();
if (auto *BCI = dyn_cast<BitCastInst>(ASCStrippedPtrOp)) {
Value *SrcOp = BCI->getOperand(0);
PointerType *SrcType = cast<PointerType>(BCI->getSrcTy());
- Type *SrcEltType = SrcType->getElementType();
+ Type *SrcEltType = SrcType->getPointerElementType();
// GEP directly using the source operand if this GEP is accessing an element
// of a bitcasted pointer to vector or array of the same dimensions:
auto BasePtr = CI->getOperand(OpOffset);
if (ignoreAccess(LI, BasePtr))
return;
- auto Ty = cast<PointerType>(BasePtr->getType())->getElementType();
+ auto Ty = BasePtr->getType()->getPointerElementType();
MaybeAlign Alignment = Align(1);
// Otherwise no alignment guarantees. We probably got Undef.
if (auto *Op = dyn_cast<ConstantInt>(CI->getOperand(1 + OpOffset)))
unsigned Granularity, uint32_t TypeSize,
bool IsWrite, Value *SizeArgument,
bool UseCalls, uint32_t Exp) {
- auto *VTy = cast<FixedVectorType>(
- cast<PointerType>(Addr->getType())->getElementType());
+ auto *VTy = cast<FixedVectorType>(Addr->getType()->getPointerElementType());
uint64_t ElemTypeSize = DL.getTypeStoreSizeInBits(VTy->getScalarType());
unsigned Num = VTy->getNumElements();
auto Zero = ConstantInt::get(IntptrTy, 0);
}
auto *BasePtr = CI->getOperand(0 + OpOffset);
- auto *Ty = cast<PointerType>(BasePtr->getType())->getElementType();
+ auto *Ty = BasePtr->getType()->getPointerElementType();
Access.TypeSize = DL.getTypeStoreSizeInBits(Ty);
if (auto *AlignmentConstant =
dyn_cast<ConstantInt>(CI->getOperand(1 + OpOffset)))
Instruction *I, Value *Addr,
unsigned Alignment,
uint32_t TypeSize, bool IsWrite) {
- auto *VTy = cast<FixedVectorType>(
- cast<PointerType>(Addr->getType())->getElementType());
+ auto *VTy = cast<FixedVectorType>(Addr->getType()->getPointerElementType());
uint64_t ElemTypeSize = DL.getTypeStoreSizeInBits(VTy->getScalarType());
unsigned Num = VTy->getNumElements();
auto *Zero = ConstantInt::get(IntptrTy, 0);
void ModuleSanitizerCoverage::InjectTraceForLoadsAndStores(
Function &, ArrayRef<LoadInst *> Loads, ArrayRef<StoreInst *> Stores) {
auto CallbackIdx = [&](const Value *Ptr) -> int {
- auto ElementTy = cast<PointerType>(Ptr->getType())->getElementType();
+ auto *ElementTy = Ptr->getType()->getPointerElementType();
uint64_t TypeSize = DL->getTypeStoreSizeInBits(ElementTy);
return TypeSize == 8 ? 0
: TypeSize == 16 ? 1
if (IsNullOrUndef(CI->getArgOperand(0))) {
Changed = true;
Type *Ty = CI->getArgOperand(0)->getType();
- new StoreInst(UndefValue::get(cast<PointerType>(Ty)->getElementType()),
+ new StoreInst(UndefValue::get(Ty->getPointerElementType()),
Constant::getNullValue(Ty), CI);
Value *NewValue = UndefValue::get(CI->getType());
LLVM_DEBUG(
IsNullOrUndef(CI->getArgOperand(1))) {
Changed = true;
Type *Ty = CI->getArgOperand(0)->getType();
- new StoreInst(UndefValue::get(cast<PointerType>(Ty)->getElementType()),
+ new StoreInst(UndefValue::get(Ty->getPointerElementType()),
Constant::getNullValue(Ty), CI);
Value *NewValue = UndefValue::get(CI->getType());
if (Ty == IRB.getInt8PtrTy(Ty->getAddressSpace()) && TargetTy->isIntegerTy(8))
return nullptr;
- Type *ElementTy = Ty->getElementType();
+ Type *ElementTy = Ty->getNonOpaquePointerElementType();
if (!ElementTy->isSized())
return nullptr; // We can't GEP through an unsized element.
APInt Int8PtrOffset(Offset.getBitWidth(), 0);
PointerType *TargetPtrTy = cast<PointerType>(PointerTy);
- Type *TargetTy = TargetPtrTy->getElementType();
+ Type *TargetTy = TargetPtrTy->getNonOpaquePointerElementType();
// As `addrspacecast` is , `Ptr` (the storage pointer) may have different
// address space from the expected `PointerTy` (the pointer to be used).
Type *Ty = V->getType();
PtrTy = dyn_cast<PointerType>(Ty);
if (PtrTy)
- Ty = PtrTy->getElementType();
+ Ty = PtrTy->getPointerElementType();
Size = cast<FixedVectorType>(Ty)->getNumElements();
if (!CachePtr)
Tmp.resize(Size, nullptr);
return CV[I];
IRBuilder<> Builder(BB, BBI);
if (PtrTy) {
- Type *ElTy = cast<VectorType>(PtrTy->getElementType())->getElementType();
+ Type *ElTy =
+ cast<VectorType>(PtrTy->getPointerElementType())->getElementType();
if (!CV[0]) {
Type *NewPtrTy = PointerType::get(ElTy, PtrTy->getAddressSpace());
CV[0] = Builder.CreateBitCast(V, NewPtrTy, V->getName() + ".i0");
if (!PtrTy)
return false;
- auto IntTy = dyn_cast<IntegerType>(PtrTy->getElementType());
+ auto IntTy = dyn_cast<IntegerType>(PtrTy->getPointerElementType());
if (!IntTy)
return false;
Function *F = OrigBB->getParent();
const DataLayout &DL = F->getParent()->getDataLayout();
- Type *EltTy = cast<PointerType>(SrcAddr->getType())->getElementType();
+ Type *EltTy = SrcAddr->getType()->getPointerElementType();
// Create the a comparison of src and dst, based on which we jump to either
// the forward-copy part of the function (if src >= dst) or the backwards-copy
auto *PtrTy = cast<PointerType>(Ty);
if (DL.isNonIntegralPointerType(PtrTy)) {
auto *Int8PtrTy = Builder.getInt8PtrTy(PtrTy->getAddressSpace());
- assert(DL.getTypeAllocSize(Int8PtrTy->getElementType()) == 1 &&
+ assert(DL.getTypeAllocSize(Int8PtrTy->getPointerElementType()) == 1 &&
"alloc size of i8 must by 1 byte for the GEP to be correct");
auto *GEP = Builder.CreateGEP(
Builder.getInt8Ty(), Constant::getNullValue(Int8PtrTy), V, "uglygep");
// indexes into the array implied by the pointer operand; the rest of
// the indices index into the element or field type selected by the
// preceding index.
- Type *ElTy = PTy->getElementType();
+ Type *ElTy = PTy->getNonOpaquePointerElementType();
for (;;) {
// If the scale size is not 0, attempt to factor out a scale for
// array indexing.
Value *Casted = V;
if (V->getType() != PTy)
Casted = InsertNoopCastOfTo(Casted, PTy);
- Value *GEP = Builder.CreateGEP(PTy->getElementType(), Casted, GepIndices,
- "scevgep");
+ Value *GEP = Builder.CreateGEP(PTy->getNonOpaquePointerElementType(),
+ Casted, GepIndices, "scevgep");
Ops.push_back(SE.getUnknown(GEP));
}
void Act() override {
// Try to use predefined pointers. If non-exist, use undef pointer value;
Value *Ptr = getRandomPointerValue();
- PointerType *Tp = cast<PointerType>(Ptr->getType());
- Value *V = new LoadInst(Tp->getElementType(), Ptr, "L",
+ Value *V = new LoadInst(Ptr->getType()->getPointerElementType(), Ptr, "L",
BB->getTerminator());
PT->push_back(V);
}
void Act() override {
// Try to use predefined pointers. If non-exist, use undef pointer value;
Value *Ptr = getRandomPointerValue();
- PointerType *Tp = cast<PointerType>(Ptr->getType());
- Value *Val = getRandomValue(Tp->getElementType());
+ Value *Val = getRandomValue(Ptr->getType()->getPointerElementType());
Type *ValTy = Val->getType();
// Do not store vectors of i1s because they are unsupported