Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get llvm libcall optimizations working #9541

Closed
thestinger opened this issue Sep 26, 2013 · 2 comments
Closed

get llvm libcall optimizations working #9541

thestinger opened this issue Sep 26, 2013 · 2 comments
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@thestinger
Copy link
Contributor

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.

@thestinger
Copy link
Contributor Author

This is also going to prevent the upcoming escape analysis implementation in LLVM from working.

@thestinger
Copy link
Contributor Author

This is fixed for malloc and free, at least.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
Generate lint categories and explanations with `declare_clippy_lint`

This means contributors will no longer have to run `cargo dev update_lints` after changing a lints documentation or its category, which may also mean fewer merge conflicts in general

It works by swapping `declare_clippy_lint` out for a `proc_macro` of the same name. The proc macro emits a `LintInfo` alongside the generated `Lint` which are gathered into `declared_lint::LINTS`. The categories/explanations are then read from `declared_lint::LINTS` at runtime

The removal of `src/docs` is split into a separate commit to be more easily ignored

It is slightly slower though, adding a bit under a second to build time. Less noticeable in full builds or with a slower linker (benchmark uses mold)

```bash
hyperfine --warmup 2 \
    --parameter-list commit "declare-proc-macro,master" \
    --command-name "{commit}" \
    --setup "git checkout {commit}" \
    --prepare "touch clippy_lints/src/lib.rs" \
    "cargo build"
```
```
Benchmark 1: declare-proc-macro
  Time (mean ± σ):     10.731 s ±  0.154 s    [User: 7.739 s, System: 1.791 s]
  Range (min … max):   10.598 s … 11.125 s    10 runs

Benchmark 2: master
  Time (mean ± σ):      9.422 s ±  0.094 s    [User: 7.183 s, System: 1.732 s]
  Range (min … max):    9.287 s …  9.624 s    10 runs

Summary
  'master' ran
    1.14 ± 0.02 times faster than 'declare-proc-macro'
```

r? `@flip1995`
cc `@llogiq` for `--explain`

changelog: none
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
removes document text files that are no longer needed by rust-lang#9541.
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
…, r=flip1995

chore: remove unnecessary files

removes document text files that are no longer needed by rust-lang#9541.

changelog: none

r? `@Alexendoo`
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
Remove `lib.register_*` and `src/docs*` in `cargo dev update_lints`

Follow up to rust-lang#9709 / rust-lang#9541

There's a good number of PRs with some leftover `src/docs` files for example, and as a reviewer it's something we're used to ignoring so it can easily slip through

r? `@flip1995`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

1 participant