[Migrated] spirv-std inline `asm!` should use `MaybeUninit<T>` instead of `let mut result = T::default();`.
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 3.4k
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1007
Old labels: t: enhancement,a: asm
Originally creatd by eddyb on 2023-03-17T20:01:45Z
We have a few different ways to extract results from asm!:
- old unsound approach (UB because of
OpReturnValue, so it's getting replaced)
asm! {
"%result = ...",
"OpReturnValue %result",
options(noreturn),
}
- old approach (sound, but requires
T: Default)
let mut result = T::default();
asm!(
"%result = ...",
"OpStore {result} %result",
result = in(reg) &mut result,
);
result
- new approach (using
MaybeUninit<T>), from #1006
let mut result_slot = core::mem::MaybeUninit::uninit();
asm! {
"%result = ...",
"OpStore {result_slot} %result",
result_slot = in(reg) result_slot.as_mut_ptr(),
}
result_slot.assume_init()
In #1006 only the unsound uses of asm!("OpReturnValue") were fixed (i.e. when dealing with opaque handles or &T/&mut T, neither of which implement Default).
However, it might be a good to transition everything uniformly, and maybe even provide a wrapper macro that allows uniformly using asm! with the result slot automatically handled (and even by-ref inputs as well?).
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
既存の spirv-std inline asm! の結果抽出箇所と、#1006 の MaybeUninit アプローチを確認する。T::default() の結果スロットを一律に置き換える範囲を、ラッパーマクロが必要かどうかも含めて特定する。完了の条件は、該当する抽出で T: Default が不要になり、選択したアプローチに一貫性があることである。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100