Skip to content

arm: functions needing the AAPCS stack-arg path (>8 scalar params, or any 64-bit stack param) are skipped, not lowered #503

Description

@avrabe

Summary

On the arm backend, synth compile skips (emits no code for) any function whose call signature needs the AAPCS stack-argument path — i.e. more than 8 scalar params, or any 64-bit (i64/f64) param that would land on the stack. The function is dropped from the ELF rather than lowered. This is a completeness gap on the road to self-contained firmware (and to the #494 0.7× goal): every reachable function must lower.

Verified on synth v0.15.1 (released aarch64-apple-darwin binary).

Minimal repro

sum10.wat — 10 i32 params:

(module
  (func (export "sum10") (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32)
    local.get 0 local.get 1 i32.add local.get 2 i32.add local.get 3 i32.add
    local.get 4 i32.add local.get 5 i32.add local.get 6 i32.add local.get 7 i32.add
    local.get 8 i32.add local.get 9 i32.add))
$ synth compile sum10.wat -t cortex-m3 --cortex-m -o /tmp/r.elf
warning: skipping function 'sum10': backend 'arm' failed: ... Synthesis failed:
  #359: function has 10 params; the AAPCS stack-argument path supports at most 8 scalar params
Error: no functions compiled successfully (1 skipped) — nothing to emit

mix.wat — 5 params, one i64 on the stack:

(module
  (func (export "mix") (param i32 i32 i32 i32 i64) (result i64)
    local.get 4 local.get 0 i64.extend_i32_u i64.add))
warning: skipping function 'mix': ... Synthesis failed:
  #359: function has 5 params including a 64-bit (i64/f64) param; the AAPCS stack-argument path supports only i32 params

Control: the same shape with 8 i32 params compiles cleanly and emits an ELF.

Impact (real workload)

Compiling the falcon flight component (falcon-flight-v1.94 → meld-fused → loom-optimized → synth compile -t cortex-m3), 3 of the 29 skipped functions fail on exactly this: func_57 (10 params), func_58 (25 params), func_163 (5 params incl. a 64-bit). These survive meld/loom as legitimate lowered helpers; the arm backend just can't pass their args. (The other 26 skips are the known float #369 (23) and register-exhaustion (3) buckets — tracked separately.)

Two asks

  1. Lower these per AAPCS — r0–r3 for the first 4 words, the rest spilled to the stack (with 8-byte alignment for 64-bit params), and the i64/f64 stack-passing case. This unblocks 3 falcon functions today and is on the critical path for self-contained firmware + #494.
  2. Fix the diagnostic label — the warning cites #359, which is closed and about a different bug (sret first-arg shift). There's no open issue for the stack-arg-path limitation itself; this is it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions