forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle NullOp::DebugAssertions and remove the MIR pass
- Loading branch information
Showing
10 changed files
with
433 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// compile-flags: -Copt-level=0 -Cdebug-assertions=no | ||
|
||
// This test ensures that in a debug build which turns off debug assertions, we do not monomorphize | ||
// any of the standard library's unsafe precondition checks. | ||
// The naive codegen of those checks contains the actual check underneath an `if false`, which | ||
// could be optimized out if optimizations are enabled. But if we rely on optimizations to remove | ||
// panic branches, then we can't link compiler_builtins without optimizing it, which means that | ||
// -Zbuild-std doesn't work with -Copt-level=0. | ||
// | ||
// In other words, this tests for a mandatory optimization. | ||
|
||
#![crate_type = "lib"] | ||
|
||
use std::ptr::NonNull; | ||
|
||
// CHECK-LABEL: ; core::ptr::non_null::NonNull<T>::new_unchecked | ||
// CHECK-NOT: call | ||
|
||
// CHECK-LABEL: @nonnull_new | ||
#[no_mangle] | ||
pub unsafe fn nonnull_new(ptr: *mut u8) -> NonNull<u8> { | ||
// CHECK: ; call core::ptr::non_null::NonNull<T>::new_unchecked | ||
unsafe { | ||
NonNull::new_unchecked(ptr) | ||
} | ||
} |
Oops, something went wrong.