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

don't translate items when monomorphizing foreign-ABI functions #16359

Merged
merged 1 commit into from
Aug 10, 2014
Merged

don't translate items when monomorphizing foreign-ABI functions #16359

merged 1 commit into from
Aug 10, 2014

Conversation

spernsteiner
Copy link
Contributor

Extend the changes from #16059 to the new generic foreign functions introduced by #15831.

bors added a commit that referenced this pull request Aug 9, 2014
…chton

Extend the changes from #16059 to the new generic foreign functions introduced by #15831.
@bors bors closed this Aug 10, 2014
@bors bors merged commit 0c158b4 into rust-lang:master Aug 10, 2014
bors added a commit that referenced this pull request Aug 13, 2014
This code produces an ICE:

```rust
#![crate_type = "rlib"]
fn main() {
    if true { return }
    // remaining code is unreachable
    match () {
        () => { static MAGIC: uint = 0; }
    }
}
```
([playpen](http://is.gd/iwOISB))

The error is "encode_symbol: id not found 18", where 18 is the `NodeId` of the declaration of `MAGIC`.  The problem is that `rustc` tries to emit metadata for `MAGIC`, but some of the information is missing because `MAGIC` never gets translated by `trans_item` - the entire body of the `match` gets skipped because the `match` itself is unreachable.

This branch simplifies the handling of inner items by always processing them using the `trans_item` visitor, instead of sometimes using the visitor and sometimes waiting until `trans_stmt` encounters the item.  This fixes the ICE by making the translation of the item no longer depend on the declaration being reachable code.  This branch also reverts #16059 and #16359, since the new change to item translation fixes the same problems as those but is simpler.
bors added a commit that referenced this pull request Sep 6, 2014
This branch adds support for running LLVM optimization and codegen on different parts of a crate in parallel.  Instead of translating the crate into a single LLVM compilation unit, `rustc` now distributes items in the crate among several compilation units, and spawns worker threads to optimize and codegen each compilation unit independently.  This improves compile times on multicore machines, at the cost of worse performance in the compiled code.  The intent is to speed up build times during development without sacrificing too much optimization.

On the machine I tested this on, `librustc` build time with `-O` went from 265 seconds (master branch, single-threaded) to 115s (this branch, with 4 threads), a speedup of 2.3x.  For comparison, the build time without `-O` was 90s (single-threaded).  Bootstrapping `rustc` using 4 threads gets a 1.6x speedup over the default settings (870s vs. 1380s), and building `librustc` with the resulting stage2 compiler takes 1.3x as long as the master branch (44s vs.  55s, single threaded, ignoring time spent in LLVM codegen).

The user-visible changes from this branch are two new codegen flags:

 * `-C codegen-units=N`: Distribute items across `N` compilation units.
 * `-C codegen-threads=N`: Spawn `N` worker threads for running optimization and codegen.  (It is possible to set `codegen-threads` larger than `codegen-units`, but this is not very useful.)

Internal changes to the compiler are described in detail on the individual commit messages.

Note: The first commit on this branch is copied from #16359, which this branch depends on.

r? @nick29581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants