Zero alloc fix flambda2 invalid no return take2#2810
Conversation
instead of in deadcode elimination
…lse during deadcode pass" This reverts commit 51e24f4.
|
This approach seems fine (for now), but do we know how often the extra DCE pass will be needed? I wouldn't be surprised if |
it's only triggered for function explicitly annotated with |
xclerc
left a comment
There was a problem hiding this comment.
As briefly discussed off-line, we are mildly
worried of the performance implications
of the mach version, but it should be
removed soon-ish.
Once we have #2813, we can use this information to remove functions that are kept alive only for zero_alloc check instead of modifying them here. I expect that this condition will cover most of hte cases (not all) and then we can avoid reallocating if a function does not contain a call to |
Fix compilation failure caused by the special treatment of
caml_flambda2_invalidforzero_alloc(added in #2112) in the presence of unboxed types.The middle end generates
caml_flambda2_invalidwithreturn=falseand return type set totyp_void. InSelectgen, we sometimes change it toreturn=trueandtyp_int, but the context may not be compatible with the return type ofint. This should not matter because the code is unreachable, but it triggers an assertion:The proposed fix updates
return=falseat the end ofZero_alloc_checkon all these special primitives.Deadcodepass to eliminate the illegal moves before register allocation. Changingreturnsfield is expensive because we reallocate all functions annotated with zero_alloc. A cheaper alternative (see reverted commit) is to directly changeDeadcodepass.A proper fix would be to let the middle end eliminate dead functions even if they are annotated with zero_alloc assertions (i.e., revert #1378), and instead propagate zero_alloc assertions to instructions, similarly to the way we do for assume using debug info, but currently debug info may not be reliable enough.