julia
c05b68f0 - Don't inline generated functions if we can't invoke their generator (#59018)

Commit
111 days ago
Don't inline generated functions if we can't invoke their generator (#59018) This PR disables inlining (via an outer `src_inlining_policy` method) for method instances obtained from `@generated` methods if we cannot invoke their generator during compilation, deferring their execution to runtime via dynamic dispatch. Generated functions may be called with arguments that are not fully inferrable, yet we might inline them. The lack of concretely inferred argument types can cause the generator function to not be invoked `may_invoke_generator(mi) === false`, which causes its fallback definition to be executed when one is available to expand its body (the `else` branch of a `if @generated` construct, if present). However, fallback definitions were intended to enable more accurate type inference, but not to be actually used for execution; they will typically be slower, and in this case, it is best to defer the generation of the method body to runtime, where the generator can be invoked with concrete argument types. Implements https://github.com/JuliaLang/julia/pull/59013#issuecomment-3075399340, fixing #58915.
Author
Parents
Loading