Spill-range trimming introduces stack traffic in call-free loops
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- rust
- 領域
- compilers, performance
研究方向
Start with the spill-range trimming logic and reproduce the reported case using the supplied CLIF with clif-util compile --target aarch64-apple-darwin --set opt_level=speed --set regalloc_checker=true -p -D one-loop-then-helper.clif. Trace how trimming moves live-range ends across loop depths and inspect whether block-argument uses and block-parameter definitions are included. Done means the reproductions no longer generate per-iteration stack traffic while the related split-limit behavior remains distinct.
由索引模型根據 Issue 內容生成。
描述
issue for poor allocation for the following pseudocode:
acc = 0
n = input_count
while n > 0:
n -= 1
acc += 1
helper()
return acc
CLIF concrete example with a float accumulator on aarch64 (which spills):
function %one_loop_then_helper(i64, i64) -> f64 apple_aarch64 {
sig0 = () apple_aarch64
block0(v0: i64, v2: i64):
v3 = f64const 0.0
jump block1(v0, v3)
block1(v4: i64, v5: f64):
v6 = iconst.i64 0
v7 = icmp sgt v4, v6
brif v7, block2, block3
block2:
v8 = f64const 0x1.0000000000000p0
v9 = fadd v5, v8
v10 = iconst.i64 1
v11 = isub v4, v10
jump block1(v11, v9)
block3:
call_indirect sig0, v2()
return v5
}
(Compile with clif-util compile --target aarch64-apple-darwin --set opt_level=speed --set regalloc_checker=true -p -D one-loop-then-helper.clif)
This produces an unnecessary accumulator store on every loop iteration, in addition to a save immediately before the helper call. A second variant, where the accumulator controls loop termination and the helper is called afterward, produces both a store and a reload on every iteration.
Tracing these cases shows one split near the helper call. Trimming then moves the end of the live ranges back into the loop, introducing repeated stack traffic.
I’m not an expert on this code, but I’ve investigated it with GPT-6 Astra. Two possible improvements seem worth discussing:
- Stop trimming when it would enter a deeper loop than the split point, to avoid turning preservation outside a loop into per-iteration traffic.
- Account for block-argument uses and block-parameter definitions during trimming, rather than consulting only the instruction-use lists.
A small patch implementing the loop-depth restriction fixes both examples (and I'll post that PR soon). I had Astra prototype accounting for block-argument uses, and it also fixes this issue, though it requires more substantial work.
Related to #268/#270 in symptom, but these reproductions do not trigger the split-limit fallback. Neither approach removes the inner-loop spills in #268’s attached reproducer.
- 主要語言
- Rust
- 星號
- 271
- 分支
- 65
- 平均合併
- 2 天 22 小時
- 30 天內合併 PR
- 8
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
bytecodealliance/regalloc2 的其他 Issue
-
難度 5/5 一週以上 新手友好度 35/100
bytecodealliance/regalloc2#273 · 2 則留言 ·
-
A bundle split twice around call clobbers spills in the call-free loops it spans可能已有人在做 @EvanCarroll 於 36 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 42/100
bytecodealliance/regalloc2#268 · 4 則留言 ·
-
難度 4/5 3-5 天 新手友好度 48/100
bytecodealliance/regalloc2#265 · 9 則留言 ·
-
難度 5/5 一週以上 新手友好度 25/100
bytecodealliance/regalloc2#247 · 3 則留言 ·
-
難度 5/5 一週以上 新手友好度 25/100
bytecodealliance/regalloc2#206 · 2 則留言 ·
查看 bytecodealliance/regalloc2 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
area: settings bug Haiku review: no-score ui
難度 2/5 1-3 小時 新手友好度 78/100
MMFoundation/WallpaperMachine#346 ·
維護者通常 1 天內回覆
-
Make the HTTP server's keep-alive and headers timeouts configurable可能已有人在做 @mattgodbolt 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
compiler-explorer/compiler-explorer#9902 ·
維護者通常 1 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 68/100
jonathanong/no-mistakes#5490 ·
-
follow-up
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆