Skip to content

CEP-0058: Source-Level Optimization Hints

Draft

Draft proposal for source-level optimization hints such as future @inline and @noinline. V1 defines no optimization-hint attributes.

Summary

Catalyst should eventually decide whether source can request or forbid selected optimizations through explicit hints.

V1 leaves optimization decisions to the compiler and backend. The V1 prelude does not define @inline, @noinline, or any equivalent optimization-hint attribute.

Example

Possible future shape:

@inline
fn small_helper(x: f32) f32 {
  return x * x
}

@noinline
fn cold_path() void {
}

The proposal must decide whether these are best modeled as attributes, compiler options, profile-guided inputs, or ordinary backend policy.

Motivation

Performance-sensitive code sometimes needs a way to communicate intent to the optimizer. Inline and no-inline controls are common examples, but they are also easy to overpromise. A source hint might affect code size, debug behavior, ABI boundaries, compile time, and backend portability.

Catalyst should avoid adding source-level optimization promises until the optimizer and backend model can say what the promise means.

Proposed Direction

The future design should cover:

  • whether inline and noinline are attributes, keywords, pragmas, or build-policy settings;
  • whether hints are advisory or mandatory;
  • valid target kinds, such as functions, methods, function values, or call sites;
  • interaction with generic instantiation, dynamic dispatch, exported symbols, and C ABI boundaries;
  • diagnostics for contradictory hints;
  • reflection, IR metadata, and tooling display;
  • portability across the interpreter backend, future LLVM backend, and other backends.

V1 Compatibility

V1 has no source-level optimization-hint attributes. Unqualified @inline and @noinline are not prelude names and fail through normal attribute name resolution unless user code explicitly defines or imports providers with those names.

V1 attribute target expansion is tracked by CEP-0030. Attribute semantic effects beyond V1 setters are tracked by CEP-0031. Advanced backend and optimizer work is tracked by CEP-0052.