Implement ABI stuff for -preview=in#3578
Conversation
|
I am very worried about the semantic meaning of My worry is that with this PR, we combine the decision that we must pass by reference to not violate D language semantics, with the decision that we may pass by ref as an optimization (without changing language semantics). Edit: looking a bit closer at the PR, I see that my fear is not justified (all was behind preview=in before aswell). |
|
Yeah, this just implements the ABI-specific part for LDC (well, at least the 3 major ABIs, but the 32-bit x86 ABI is IMO okay too this way). The upstream ABI part for DMD needs work - I've promised to implement it, so the frontend changes in here will probably be upstreamed more or less as-is. |
This is hard to prove (could be aliased via global state as well), and explicit |
Ping me when you make that PR. |
This is the promised follow-up on dlang#11000 and makes DMD exploit the specifics of the few supported ABIs (Win64, SysV x86_64, 32-bit x86). It also almost perfectly matches the proposed LDC implementation in ldc-developers/ldc#3578 (just a minor divergence for Win64 and dynamic arrays, but in that point the LDC and DMD Win64 ABI diverges in general).
This is the promised follow-up on dlang#11000 and makes DMD exploit the specifics of the few supported ABIs (Win64, SysV x86_64, 32-bit x86). It also almost perfectly matches the proposed LDC implementation in ldc-developers/ldc#3578 (just a minor divergence for Win64 and dynamic arrays, but in that point the LDC and DMD Win64 ABI diverges in general).
This is the promised follow-up on dlang#11000 and makes DMD exploit the specifics of the few supported ABIs (Win64, SysV x86_64, 32-bit x86). It also almost perfectly matches the proposed LDC implementation in ldc-developers/ldc#3578 (just a minor divergence for Win64 and dynamic arrays, but in that point the LDC and DMD Win64 ABI diverges in general).
I expect this to be slightly more performant than the previous behavior, where a delegate was treated like a corresponding struct, passed via hidden pointer and returned via sret. The primary motivation is a smooth preparation for PR ldc-developers#3578 - in order to allow people to experiment with `-preview=in` without recompiling druntime and Phobos, `in` slices and delegates must not be passed by-ref with `-preview=in` (see dlang/dmd#11828). This would have required a special case for delegates on Win64, which is IMO better handled this way.
I expect this to be slightly more performant than the previous behavior, where a delegate was treated like a corresponding struct, passed via hidden pointer and returned via sret. The primary motivation is a smooth preparation for PR ldc-developers#3578 - in order to allow people to experiment with `-preview=in` without recompiling druntime and Phobos, `in` slices and delegates must not be passed by-ref with `-preview=in` (see dlang/dmd#11828). This would have required a special case for delegates on Win64, which is IMO better handled this way.
This is the promised follow-up on dlang#11000 and makes DMD exploit the specifics of the few supported ABIs (Win64, SysV x86_64, 32-bit x86). It also almost perfectly matches the proposed LDC implementation in ldc-developers/ldc#3578 (just a minor divergence for Win64 and dynamic arrays, but in that point the LDC and DMD Win64 ABI diverges in general).
…ers (#3609) I expect this to be slightly more performant than the previous behavior, where a delegate was treated like a corresponding struct, passed via hidden pointer and returned via sret. The primary motivation is a smooth preparation for PR #3578 - in order to allow people to experiment with `-preview=in` without recompiling druntime and Phobos, `in` slices and delegates must not be passed by-ref with `-preview=in` (see dlang/dmd#11828). This would have required a special case for delegates on Win64, which is IMO better handled this way.
This is the promised follow-up on #11000 and makes DMD exploit the specifics of the few supported ABIs (Win64, SysV x86_64, 32-bit x86). It also almost perfectly matches the proposed LDC implementation in ldc-developers/ldc#3578 (just a minor divergence for Win64 and dynamic arrays, but in that point the LDC and DMD Win64 ABI diverges in general).
a83a362 to
153c5f6
Compare
I.e., the ABI-specific decision for which parameter types to prefer passing a ref over a value. The x86_64 and AArch64 ABIs are pretty clear - use a ref if the POD type cannot be passed in registers. For all others, use a simple default heuristic based on the type size - if larger than 2 machine words, use a ref. Note that this includes x87 `real` for the 32-bit x86 ABI.
I.e., the ABI-specific decision for which parameter types to prefer passing a ref over a value.
The x86_64 and AArch64 ABIs are pretty clear - use a ref if the POD type cannot be passed in registers. For all others, use a simple default heuristic based on the type size - if larger than 2 machine words, use a ref. Note that this includes x87
realfor the 32-bit x86 ABI.