[AMDGPU] Fix crash with 160-bit p7's by manually defining getPointerTy
authorKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Fri, 5 May 2023 22:03:40 +0000 (22:03 +0000)
committerKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Fri, 12 May 2023 15:57:53 +0000 (15:57 +0000)
commit53a4adc0deb29fcc1f907ea7bc151fdebecf406d
treecc0a1a35ffbb09729673309a7d507c9faccc2c19
parent3f6e4e5b6e9451adf0fc21f3c45076d987fbbfd2
[AMDGPU] Fix crash with 160-bit p7's by manually defining getPointerTy

While pointers in address space 7 (128 bit rsrc + 32 bit offset)
should be rewritten out of the code before IR translation on AMDGPU,
higher-level analyses may still call MVT getPointerTy() and the like
on the target machine. Currently, since there is no MVT::i160, this
operation ends up causing crashes.

The changes to the data layout that caused such crashes were D149776.

This patch causes getPointerTy() to return the type MVT::v5i32
and getPointerMemTy() to be MVT::v8i32. These are accurate types,
but mean that we can't use vectors of address space 7 pointers during
codegen. This is mostly OK, since vectors of buffers aren't supported
in LPC anyway, but it's a noticable limitation.

Potential alternative solutions include adjusting getPointerTy() to return
an EVT or adding MVT::i160 and MVT::i256, both of which are rather
disruptive to the rest of the compiler.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D150002
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.h
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces-vectors.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll [new file with mode: 0644]
llvm/test/Transforms/IndVarSimplify/AMDGPU/addrspace-7-doesnt-crash.ll [new file with mode: 0644]