Skip to content

Commit 0550555

Browse files
Dale-Blackclaude
andcommitted
Fix Pass 3: skip local allocation for globals, slots, assignments
In optimize=false IR, GlobalRef and SlotNumber SSAs should always inline (not get _vN locals). This enables proper SSA callee resolution for push!, sin, etc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 74e0fda commit 0550555

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/compiler/codegen.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ function compile_function(ctx::JSCompilationContext)
4747

4848
# === Pass 3: Pre-allocate locals for SSA values used across blocks ===
4949
# Any SSA value referenced from a different block needs a local
50+
# Skip globals, constants, slot reads — these always inline
5051
for (i, stmt) in enumerate(code)
52+
# Skip statements that should always inline (not get a local)
53+
if stmt isa GlobalRef || stmt isa Core.SlotNumber
54+
continue
55+
end
56+
# Skip slot assignments (the slot variable IS the local)
57+
if stmt isa Expr && stmt.head === :(=)
58+
continue
59+
end
5160
if stmt isa Expr && stmt.head in (:call, :invoke, :new)
5261
# Check if this value is used anywhere
5362
for (j, other) in enumerate(code)

0 commit comments

Comments
 (0)