Use templated lowering for _d_newarray*#4965
Use templated lowering for _d_newarray*#4965Albert24GG wants to merge 1 commit intoldc-developers:masterfrom
_d_newarray*#4965Conversation
|
Thx! I don't really recall whether the GC2Stack regressions were the reason, but they are definitely a problem. - We have an extra LLVM pass that looks for GC allocations that don't escape their scope (after inlining & optimizing), and convert them to stack allocations instead. This was all based on the old non-templated druntime hooks, based on TypeInfos etc. So for instance, this now fails: Lines 10 to 18 in 9db6d95 as the GC2Stack pass doesn't eliminate the superfluos GC allocation anymore when switching to the templated lowering. |
|
@kinke I took a look over the GC2Stack pass and I see it is indeed one of the last passes. The current implementation that uses the TypeInfo version is based on the fact that the call itself will not be inlined since the function is extern and needs to be linked. Now when switching to the templated version, the pass does not find any call to |
|
Once everything GC-related is templated (or at least the stuff that makes sense), the GC2Stack would need to be overhauled, incl. accounting for the new unstable mangled names and populating the TypeInfo LLVM meta data (that we emit in IR for the later GC2Stack pass) differently etc. That's probably a bigger task, and I think only makes sense tackling once all hooks have been revised. In the meantime, here for array GC allocations, I went the conservative route of using the old non-templated hook to keep GC2Stack working, as the druntime helpers are still available. |
|
@kinke Okay, then I'll leave this PR open until everything is ready so that the idea does not get lost. |
I am not sure why, but the dynamic array creation still relies on the old hooks, despite having templated versions of
_d_newarray*that the expressions are lowered to inexpressionsem. The old hooks are soon going to be removed, because they were only used by AA hooks but now that is no longer the case.I did not remove
DtoNewDynArraysince it is still used for ArrayLiteralExp,at least until the templated version of_d_arrayliteralTXwill be integrated.