fix(0109): hoist all per-instruction allocas to the function entry block
An alloca built at its use site re-executes on every pass through that block, and LLVM reclaims allocas only at ret — so loop-body locals, nested-loop index slots, and emitter spill temps (ig.tmp, sret slots, ABI coercion temps, byval materialization) grew the stack per iteration and long loops segfaulted on stack exhaustion. New LLVMEmitter.buildEntryAlloca inserts after existing entry-block allocas and restores the builder position; every LLVMBuildAlloca site reachable during instruction emission now routes through it. Initialization stores stay at the use site (per-iteration re-init is unchanged), and entry slots become mem2reg-promotable. The 35 .ir snapshot diffs are pure alloca position moves (type multisets verified identical per file). Regression: examples/0047-basic-loop-local-stack-reuse.sx (segfaulted pre-fix on both the 1M-iteration body-local loop and the 3M-iteration nested loop).
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
sum=499999500000
|
||||
n=3000000
|
||||
Reference in New Issue
Block a user