Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
254bf6027d83a94e93b5112d558c81a3e050413f
rust/tests/codegen/noalias-unpin.rs

16 lines
325 B
Rust
Raw Normal View History

Don't compute optimized PointerKind for unoptimized builds This saves us both the Freeze/Unpin queries, and avoids placing noalias attributes, which have a compile-time impact on LLVM even in optnone builds (due to always_inline functions).
2021-03-19 22:49:51 +01:00
// compile-flags: -O -Z mutable-noalias=yes
Don't consider !Unpin references as noalias Such structures may contain self-references, in which case the same location may be accessible through a pointer that is not based-on the noalias pointer. This is still grey area as far as language semantics are concerned, but checking for !Unpin as an indicator for self-referential sturctures seems like a good approach for the meantime.
2021-03-18 22:44:36 +01:00
#![crate_type = "lib"]
pub struct SelfRef {
self_ref: *mut SelfRef,
_pin: std::marker::PhantomPinned
}
// CHECK-LABEL: @test_self_ref(
// CHECK-NOT: noalias
#[no_mangle]
pub unsafe fn test_self_ref(s: &mut SelfRef) {
(*s.self_ref).self_ref = std::ptr::null_mut();
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 654ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API