GlobalISel: Restructure argument lowering loop in handleAssignments
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 8 Jul 2020 13:11:53 +0000 (09:11 -0400)
committerMatt Arsenault <arsenm2@gmail.com>
Wed, 22 Jul 2020 17:31:11 +0000 (13:31 -0400)
commitb98f902f1877c3d679f77645a267edc89ffcd5d6
treeb0704c05fb15904806814e289e4d072782a15f67
parentd523a8d9797f3962b4af8331eea2ae220fb7111f
GlobalISel: Restructure argument lowering loop in handleAssignments

This was structured in a way that implied every split argument is in
memory, or in registers. It is possible to pass an original argument
partially in registers, and partially in memory. Transpose the logic
here to only consider a single piece at a time. Every individual
CCValAssign should be treated independently, and any merge to original
value needs to be handled later.

This is in preparation for merging some preprocessing hacks in the
AMDGPU calling convention lowering into the generic code.

I'm also not sure what the correct behavior for memlocs where the
promoted size is larger than the original value. I've opted to clamp
the memory access size to not exceed the value register to avoid the
explicit trunc/extend/vector widen/vector extract instruction. This
happens for AMDGPU for i8 arguments that end up stack passed, which
are promoted to i16 (I think this is a preexisting DAG bug though, and
they should not really be promoted when in memory).
llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp