Skip to content

Commit c8d4053

Browse files
authored
[SPIRV] Get pointer size from datalayout (#66096)
Get the pointer size from the datalayout via the TargetMachine and remove the helper function that hardcoded it. This fixes an issue caused by mismatched pointer sizes between the two for logical SPIR-V, since the computePointerSize function still defaulted to 32-bit ptr sizes.
1 parent bc5dac1 commit c8d4053

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,14 @@ static bool isAtLeastVer(uint32_t Target, uint32_t VerToCompareTo) {
4747
return Target == 0 || Target >= VerToCompareTo;
4848
}
4949

50-
static unsigned computePointerSize(const Triple &TT) {
51-
const auto Arch = TT.getArch();
52-
// TODO: unify this with pointers legalization.
53-
assert(TT.isSPIRV());
54-
55-
if (Arch == Triple::spirv64)
56-
return 64;
57-
58-
// TODO: this probably needs to be revisited:
59-
// AFAIU Logical SPIR-V has no pointer size. So falling-back on ID size.
60-
// Addressing mode can change how some pointers are handled
61-
// (PhysicalStorageBuffer64).
62-
return 32;
63-
}
64-
6550
SPIRVSubtarget::SPIRVSubtarget(const Triple &TT, const std::string &CPU,
6651
const std::string &FS,
6752
const SPIRVTargetMachine &TM)
6853
: SPIRVGenSubtargetInfo(TT, CPU, /*TuneCPU=*/CPU, FS),
69-
PointerSize(computePointerSize(TT)), SPIRVVersion(0), OpenCLVersion(0),
70-
InstrInfo(), FrameLowering(initSubtargetDependencies(CPU, FS)),
71-
TLInfo(TM, *this), TargetTriple(TT) {
54+
PointerSize(TM.getPointerSizeInBits(/* AS= */ 0)), SPIRVVersion(0),
55+
OpenCLVersion(0), InstrInfo(),
56+
FrameLowering(initSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
57+
TargetTriple(TT) {
7258
// The order of initialization is important.
7359
initAvailableExtensions();
7460
initAvailableExtInstSets();

0 commit comments

Comments
 (0)