Skip to content

Discover better llvm optimizations for Rust #3519

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

Closed
brson opened this issue Sep 18, 2012 · 6 comments
Closed

Discover better llvm optimizations for Rust #3519

brson opened this issue Sep 18, 2012 · 6 comments
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@brson
Copy link
Contributor

brson commented Sep 18, 2012

Two observations:

  • Running llvm optimizations is the greater part of rustc's time, so we should take care not to run ineffective optimizations.
  • Rust code has its own unique character so what are good llvm defaults may not be the best Rust defaults

Let us find the ideal combination of passes that is both fast to compile and creates fast code. LLVM almost certainly has tools for this. Testing should be done with split stacks disabled.

@lomereiter
Copy link

You may be interested in this blogpost about using Acovea for finding near-optimal flags using genetic algorithm: http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-llvm/

@graydon
Copy link
Contributor

graydon commented Dec 26, 2012

Indeed. Though I'd suggest blocking this on the two major codegen changes: removing refcounting and landing pads.

@bstrie
Copy link
Contributor

bstrie commented Apr 29, 2013

As of right now, there are still enough changes in the pipe that this would probably be premature.

@thestinger
Copy link
Contributor

The reason the LLVM passes take so long is because we're generating really poor pre-optimization IR. For a simple swap function, we output 150+ lines of IR while clang only has 10-15 instructions at -O0.

I think we'll need to fix the major issues with our code generation before tackling this.

@Aatch
Copy link
Contributor

Aatch commented May 29, 2013

For some real numbers as to our code gen quality. We spend ~20% of the LLVM passes on combining redundant instructions.

Now this might be just be a quirk of the pipeline, but it doesn't seem right to me...

@thestinger
Copy link
Contributor

I redid the LLVM optimization passes to match the passes used in clang 3.3 and I don't think we can do any better because we don't have different needs or patterns than C++11. The reason our compilation is many times slower than clang's is because we generate 50-200x as much IR from our poor codegen.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
"first" element check does nothing
RalfJung pushed a commit to RalfJung/rust that referenced this issue Apr 27, 2024
…sion-of-nodejs, r=RalfJung

bump actions/cache to v4

fixes rust-lang#3518.
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 4, 2024
…sion-of-nodejs, r=RalfJung

bump actions/cache to v4

fixes rust-lang#3518.
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

6 participants