Skip to content

Directive default cannot opt a binding out of derived inline directives #325

Description

@Unisay

Problem

Directive derivation (#241) gives specialization bindings — top-level bindings applying an @inline arity=N target to some of its arguments — a derived policy: arity=(N-k) while under-applied, always-inline once saturated. The derivation skips any binding carrying an explicit root directive (never/always/arity=N), but a written default cannot serve as that opt-out: resolveModes (the directive-precedence resolver in Language.PureScript.Backend.IR.Inliner) folds a winning default mode to no annotation before translation, so by the time derivedInlinePolicy inspects the uber-module the binding is indistinguishable from an unannotated one and derivation proceeds. The only working opt-out today is never, which is stronger than intended — it also pins the binding against every other paste path.

Approach

First decide the semantics, then plumb it. The README defines default as "resets the target to the built-in heuristics", and derivation can be read as part of the heuristics — under that reading current behavior is correct and the gap is expressiveness only. The leaning is the other way: an explicit directive naming a specific binding expresses intent about that binding, so default should also mask derivation. Implementation once decided: preserve the mask through translation — either a Default constructor on Annotation that collectInlinePolicy gathers into a policyDefault ∷ Set QName and that every other consumer treats as no annotation, or a masked-target set threaded from mkModule through the linker — and consult it in the hasRootDirective guard of derivedInlinePolicy.

Prerequisites / Relations

Builds on #241 (derived directives) and the #232 directive DSL. Independent of the #242 directive pack.

Verification / Measurement

A pipeline spec: a specialization of an arity=N target annotated @inline spec default keeps its call sites calling the shared binding (no derived paste), while an unannotated sibling specialization still derives. Directive-source precedence (local pragma vs file vs export) over the default entry stays as documented.

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