Skip to content

get llvm libcall optimizations working #9541

Closed
@thestinger

Description

@thestinger

It doesn't like that our libc signatures don't quite match, and we also currently have to mark all of the wrappers as inline(never) to prevent fixed_stack_segment from being too aggressively bubbled up.

Specifically, I really want dead-store-elimination working on unique pointers like it does with runtimeless Rust:

#[no_std];
#[allow(ctypes, cstack)];

extern {
    fn malloc(size: uint) -> *mut u8;
    fn free(ptr: *mut u8);
    fn abort() -> !;
}

#[lang = "exchange_malloc"]
#[inline(always)]
unsafe fn exchange_malloc(size: uint) -> *mut u8 {
    let ptr = malloc(size);
    if ptr == 0 as *mut u8 {
        abort()
    }
    ptr
}

#[lang = "exchange_free"]
#[inline(always)]
unsafe fn exchange_free(ptr: *mut u8) {
    free(ptr)
}

#[start]
fn main(_: int, _: **u8) -> int {
    let mut _a = ~5;
    0
}

LLVM eliminates the allocation here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions