Missing captures metadata when storing reference to Freeze type

Aperta
#166,040 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
compilers

Direzione di ricerca

The report provides a Rust reproducer and the rustc command that emits LLVM IR, but names no source files or tests. Start by reading the compiler code that emits LLVM store instructions and attaches captures metadata, then reproduce the output with the supplied command. Done means both stores have consistent captures metadata for the reference to the Freeze type, with a regression test covering the case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-codegen A-LLVM C-optimization T-compiler
pub fn f(a: [u8; 1024]) {
    let mut b = &a;
    std::hint::black_box(b as *const _);
    b = &a;
    std::hint::black_box(b as *const _);
}

rustc a.rs --crate-type=lib -O -Zmir-opt-level=0 -Cno-prepopulate-passes --emit llvm-ir

The second store to b has captures metadata !captures !8, while the first one does not:

...
  store ptr %a, ptr %b, align 8
  %_5 = load ptr, ptr %b, align 8, !nonnull !6, !noundef !6
; call core::hint::black_box::<*const [u8; 1024]>
  %_3 = call noundef ptr @_RINvNtCseHdv0ufVBMs_4core4hint9black_boxPAhj400_ECs5a4SndlX7Yo_1a(ptr noundef %_5)
  store ptr %a, ptr %b, align 8, !captures !8
  %_10 = load ptr, ptr %b, align 8, !nonnull !6, !noundef !6
; call core::hint::black_box::<*const [u8; 1024]>
  %_8 = call noundef ptr @_RINvNtCseHdv0ufVBMs_4core4hint9black_boxPAhj400_ECs5a4SndlX7Yo_1a(ptr noundef %_10)
...
!8 = !{!"address", !"read_provenance"}
Lingua principale
Rust
Stelle
122k
Fork
16.7k
Merge medio
2g 16h
PR unite (30g)
515

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rust

Tutte le issue di rust-lang/rust

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.