diff options
author | Vyacheslav Levytskyy <vyacheslav.levytskyy@intel.com> | 2024-06-11 21:23:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 21:23:32 +0200 |
commit | 65614605dd99af80cc2218b8a43b0b0f6aebe11a (patch) | |
tree | 6316b217d6dea812cdfce7b91bc0bffef9523350 /llvm/lib/Target/SPIRV | |
parent | c6d85baf9f12f69915559aff5ed6c48b63daafdd (diff) | |
download | llvm-65614605dd99af80cc2218b8a43b0b0f6aebe11a.zip llvm-65614605dd99af80cc2218b8a43b0b0f6aebe11a.tar.gz llvm-65614605dd99af80cc2218b8a43b0b0f6aebe11a.tar.bz2 |
[SPIR-V] Ensure that DuplicatesTracker is working with TypedPointers pointee types (#94952)
This PR is a tweak to ensure that DuplicatesTracker is working with
TypedPointers pointee types rather than with original llvm's untyped
pointers. This enforces DuplicatesTracker promise to avoid emission of
several identical OpTypePointer instructions.
Diffstat (limited to 'llvm/lib/Target/SPIRV')
-rw-r--r-- | llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h index 2ec3fb3..3c8405f 100644 --- a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h +++ b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h @@ -16,6 +16,7 @@ #include "MCTargetDesc/SPIRVBaseInfo.h" #include "MCTargetDesc/SPIRVMCTargetDesc.h" +#include "SPIRVUtils.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" @@ -285,10 +286,13 @@ public: TT.add(Ty, MF, R); } - void add(const Type *PointerElementType, unsigned AddressSpace, + void add(const Type *PointeeTy, unsigned AddressSpace, const MachineFunction *MF, Register R) { - ST.add(SPIRV::PointerTypeDescriptor(PointerElementType, AddressSpace), MF, - R); + if (isUntypedPointerTy(PointeeTy)) + PointeeTy = + TypedPointerType::get(IntegerType::getInt8Ty(PointeeTy->getContext()), + getPointerAddressSpace(PointeeTy)); + ST.add(SPIRV::PointerTypeDescriptor(PointeeTy, AddressSpace), MF, R); } void add(const Constant *C, const MachineFunction *MF, Register R) { @@ -320,10 +324,13 @@ public: return TT.find(const_cast<Type *>(Ty), MF); } - Register find(const Type *PointerElementType, unsigned AddressSpace, + Register find(const Type *PointeeTy, unsigned AddressSpace, const MachineFunction *MF) { - return ST.find( - SPIRV::PointerTypeDescriptor(PointerElementType, AddressSpace), MF); + if (isUntypedPointerTy(PointeeTy)) + PointeeTy = + TypedPointerType::get(IntegerType::getInt8Ty(PointeeTy->getContext()), + getPointerAddressSpace(PointeeTy)); + return ST.find(SPIRV::PointerTypeDescriptor(PointeeTy, AddressSpace), MF); } Register find(const Constant *C, const MachineFunction *MF) { |