diff --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp --- a/llvm/lib/Target/DirectX/DXILPrepare.cpp +++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp @@ -127,9 +127,6 @@ I.eraseFromParent(); continue; } - // Only insert bitcasts if the IR is using opaque pointers. - if (M.getContext().supportsTypedPointers()) - continue; // Emtting NoOp bitcast instructions allows the ValueEnumerator to be // unmodified as it reserves instruction IDs during contruction. diff --git a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp --- a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp +++ b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp @@ -513,7 +513,7 @@ } 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(V))) @@ -1070,24 +1070,14 @@ break; } case Type::PointerTyID: { - PointerType *PTy = cast(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: { diff --git a/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp b/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp --- a/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp +++ b/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp @@ -22,15 +22,15 @@ // 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(V)) { - if (!Inst->getResultElementType()->isOpaquePointerTy()) + if (!Inst->getResultElementType()->isPointerTy()) PointeeTy = Inst->getResultElementType(); } else if (auto *Inst = dyn_cast(V)) { PointeeTy = Inst->getAllocatedType(); @@ -45,7 +45,7 @@ } else if (const auto *Inst = dyn_cast(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(User)) { NewPointeeTy = Inst->getSourceElementType(); @@ -54,7 +54,7 @@ // 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; } @@ -85,7 +85,7 @@ SmallVector 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(B.getTerminator()); @@ -106,7 +106,7 @@ } for (auto &A : F.args()) { Type *ArgTy = A.getType(); - if (ArgTy->isOpaquePointerTy()) + if (ArgTy->isPointerTy()) ArgTy = classifyPointerType(&A, Map); NewArgs.push_back(ArgTy); } @@ -189,7 +189,7 @@ 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); @@ -200,7 +200,7 @@ for (const auto &B : F) { for (const auto &I : B) { - if (I.getType()->isOpaquePointerTy()) + if (I.getType()->isPointerTy()) classifyPointerType(&I, Map); } }