Page MenuHomePhabricator

[AIX][PPC] Implement caller byval arguments in stack memory

Authored by cebowleratibm on Apr 6 2020, 12:19 PM.



This patch adds support to initialize byval arguments in stack memory when required.

On AIX, available GPRs are consumed for passing byval arguments. When available GPRs are exhausted, any remaining bytes of byval arguments are written to the parameter save area on the stack.

Note that when an argument passes in both registers and the stack, memory is reserved in the parameter save area for the entire object. Only the portion that does not reside in registers needs to be written by the caller. On entry, the callee cannot expect that the portion of the byval argument that passed in register is initialized in the parameter save area.

Diff Detail

Event Timeline

cebowleratibm created this revision.Apr 6 2020, 12:19 PM
hubert.reinterpretcast retitled this revision from [AIX][PPC} Implement caller byval arguments in stack memory to [AIX][PPC] Implement caller byval arguments in stack memory.Apr 6 2020, 1:11 PM

Can you make this dependent on rebase/repost.

Rebased to account for changes committed in D76902.

sfertile added inline comments.Apr 13 2020, 10:27 AM

'I != E' shouldn't be part of the while loops condition. If you really want a sanity check on the value you can have an assertion inside the while loop after I is incremented (And LoadOffset is incremented) that checks that either 'I' is not equal to 'E' or we have copied the whole ByVal argument.


Missing the nop for toc-restore, and loading of arguments for the call to test_byval_mem2 for both 32-bit and 64-bit check directives.


Check for the nop after the call to memcpy

cebowleratibm marked 3 inline comments as done.

Addressed unnecessary iterator check while looping on expect byval argument registers.

cebowleratibm added inline comments.Apr 13 2020, 8:42 PM

In an attempt to keep the CC tests shorter and more focussed I had opted to omit these and check only for the instuctions that set up the byval argument to the call. If you feel strongly that these should be included in the check I can bring them back.


Also omitted to reduce size.

sfertile added inline comments.Apr 14 2020, 7:25 AM

I think its important to show that the memcpy call happens completely outside the call sequence we are lowering since the call to memcpy that gets inserted would clobber the volatile registers we are using to pass the arguments. Its also worth it to show that the toc-restore nop gets emitted as that is part of the call sequence when the target is to an external function.

Added MIR expect output for tests that expect calls to memcpy to ensure the memcpy calls are generated independently from caller register setup.

cebowleratibm marked 3 inline comments as done.Apr 14 2020, 2:02 PM
sfertile accepted this revision.Apr 15 2020, 10:52 AM

Thanks for the test updates. LGTM.

This revision is now accepted and ready to land.Apr 15 2020, 10:52 AM
This revision was automatically updated to reflect the committed changes.
cebowleratibm marked an inline comment as done.