This now always returns true (for pointer types).
AbstractInfo = abstractInfo;
assert(functionPtr && "configuring callee without function pointer");
assert(functionPtr->getType()->isPointerTy());
- assert(functionPtr->getType()->isOpaquePointerTy() ||
- functionPtr->getType()->getNonOpaquePointerElementType()
- ->isFunctionTy());
}
static CGCallee forBuiltin(unsigned builtinID,
}
}
- // For opaque pointers an all-zero GEP is a no-op. For typed pointers,
- // it may be equivalent to a bitcast.
- if (Ptr->getType()->getScalarType()->isOpaquePointerTy() &&
- Ptr->getType() == GEPTy &&
+ // All-zero GEP is a no-op, unless it performs a vector splat.
+ if (Ptr->getType() == GEPTy &&
all_of(Indices, [](const auto *V) { return match(V, m_Zero()); }))
return Ptr;
// Handle "ptr" opaque pointer type.
//
// Type ::= ptr ('addrspace' '(' uint32 ')')?
- if (Result->isOpaquePointerTy()) {
+ if (Result->isPointerTy()) {
unsigned AddrSpace;
if (parseOptionalAddrSpace(AddrSpace))
return true;
return It->second;
}
-#ifndef NDEBUG
- if (!Ty->isOpaquePointerTy()) {
- assert(Ty->getNumContainedTypes() == ChildTypeIDs.size() &&
- "Wrong number of contained types");
- for (auto Pair : zip(Ty->subtypes(), ChildTypeIDs)) {
- assert(std::get<0>(Pair) == getTypeByID(std::get<1>(Pair)) &&
- "Incorrect contained type ID");
- }
- }
-#endif
-
unsigned TypeID = TypeList.size();
TypeList.push_back(Ty);
if (!ChildTypeIDs.empty())
auto buildGEP = [](ArrayRef<Value *> Srcs, Instruction *Inst) {
// TODO: It would be better to generate a random type here, rather than
// generating a random value and picking its type.
- Type *Ty = Srcs[0]->getType()->isOpaquePointerTy()
- ? Srcs[1]->getType()
- : Srcs[0]->getType()->getNonOpaquePointerElementType();
+ Type *Ty = Srcs[1]->getType();
auto Indices = ArrayRef(Srcs).drop_front(2);
return GetElementPtrInst::Create(Ty, Srcs[0], Indices, "G", Inst);
};
IP = ++I->getIterator();
assert(IP != BB.end() && "guaranteed by the findPointer");
}
- // For opaque pointers, pick the type independently.
- Type *AccessTy = Ptr->getType()->isOpaquePointerTy()
- ? RS.getSelection()->getType()
- : Ptr->getType()->getNonOpaquePointerElementType();
+ // Pick the type independently.
+ Type *AccessTy = RS.getSelection()->getType();
auto *NewLoad = new LoadInst(AccessTy, Ptr, "L", &*IP);
// Only sample this load if it really matches the descriptor
}
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty) {
- return unwrap(Ty)->isOpaquePointerTy();
+ return true;
}
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {
auto *AsyncFuncPtrAddr = dyn_cast<GlobalVariable>(V->stripPointerCasts());
if (!AsyncFuncPtrAddr)
fail(I, "llvm.coro.id.async async function pointer not a global", V);
-
- if (AsyncFuncPtrAddr->getType()->isOpaquePointerTy())
- return;
-
- auto *StructTy = cast<StructType>(
- AsyncFuncPtrAddr->getType()->getNonOpaquePointerElementType());
- if (StructTy->isOpaque() || !StructTy->isPacked() ||
- StructTy->getNumElements() != 2 ||
- !StructTy->getElementType(0)->isIntegerTy(32) ||
- !StructTy->getElementType(1)->isIntegerTy(32))
- fail(I,
- "llvm.coro.id.async async function pointer argument's type is not "
- "<{i32, i32}>",
- V);
}
void CoroIdAsyncInst::checkWellFormed() const {
unsigned BitWidth = DL.getIndexTypeSizeInBits(PtrTy);
MapVector<Value *, APInt> VariableOffsets;
APInt ConstantOffset(BitWidth, 0);
- if (PtrTy->isOpaquePointerTy() &&
- GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset)) {
- // For opaque pointers, convert into offset representation, to recognize
- // equivalent address calculations that use different type encoding.
+ if (GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset)) {
+ // Convert into offset representation, to recognize equivalent address
+ // calculations that use different type encoding.
LLVMContext &Context = GEP->getContext();
E.opcode = GEP->getOpcode();
E.type = nullptr;
E.varargs.push_back(
lookupOrAdd(ConstantInt::get(Context, ConstantOffset)));
} else {
- // If converting to offset representation fails (for typed pointers and
- // scalable vectors), fall back to type-based implementation:
+ // If converting to offset representation fails (for scalable vectors),
+ // fall back to type-based implementation:
E.opcode = GEP->getOpcode();
E.type = GEP->getSourceElementType();
for (Use &Op : GEP->operands())
IRB.SetInsertPoint(&LI);
- if (auto *TypedPtrTy = LI.getPointerOperandType();
- !TypedPtrTy->isOpaquePointerTy() && SI.getType() != TypedPtrTy) {
- TV = IRB.CreateBitOrPointerCast(TV, TypedPtrTy, "");
- FV = IRB.CreateBitOrPointerCast(FV, TypedPtrTy, "");
- }
-
LoadInst *TL =
IRB.CreateAlignedLoad(LI.getType(), TV, LI.getAlign(),
LI.getName() + ".sroa.speculate.load.true");
}
CondMemOp.insertBefore(NewMemOpBB->getTerminator());
Value *Ptr = SI.getOperand(1 + SuccIdx);
- if (auto *PtrTy = Ptr->getType();
- !PtrTy->isOpaquePointerTy() &&
- PtrTy != CondMemOp.getPointerOperandType())
- Ptr = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
- Ptr, CondMemOp.getPointerOperandType(), "", &CondMemOp);
CondMemOp.setOperand(I.getPointerOperandIndex(), Ptr);
if (isa<LoadInst>(I)) {
CondMemOp.setName(I.getName() + (IsThen ? ".then" : ".else") + ".val");
static Value *getAdjustedPtr(IRBuilderTy &IRB, const DataLayout &DL, Value *Ptr,
APInt Offset, Type *PointerTy,
const Twine &NamePrefix) {
- assert(Ptr->getType()->isOpaquePointerTy() &&
- "Only opaque pointers supported");
if (Offset != 0)
Ptr = IRB.CreateInBoundsGEP(IRB.getInt8Ty(), Ptr, IRB.getInt(Offset),
NamePrefix + "sroa_idx");
void Act() override {
// Try to use predefined pointers. If non-exist, use undef pointer value;
Value *Ptr = getRandomPointerValue();
- Type *Ty = Ptr->getType()->isOpaquePointerTy()
- ? pickType()
- : Ptr->getType()->getNonOpaquePointerElementType();
+ Type *Ty = pickType();
Value *V = new LoadInst(Ty, 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();
- Type *ValTy = Ptr->getType()->isOpaquePointerTy()
- ? pickType()
- : Ptr->getType()->getNonOpaquePointerElementType();
+ Type *ValTy = pickType();
// Do not store vectors of i1s because they are unsupported
// by the codegen.