Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Allocation results in unnecessary moves around destructive operations

オープン
#265 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
compilers

調査の方向性

Start with the three cases in the regalloc2-repro repository, then compare their output with the reported fib.asm and fib.vcode files from the linked botlish audit. Trace the allocation around the destructive operations and verify that the unnecessary moves into r13 are reduced without regressing the repro cases.

索引モデルが issue の本文から書いたものです。

説明

I am implementing a Cranelift-based compiler stack for a new programming language where one design objective is efficient machine code. This is why early in development I am doing audits on the generated code to find out which inefficiencies are caused by the mid-end, which by the backend and which by missing language features.

In the asm dump of my fibonacci benchmark I saw this:

 177:	mov    rsi,r13
 17a:	mov    r14,rax
 17d:	sub    rsi,0x2
 181:	mov    r13,rsi
 184:	shl    rsi,1
 187:	mov    r13,rsi
 18a:	or     rsi,0x1
 18e:	mov    r13,rsi
 191:	mov    QWORD PTR [rbx+0x8],rsi

rsi is moved repeatedly into r13 for no discernible reason, then the content of rsi is moved into memory. r13 is later overwritten. So r13 was completely useless here.

The entire ASM is available in https://github.com/mwagner-webdev/botlish/blob/9cb689a/audit/native-scalar-asm/bench/fib.asm

This code was generated via Cranelift from this CLIF: https://github.com/mwagner-webdev/botlish/blob/9cb689a/audit/native-scalar-asm/bench/fib.vcode

I have a minimal repro here with three cases that illustrate the issue: https://github.com/mwagner-webdev/regalloc2-repro

I have zero experience with the workings of register allocators and it's all pretty fascinating. Obviously perfect allocation is impossible, but this looks like a clear-cut pathological case for which some heuristic may be found.

主要言語
Rust
スター
266
フォーク
54
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bytecodealliance/regalloc2 のほかの issue

bytecodealliance/regalloc2 の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。