Skip to content

Commit

Permalink
std: Tag OOM functions as #[cold]
Browse files Browse the repository at this point in the history
This was forgotten from #42727 by accident, but these functions are rarely
called and codegen can be improved in LLVM with the `#[cold]` tag.
  • Loading branch information
alexcrichton committed Aug 11, 2017
1 parent a83d2af commit fae60b3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/liballoc/heap.rs
Expand Up @@ -28,6 +28,7 @@ pub mod __core {
extern "Rust" {
#[allocator]
fn __rust_alloc(size: usize, align: usize, err: *mut u8) -> *mut u8;
#[cold]
fn __rust_oom(err: *const u8) -> !;
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
fn __rust_usable_size(layout: *const u8,
Expand Down Expand Up @@ -81,6 +82,7 @@ unsafe impl Alloc for Heap {
}

#[inline]
#[cold]
fn oom(&mut self, err: AllocErr) -> ! {
unsafe {
__rust_oom(&err as *const AllocErr as *const u8)
Expand Down

0 comments on commit fae60b3

Please sign in to comment.