amd64-windows: Fix funcall with by-pointer arguments

Joel Brobecker
2012-10-24T17:23:51Z

Hello,

I realized a while ago that I completely misunderstood the amd64-windows
API regarding arguments that are passed by pointer. The calling
convention is published there:

http://msdn.microsoft.com/en-us/library/zthk2dkh(v=vs.80).aspx

Aggregates whose size is not 8/16/32/64 should be passed by pointer,
and what that means is that the caller is expected to make a copy
of the object, and pass its address as the argument. This is different
from passing the argument through the stack and the stack address
at the same time.

In particular, when you have a function call which involves one of
those by-pointer argument that follows an on-stack argument, the
incorrect method would puth the by-pointer argument on the stack
after the first argument, thus screwing up the offset of the first
argument relative to the caller's frame address, etc.

This patch series fixes the problem by:
1. Reverting the first (incorrect) attempt at handling by-pointer
arguments;
2. Add handling of by-pointer arguments again.

Tested on x86_64-windows with AdaCore's testsuite, and on x86_64-linux
using the official testsuite.