GlobalISel: Partially fix handling of byval arguments
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 5 Mar 2021 22:28:32 +0000 (17:28 -0500)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 12 Mar 2021 14:01:53 +0000 (09:01 -0500)
commit34471c30602b5deccca4ed7607721e819e26b39c
treefe0790d7005af4a5f347f79d1ff3d3cc7cdbc5c4
parentd44a3dad994bac112850e929e36f97e6963cd481
GlobalISel: Partially fix handling of byval arguments

This was essentially ignoring byval and treating them as a pointer
argument which needed to be loaded from. This should copy the frame
index value to the virtual register, not insert a load from the frame
index into the pointer value.

For AMDGPU, this was producing a load from the byval pointer argument,
to a pointer used for the byval arguments. I do not understand how
AArch64 managed to work before since it appears to be similarly
broken.

We could also change the ValueHandler API to avoid the extra copy from
the frame index, since currently it returns a new register.

I believe there is still an issue with outgoing byval arguments. These
should have a copy inserted in case the callee decided to overwrite
the memory.
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-sret.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-function-args.ll