Spill-range trimming introduces stack traffic in call-free loops
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- compilers, performance
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 271
- Fork
- 65
- Merge trung bình
- 2 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytecodealliance/regalloc2
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
bytecodealliance/regalloc2#273 · 2 bình luận ·
-
A bundle split twice around call clobbers spills in the call-free loops it spansCó thể đã có người làm @EvanCarroll đã nhận 36 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
bytecodealliance/regalloc2#268 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
bytecodealliance/regalloc2#265 · 9 bình luận ·
-
Modeling subregister aliasingĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
bytecodealliance/regalloc2#247 · 3 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
bytecodealliance/regalloc2#206 · 2 bình luận ·
Tất cả issue của bytecodealliance/regalloc2
Issue tương tự
-
Test connection's password prompt says the password is never saved, also for a keychain profileĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: settings bug Haiku review: no-score ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MMFoundation/WallpaperMachine#346 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Make the HTTP server's keep-alive and headers timeouts configurableCó thể đã có người làm @mattgodbolt đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
compiler-explorer/compiler-explorer#9902 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jonathanong/no-mistakes#5490 ·
-
follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày