Skip to content

Discover better llvm optimizations for Rust #3519

Closed
@brson

Description

@brson
Contributor

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.

Activity

lomereiter

lomereiter commented on Dec 25, 2012

@lomereiter

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

graydon commented on Dec 26, 2012

@graydon
Contributor

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

bstrie

bstrie commented on Apr 29, 2013

@bstrie
Contributor

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

thestinger

thestinger commented on May 25, 2013

@thestinger
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

Aatch commented on May 29, 2013

@Aatch
Contributor

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

thestinger commented on Jul 4, 2013

@thestinger
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.

added a commit that references this issue on May 15, 2021
31a6942
added a commit that references this issue on Apr 27, 2024

Auto merge of rust-lang#3519 - hamirmahal:fix/usage-of-deprecated-ver…

added a commit that references this issue on May 4, 2024

Auto merge of rust-lang#3519 - hamirmahal:fix/usage-of-deprecated-ver…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @graydon@brson@Aatch@lomereiter@bstrie

        Issue actions

          Discover better llvm optimizations for Rust · Issue #3519 · rust-lang/rust