Open
Description
Latest LLVM issue for context (currently abandoned and may not be revived): https://reviews.llvm.org/D110745
- because
dereferenceable
currently means "dereferenceable everywhere", we avoid applyingdereferenceable
attribute toBox
:
rust/compiler/rustc_middle/src/ty/layout.rs
Lines 3074 to 3080 in b8c56fa
// we could apply `dereferenceable_at_point` to the `x` argument
fn foo(x: Box<u64>) -> u64 {
let value = *x;
// ...but we can't apply `dereferenceable_globally` to it, because that would allow `x` to be loaded from at this point, after the box is freed
value + 1
}
- we could use the same logic to apply
!dereferenceable
metadata to loads, e.g. here:
rust/compiler/rustc_codegen_llvm/src/builder.rs
Lines 476 to 531 in b8c56fa
let x = Box::new(42);
let ref1: &&u64 = &x.as_ref();
// we could apply `!dereferenceable_at_point` to this load of `&u64`
let ref2: &u64 = *ref1;
dbg!(ref2);
drop(x);
// ...but we can't apply `!dereferenceable_globally` to it, because that would allow `ref2` to be loaded from at this point, after the box is freed
@rustbot label A-llvm T-compiler S-blocked