Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_cranelift/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
pub fn panic(_msg: &'static str) -> ! {
unsafe {
libc::puts("Panicking\n\0" as *const str as *const i8);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand Down Expand Up @@ -539,7 +539,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
len,
index,
);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand All @@ -548,7 +548,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
fn panic_cannot_unwind() -> ! {
unsafe {
libc::puts("panic in a function that cannot unwind\n\0" as *const str as *const i8);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand Down Expand Up @@ -688,7 +688,7 @@ pub union MaybeUninit<T> {

pub mod intrinsics {
#[rustc_intrinsic]
pub fn abort() -> !;
pub fn abort_immediate() -> !;
#[rustc_intrinsic]
pub const fn size_of<T>() -> usize;
#[rustc_intrinsic]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,11 @@ pub enum E2<X> {
#[allow(unreachable_patterns)]
fn check_niche_behavior() {
if let E1::V2 { .. } = (E1::V1 { f: true }) {
intrinsics::abort();
intrinsics::abort_immediate();
}

if let E2::V1 { .. } = E2::V3::<Infallible> {
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let usize_layout = fx.layout_of(fx.tcx.types.usize);

match intrinsic {
sym::abort => {
sym::abort_immediate => {
fx.bcx.set_cold_block(fx.bcx.current_block().unwrap());
fx.bcx.ins().trap(TrapCode::user(2).unwrap());
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/build_system/src/fuzz/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn block_abort(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache)
// ..and insert an unconditional call to abort.
file_copy.insert(
block_starts,
"Call(tmp = core::intrinsics::abort(), ReturnTo(bb1), UnwindUnreachable())\n"
"Call(tmp = core::intrinsics::abort_immediate(), ReturnTo(bb1), UnwindUnreachable())\n"
.to_string(),
);
file_copy.insert(block_starts, "let tmp = ();\n".to_string());
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/example/alloc_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ extern "C" {

#[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! {
core::intrinsics::abort();
core::intrinsics::abort_immediate();
}

#[alloc_error_handler]
fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
core::intrinsics::abort();
core::intrinsics::abort_immediate();
}

#[lang = "eh_personality"]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_gcc/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
pub fn panic(_msg: &'static str) -> ! {
unsafe {
libc::puts("Panicking\n\0" as *const str as *const u8);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand Down Expand Up @@ -546,7 +546,7 @@ panic_const! {
fn panic_cannot_unwind() -> ! {
unsafe {
libc::puts("Panicking\n\0" as *const str as *const u8);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand All @@ -555,7 +555,7 @@ fn panic_cannot_unwind() -> ! {
fn panic_in_cleanup() -> ! {
unsafe {
libc::printf("panic in a destructor during cleanup\n\0" as *const str as *const i8);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand All @@ -568,7 +568,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
len,
index,
);
intrinsics::abort();
intrinsics::abort_immediate();
}
}

Expand Down Expand Up @@ -698,7 +698,7 @@ pub mod intrinsics {
#[rustc_intrinsic]
pub const fn black_box<T>(_dummy: T) -> T;
#[rustc_intrinsic]
pub fn abort() -> !;
pub fn abort_immediate() -> !;
#[rustc_intrinsic]
pub const fn size_of<T>() -> usize;
#[rustc_intrinsic]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ pub enum E2<X> {
#[allow(unreachable_patterns)]
fn check_niche_behavior () {
if let E1::V2 { .. } = (E1::V1 { f: true }) {
intrinsics::abort();
intrinsics::abort_immediate();
}

if let E2::V1 { .. } = E2::V3::<Infallible> {
intrinsics::abort();
intrinsics::abort_immediate();
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
llret
}

fn abort(&mut self) {
fn abort_immediate(&mut self) {
let func = self.context.get_builtin_function("__builtin_trap");
self.block.add_eval(self.location, self.context.new_call(self.location, func, &[]));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/tests/run/abort1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate mini_core;
use mini_core::*;

fn test_fail() -> ! {
unsafe { intrinsics::abort() };
unsafe { intrinsics::abort_immediate() };
}

#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/tests/run/abort2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate mini_core;
use mini_core::*;

fn fail() -> i32 {
unsafe { intrinsics::abort() };
unsafe { intrinsics::abort_immediate() };
0
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/tests/run/always_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn fib_a(n: u8) -> u8 {
#[no_mangle]
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
if fib(2) != fib_a(2) {
intrinsics::abort();
intrinsics::abort_immediate();
}
0
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
self.unreachable();
}
} else {
self.abort();
self.abort_immediate();
self.unreachable();
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
autocast(self, llret, src_ty, dest_ty)
}

fn abort(&mut self) {
fn abort_immediate(&mut self) {
self.call_intrinsic("llvm.trap", &[], &[]);
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
"compiler_builtins call to diverging function {:?} replaced with abort",
instance.def_id()
);
bx.abort();
bx.abort_immediate();
bx.unreachable();
return MergingSucc::False;
}
Expand Down Expand Up @@ -587,7 +587,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// so we should make sure that we never actually do.
// We play it safe by using a well-defined `abort`, but we could go for immediate UB
// if that turns out to be helpful.
bx.abort();
bx.abort_immediate();
// `abort` does not terminate the block, so we still need to generate
// an `unreachable` terminator after it.
bx.unreachable();
Expand Down Expand Up @@ -1099,7 +1099,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
// Also we need to terminate the block to avoid an LLVM assertion,
// even though we're not going to actually use the IR.
bx.abort();
bx.abort_immediate();
return MergingSucc::False;
}
IntrinsicResult::Fallback(instance) => {
Expand Down Expand Up @@ -2398,7 +2398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let (fn_abi, fn_ptr, instance) =
common::build_langcall(&bx, self.mir.span, reason.lang_item());
if is_call_from_compiler_builtins_to_upstream_monomorphization(bx.tcx(), instance) {
bx.abort();
bx.abort_immediate();
} else {
let fn_ty = bx.fn_decl_backend_type(fn_abi);

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

if args.is_empty() {
match name {
sym::abort
sym::abort_immediate
| sym::unreachable
| sym::cold_path
| sym::gpu_launch_sized_workgroup_mem
Expand Down Expand Up @@ -152,8 +152,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}

let op_val: OperandValue<_> = match name {
sym::abort => {
bx.abort();
sym::abort_immediate => {
bx.abort_immediate();
OperandValue::ZeroSized
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
Err(UninhabitedVariantError) => {
// We play it safe by using a well-defined `abort`, but we could go for immediate UB
// if that turns out to be helpful.
bx.abort();
bx.abort_immediate();
}
Ok(Some((tag_field, imm))) => {
let tag_place = self.project_field(bx, tag_field.as_usize());
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
Err(super::place::UninhabitedVariantError) => {
// Like codegen_set_discr we use a sound abort, but could
// potentially `unreachable` or just return the poison for
// more optimizability, if that turns out to be helpful.
bx.abort();
// optimizability, if that turns out to be helpful.
bx.abort_immediate();
let val = OperandValue::poison(bx, layout);
OperandRef { val, layout, move_annotation: None }
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes {
is_cleanup: bool,
) -> Self::Value;

fn abort(&mut self);
/// Ungracefully stop execution in the simplest way possible.
fn abort_immediate(&mut self);
fn assume(&mut self, val: Self::Value);
fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
/// Trait method used to load a function while testing if it is associated with a type
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {

// CTFE-specific intrinsics.
match intrinsic_name {
sym::abort => {
// Note that `abort` is also hooked separately in Miri.
sym::abort_immediate => {
// Note that `abort_immediate` is also hooked separately in Miri.
throw_machine_stop!(ConstEvalErrKind::Abort);
}
sym::ptr_guaranteed_cmp => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
// safe extern fns are otherwise unprecedented.

// tidy-alphabetical-start
| sym::abort
| sym::abort_immediate
| sym::add_with_overflow
| sym::aggregate_raw_ptr
| sym::align_of
Expand Down Expand Up @@ -289,7 +289,7 @@ pub(crate) fn check_intrinsic_type(
let n_lts = 0;
let (n_tps, n_cts, inputs, output) = match intrinsic_name {
sym::autodiff => (4, 0, vec![param(0), param(1), param(2)], param(3)),
sym::abort => (0, 0, vec![], tcx.types.never),
sym::abort_immediate => (0, 0, vec![], tcx.types.never),
sym::amdgpu_dispatch_ptr => (0, 0, vec![], Ty::new_imm_ptr(tcx, tcx.types.unit)),
sym::unreachable => (0, 0, vec![], tcx.types.never),
sym::breakpoint => (0, 0, vec![], tcx.types.unit),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ symbols! {
abi_vectorcall,
abi_x86_interrupt,
abort,
abort_immediate,
add,
add_assign,
add_with_overflow,
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(super) fn replace<T, R>(v: &mut T, change: impl FnOnce(T) -> (T, R)) -> R {
struct PanicGuard;
impl Drop for PanicGuard {
fn drop(&mut self) {
intrinsics::abort()
intrinsics::abort_immediate()
}
}
let guard = PanicGuard;
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<K, V> Root<K, V> {
// A panic from a later `search_node` comparison would unwind out of
// that state and double-free the shared values (#158165), so abort
// instead of exposing it.
let guard = mem::DropGuard::new((), |()| intrinsics::abort());
let guard = mem::DropGuard::new((), |()| intrinsics::abort_immediate());

loop {
split_edge.move_suffix(&mut right_node);
Expand Down
9 changes: 4 additions & 5 deletions library/alloc/src/rcs/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use core::clone::TrivialClone;
use core::clone::{CloneToUninit, Share, UseCloned};
use core::cmp::Ordering;
use core::hash::{Hash, Hasher};
use core::intrinsics::abort;
#[cfg(not(no_global_oom_handling))]
use core::iter;
use core::marker::{PhantomData, Unsize};
Expand All @@ -21,7 +20,7 @@ use core::ptr::{self, NonNull};
use core::slice::from_raw_parts_mut;
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};
use core::sync::atomic::{self, Atomic};
use core::{borrow, fmt, hint};
use core::{borrow, fmt, hint, intrinsics};

#[cfg(not(no_global_oom_handling))]
use crate::alloc::handle_alloc_error;
Expand Down Expand Up @@ -2539,7 +2538,7 @@ impl<T: ?Sized, A: AllocatorClone> Clone for Arc<T, A> {
// Otherwise, the counter could be brought to an almost-overflow using a compare-exchange loop,
// and then overflow using a few `fetch_add`s.
if old_size > MAX_REFCOUNT {
abort();
intrinsics::abort_immediate();
}

// SAFETY: Pointer is valid & allocator corresponds to the one used to allocate it.
Expand Down Expand Up @@ -3587,7 +3586,7 @@ impl<T: ?Sized, A: AllocatorClone> Clone for Weak<T, A> {

// See comments in Arc::clone() for why we do this (for mem::forget).
if old_size > MAX_REFCOUNT {
abort();
intrinsics::abort_immediate();
}
}

Expand Down Expand Up @@ -5065,7 +5064,7 @@ impl<T: ?Sized, A: AllocatorClone> UniqueArc<T, A> {

// See comments in Arc::clone() for why we do this (for mem::forget).
if old_size > MAX_REFCOUNT {
abort();
intrinsics::abort_immediate();
}

Weak { ptr: this.ptr, alloc: this.alloc.clone() }
Expand Down
Loading
Loading