Skip to content

Make default-pack directives monotone: gate saturated pastes without vetoing the heuristics #330

Description

@Unisay

Problem

An arity=N directive replaces the built-in heuristics for its target everywhere: the name is pasted at sites applying at least N arguments, and vetoed at every other decision point — the uncurry split, whole-binding inlining, and the dictionary-projection resolution. That totality is right when a user wrote the directive (it expresses intent), but the default pack (#242) is compiler-shipped, and at sites the heuristics handled better the pack now forces a worse shape. Concrete instance from PR #327, Golden.ArrayOfUnits.Test/golden.lua: inside the Effect functor dictionary, map = liftA1 contains pure applicativeEffect; the heuristics used to chase that projection to the stored field value, emitting the direct reference Effect_pureE(f), but under the pack's Control.Applicative.pure arity=1 the site pastes to the field read Effect_applicativeEffect.pure(f) and stops — the Effect dictionaries are a lazily-tied recursive knot the projection resolver cannot look through after the paste. Same family: Golden.StringCodePoints +2% from rematerialized wrappers, Golden.Issue37 and Golden.CprState shifting a few bytes each. During pack calibration, roughly twenty candidate entries (comparison operators, numeric accessors, Control.Monad.ap) had to be dropped for regressing the corpus this way, so the strict semantics also caps how much of the prelude the pack can safely cover.

Approach

Track directive provenance in InlinePolicy: entries sourced from the default pack contribute the saturated-paste rule (inlineSaturatedCall) but do not join uncurryVeto and do not veto the heuristic paths, so wherever the heuristics previously produced a better shape they still fire. Explicit sources — module-header pragmas and the --directives file — keep today's strict semantics unchanged. The pack becomes monotone by construction: with it enabled the output is never worse than without it.

Prerequisites / Relations

Follow-up to #242 / PR #327. Would let the entries dropped during #327's calibration be reconsidered, and de-risks extending the pack to more libraries.

Verification / Measurement

Property at corpus level: with the soft tier, no golden.lua grows relative to a pack-disabled build (assert by diffing a mempty-pack compile against the shipped-pack compile in the harness); the ArrayOfUnits line returns to Effect_pureE(f_S_1); all present wins retained byte-for-byte; eval goldens unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    OptimisationA Compiler Optimisationarea: irIR / optimizer / DCE / inlinerenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions