[PATCH] D98148: GlobalISel: Fix marking byval arguments as immutable
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 7 14:48:15 PST 2021
arsenm added a comment.
In D98148#2610252 <https://reviews.llvm.org/D98148#2610252>, @aemerson wrote:
> Am I misunderstanding the meaning of byval? From the langref:
>
>> The attribute implies that a hidden copy of the pointee is made between the caller and the callee, so the callee is unable to modify the value in the caller. This attribute is only valid on LLVM pointer arguments. It is generally used to pass structs and arrays by value, but is also valid on pointers to scalars. The copy is considered to belong to the caller not the callee (for example, readonly functions should not write to byval parameters).
>
> From that, I'd expect byval stack slots to be *immutable*.
It's unable to modify the *original* value in the caller. The caller is responsible for copying the incoming value into a scratchpad the callee is allowed to write into. I'm not aware of any situations where the IR will produce writes into a byval area, but it is technically allowed. SelectionDAG does not mark byval arguments as immutable. I also believe GlobalISel is broken since the byval lowering is currently not inserting the required copy in the call setup
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98148/new/
https://reviews.llvm.org/D98148
More information about the llvm-commits
mailing list