D-Programming-Language/dmd — pull request #2875 by yebblies (2013-11-24 15:58:36+00:00)
Title: Issue 8658 - Passing large structs to function b value causes stack corruption

So, the frame size doesn't fit in the immediate field of RET, so we have to do it manually.

But wait! If we just `add ESP, ...` we're throwing away the return value.

One option is
```
ADD ESP, Para.offset+REGSIZE
JMP [ESP-Para.offset-REGSIZE]
```
but I'm a little worried using JMP instead of RET will screw something up, branch prediction-wise.

Instead, put the return address in ECX and push it back before returning.

Is ECX ok? D/C/stdcall don't care about it at this point, but I'm not sure what else the backend might support.

@WalterBright

https://d.puremagic.com/issues/show_bug.cgi?id=8658