mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Treat the semantics of pointee.size as "dereferenceable-at-point" and always specify the size. Instead, use a separate NoFree attribute to determine whether dereferenceability extends to the whole function. Then in the LLVM backend, only actually emit dereferenceable if nofree is also set, as dereferenceable currently implies nofree. In addition, explicitly emit the nofree attribute, which will help when LLVM switches dereferenceable to be at-point.
31 lines
1.2 KiB
Rust
31 lines
1.2 KiB
Rust
//! The tests here test that the `-Zllvm-writable` flag and
|
|
//! the `#[rustc_no_writable]` attribute have the desired effect.
|
|
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Zllvm-writable
|
|
#![crate_type = "lib"]
|
|
#![feature(rustc_attrs, unsafe_pinned)]
|
|
|
|
// CHECK: @mutable_borrow(ptr noalias nofree noundef writable align 4 dereferenceable(4) %_1)
|
|
#[no_mangle]
|
|
pub fn mutable_borrow(_: &mut i32) {}
|
|
|
|
// CHECK: @mutable_unsafe_borrow(ptr noalias nofree noundef writable align 2 dereferenceable(2) %_1)
|
|
#[no_mangle]
|
|
pub fn mutable_unsafe_borrow(_: &mut std::cell::UnsafeCell<i16>) {}
|
|
|
|
// CHECK: @option_borrow_mut(ptr noalias nofree noundef writable align 4 dereferenceable_or_null(4) %_1)
|
|
#[no_mangle]
|
|
pub fn option_borrow_mut(_: Option<&mut i32>) {}
|
|
|
|
// CHECK: @box_moved(ptr noalias noundef nonnull align 4 %0)
|
|
#[no_mangle]
|
|
pub fn box_moved(_: Box<i32>) {}
|
|
|
|
// CHECK: @unsafe_pinned_borrow_mut(ptr noundef nonnull align 4 %_1)
|
|
#[no_mangle]
|
|
pub fn unsafe_pinned_borrow_mut(_: &mut std::pin::UnsafePinned<i32>) {}
|
|
|
|
// CHECK: @mutable_borrow_no_writable(ptr noalias nofree noundef align 4 dereferenceable(4) %_1)
|
|
#[no_mangle]
|
|
#[rustc_no_writable]
|
|
pub fn mutable_borrow_no_writable(_: &mut i32) {}
|