Skip to content

[SPIR-V] Ensure that DuplicatesTracker is working with TypedPointers pointee types #94952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -285,10 +286,13 @@ class SPIRVGeneralDuplicatesTracker {
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) {
Expand Down Expand Up @@ -320,10 +324,13 @@ class SPIRVGeneralDuplicatesTracker {
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) {
Expand Down
Loading