Skip to content

Fix WebAssemblySpillPointers: use call-result heuristic instead of hasGC() guard#7

Draft
Copilot wants to merge 3 commits intorelease/16.xfrom
copilot/fix-webassembly-spill-pointers
Draft

Fix WebAssemblySpillPointers: use call-result heuristic instead of hasGC() guard#7
Copilot wants to merge 3 commits intorelease/16.xfrom
copilot/fix-webassembly-spill-pointers

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 2, 2026

The WebAssemblySpillPointers pass runs unconditionally at O2+, adding spill stack slots that inflate frame sizes and break userstack.ll (e.g. non_mem_use expects 48-byte frame). The previous fix using hasGC() was incorrect — Boehm GC doesn't use LLVM GC strategy annotations, so hasGC() is always false and the pass would never activate for its intended use case.

Changes

  • Removed hasGC() guard — wrong abstraction for conservative GC
  • Added HasCallResultPointer heuristic in Phase 1 — tracks whether any call in the function returns a potential pointer (i.e., the function calls allocation routines like GC_malloc)
  • Early return after Phase 1 if no pointer-returning calls exist — functions calling only void-returning helpers (like ext_func) skip spilling entirely

When a pointer-returning call is present, ALL potential pointers (arguments, loads, derived values) are still spilled across all calls, preserving full conservative GC correctness.

// cons() calls GC_malloc (returns ptr) → pass activates, spills n AND xs
// non_mem_use() calls ext_func (returns void) → pass skips, frame unchanged

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ut GC strategy

Co-authored-by: PLUTOFX <110596339+PLUTOFX@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unexpected failure during ninja check-llvm Guard WebAssemblySpillPointers pass with hasGC() check Mar 2, 2026
…SpillPointers

The previous hasGC() check was wrong because Boehm GC (conservative GC)
does not use LLVM's GC strategy annotations. Functions using Boehm GC
just call GC_malloc/GC_gcollect as regular C calls.

Replace with a heuristic: only activate spilling when the function has
at least one call that returns a potential pointer (indicating it may
call allocation functions like GC_malloc). When such a call exists,
spill ALL potential pointers (arguments, loads, derived values) across
all calls. Functions with only void-returning calls (like userstack.ll's
ext_func) are correctly skipped.

Co-authored-by: PLUTOFX <110596339+PLUTOFX@users.noreply.github.com>
Copilot AI changed the title Guard WebAssemblySpillPointers pass with hasGC() check Fix WebAssemblySpillPointers: use call-result heuristic instead of hasGC() guard Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants