}
unsigned DXILBitcodeWriter::getTypeID(Type *T, const Value *V) {
- if (!T->isOpaquePointerTy() &&
+ if (!T->isPointerTy() &&
// For Constant, always check PointerMap to make sure OpaquePointer in
// things like constant struct/array works.
(!V || !isa<Constant>(V)))
break;
}
case Type::PointerTyID: {
- PointerType *PTy = cast<PointerType>(T);
// POINTER: [pointee type, address space]
- Code = bitc::TYPE_CODE_POINTER;
- // Emitting an empty struct type for the opaque pointer's type allows
- // this to be order-independent. Non-struct types must be emitted in
- // bitcode before they can be referenced.
- if (PTy->isOpaquePointerTy()) {
- TypeVals.push_back(false);
- Code = bitc::TYPE_CODE_OPAQUE;
- writeStringRecord(Stream, bitc::TYPE_CODE_STRUCT_NAME,
- "dxilOpaquePtrReservedName", StructNameAbbrev);
- } else {
- TypeVals.push_back(getTypeID(PTy->getNonOpaquePointerElementType()));
- unsigned AddressSpace = PTy->getAddressSpace();
- TypeVals.push_back(AddressSpace);
- if (AddressSpace == 0)
- AbbrevToUse = PtrAbbrev;
- }
+ // Emitting an empty struct type for the pointer's type allows this to be
+ // order-independent. Non-struct types must be emitted in bitcode before
+ // they can be referenced.
+ TypeVals.push_back(false);
+ Code = bitc::TYPE_CODE_OPAQUE;
+ writeStringRecord(Stream, bitc::TYPE_CODE_STRUCT_NAME,
+ "dxilOpaquePtrReservedName", StructNameAbbrev);
break;
}
case Type::FunctionTyID: {
// Classifies the type of the value passed in by walking the value's users to
// find a typed instruction to materialize a type from.
Type *classifyPointerType(const Value *V, PointerTypeMap &Map) {
- assert(V->getType()->isOpaquePointerTy() &&
- "classifyPointerType called with non-opaque pointer");
+ assert(V->getType()->isPointerTy() &&
+ "classifyPointerType called with non-pointer");
auto It = Map.find(V);
if (It != Map.end())
return It->second;
Type *PointeeTy = nullptr;
if (auto *Inst = dyn_cast<GetElementPtrInst>(V)) {
- if (!Inst->getResultElementType()->isOpaquePointerTy())
+ if (!Inst->getResultElementType()->isPointerTy())
PointeeTy = Inst->getResultElementType();
} else if (auto *Inst = dyn_cast<AllocaInst>(V)) {
PointeeTy = Inst->getAllocatedType();
} else if (const auto *Inst = dyn_cast<StoreInst>(User)) {
NewPointeeTy = Inst->getValueOperand()->getType();
// When store value is ptr type, cannot get more type info.
- if (NewPointeeTy->isOpaquePointerTy())
+ if (NewPointeeTy->isPointerTy())
continue;
} else if (const auto *Inst = dyn_cast<GetElementPtrInst>(User)) {
NewPointeeTy = Inst->getSourceElementType();
// HLSL doesn't support pointers, so it is unlikely to get more than one
// or two levels of indirection in the IR. Because of this, recursion is
// pretty safe.
- if (NewPointeeTy->isOpaquePointerTy()) {
+ if (NewPointeeTy->isPointerTy()) {
PointeeTy = classifyPointerType(User, Map);
break;
}
SmallVector<Type *, 8> NewArgs;
Type *RetTy = F.getReturnType();
LLVMContext &Ctx = F.getContext();
- if (RetTy->isOpaquePointerTy()) {
+ if (RetTy->isPointerTy()) {
RetTy = nullptr;
for (const auto &B : F) {
const auto *RetInst = dyn_cast_or_null<ReturnInst>(B.getTerminator());
}
for (auto &A : F.args()) {
Type *ArgTy = A.getType();
- if (ArgTy->isOpaquePointerTy())
+ if (ArgTy->isPointerTy())
ArgTy = classifyPointerType(&A, Map);
NewArgs.push_back(ArgTy);
}
PointerTypeMap PointerTypeAnalysis::run(const Module &M) {
PointerTypeMap Map;
for (auto &G : M.globals()) {
- if (G.getType()->isOpaquePointerTy())
+ if (G.getType()->isPointerTy())
classifyPointerType(&G, Map);
if (G.getName() == "llvm.global_ctors")
classifyGlobalCtorPointerType(G, Map);
for (const auto &B : F) {
for (const auto &I : B) {
- if (I.getType()->isOpaquePointerTy())
+ if (I.getType()->isPointerTy())
classifyPointerType(&I, Map);
}
}