[llvm] 245073a - [DirectX] Remove uses of isOpaquePointerTy(). NFC
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 14:28:24 PDT 2023
Author: Justin Bogner
Date: 2023-07-19T14:28:05-07:00
New Revision: 245073ac80b3a2ab942ac3c81126c14037501945
URL: https://github.com/llvm/llvm-project/commit/245073ac80b3a2ab942ac3c81126c14037501945
DIFF: https://github.com/llvm/llvm-project/commit/245073ac80b3a2ab942ac3c81126c14037501945.diff
LOG: [DirectX] Remove uses of isOpaquePointerTy(). NFC
isOpaquePointerTy now returns true for all pointers, so we can replace
these with isPointerTy().
Added:
Modified:
llvm/lib/Target/DirectX/DXILPrepare.cpp
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index d339430d455fea..660ca415b1a469 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -127,9 +127,6 @@ class DXILPrepareModule : public ModulePass {
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
index 328bea555190e0..2c321f4a79afc0 100644
--- a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
+++ b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
@@ -513,7 +513,7 @@ unsigned DXILBitcodeWriter::getEncodedBinaryOpcode(unsigned Opcode) {
}
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)))
@@ -1070,24 +1070,14 @@ void DXILBitcodeWriter::writeTypeTable() {
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: {
diff --git a/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp b/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
index eea89941983bb0..97b7a41cac6da3 100644
--- a/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
@@ -22,15 +22,15 @@ namespace {
// 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();
@@ -45,7 +45,7 @@ Type *classifyPointerType(const Value *V, PointerTypeMap &Map) {
} 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();
@@ -54,7 +54,7 @@ Type *classifyPointerType(const Value *V, PointerTypeMap &Map) {
// 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 @@ Type *classifyFunctionType(const Function &F, PointerTypeMap &Map) {
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());
@@ -106,7 +106,7 @@ Type *classifyFunctionType(const Function &F, PointerTypeMap &Map) {
}
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 @@ static void classifyGlobalCtorPointerType(const GlobalVariable &GV,
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 @@ PointerTypeMap PointerTypeAnalysis::run(const Module &M) {
for (const auto &B : F) {
for (const auto &I : B) {
- if (I.getType()->isOpaquePointerTy())
+ if (I.getType()->isPointerTy())
classifyPointerType(&I, Map);
}
}
More information about the llvm-commits
mailing list