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

Rollup of 29 pull requests #33610

Closed
wants to merge 78 commits into from
Closed

Rollup of 29 pull requests #33610

wants to merge 78 commits into from

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented May 13, 2016

alexcrichton and others added 30 commits May 9, 2016 08:17
Long ago LLVM unfortunately didn't handle the 32-bit MSVC case of `frem` where
it can't be lowered to `fmodf` because that symbol doesn't exist. That was since
fixed in http://reviews.llvm.org/D12099 (landed as r246615) and was released in
what appears to be LLVM 3.8. Now that we're using that branch of LLVM let's
remove our own hacks and help LLVM optimize a little better by giving it
knowledge about what we're doing.
When bootstrapping Rust using a previously built toolchain, I noticed
a number of libraries were not copied in. As a result the copied in
rustc fails to execute because it can't find all its dependences.

Add them into the local_stage0.sh script.
- Adding name attribute to the sample code - Fix description sentences
Currently, to prepare for MIR trans, we break _all_ critical edges,
although we only actually need to do this for edges originating from a
call that gets translated to an invoke instruction in LLVM.

This has the unfortunate effect of undoing a bunch of the things that
SimplifyCfg has done. A particularly bad case arises when you have a
C-like enum with N variants and a derived PartialEq implementation.

In that case, the match on the (&lhs, &rhs) tuple gets translated into
nested matches with N arms each and a basic block each, resulting in N²
basic blocks. SimplifyCfg reduces that to roughly 2*N basic blocks, but
breaking the critical edges means that we go back to N².

In nickel.rs, there is such an enum with roughly N=800. So we get about
640K basic blocks or 2.5M lines of LLVM IR. LLVM takes a while to
reduce that to the final "disr_a == disr_b".

So before this patch, we had 2.5M lines of IR with 640K basic blocks,
which took about about 3.6s in LLVM to get optimized and translated.
After this patch, we get about 650K lines with about 1.6K basic blocks
and spent a little less than 0.2s in LLVM.

cc rust-lang#33111
Currently, all switches in MIR are exhausitive, meaning that we can have
a lot of arms that all go to the same basic block, the extreme case
being an if-let expression which results in just 2 possible cases, be
might end up with hundreds of arms for large enums.

To improve this situation and give LLVM less code to chew on, we can
detect whether there's a pre-dominant target basic block in a switch
and then promote this to be the default target, not translating the
corresponding arms at all.

In combination with rust-lang#33544 this makes unoptimized MIR trans of
nickel.rs as fast as using old trans and greatly improves the times for
optimized builds, which are only 30-40% slower instead of ~300%.

cc rust-lang#33111
eddyb added 15 commits May 13, 2016 08:52
…hton

Don't use env::current_exe with libbacktrace

If the path we give to libbacktrace doesn't actually correspond to the
current process, libbacktrace will segfault *at best*.

cc rust-lang#21889

r? @alexcrichton
cc @semarie
…sakis

Remove unification despite ambiguity in projection

Turns out that closures aren't explicitly considered in `project.rs`, so the ambiguity handling w.r.t. closures can just be removed as the change done in `select.rs` covers it.

r? @nikomatsakis
Use symlink_metadata in tidy to avoid panicking on broken symlinks.

r? @alexcrichton
Export OnceState from libstd

This type is used in the signature of `call_once_force` but isn't exported from libstd.

r? @alexcrichton
Fix typo in std::sync::Once documentation
[MIR trans] Optimize trans for biased switches

Currently, all switches in MIR are exhausitive, meaning that we can have
a lot of arms that all go to the same basic block, the extreme case
being an if-let expression which results in just 2 possible cases, be
might end up with hundreds of arms for large enums.

To improve this situation and give LLVM less code to chew on, we can
detect whether there's a pre-dominant target basic block in a switch
and then promote this to be the default target, not translating the
corresponding arms at all.

In combination with rust-lang#33544 this makes unoptimized MIR trans of
nickel.rs as fast as using old trans and greatly improves the times for
optimized builds, which are only 30-40% slower instead of ~300%.

cc rust-lang#33111
Support references to outer type params for assoc consts

Fixes rust-lang#28809

r? @eddyb
Plumb inference obligations through selection, take 2

Using a `SnapshotVec` and dumping inferred obligations into `Vtable` variants.

r? @nikomatsakis
Cleanup formatting and wording for `std::env::temp_dir` docs.

None
update "reason" for fnbox feature gate

It isn't "newly introduced" anymore.
Improve derived implementations for enums with lots of fieldless variants

A number of trait methods like PartialEq::eq or Hash::hash don't
actually need a distinct arm for each variant, because the code within
the arm only depends on the number and types of the fields in the
variants. We can easily exploit this fact to create less and better
code for enums with multiple variants that have no fields at all, the
extreme case being C-like enums.

For nickel.rs and its by now infamous 800 variant enum, this reduces
optimized compile times by 25% and non-optimized compile times by 40%.
Also peak memory usage is down by almost 40% (310MB down to 190MB).

To be fair, most other crates don't benefit nearly as much, because
they don't have as huge enums. The crates in the Rust distribution that
I measured saw basically no change in compile times (I only tried
optimized builds) and only 1-2% reduction in peak memory usage.
…-type-path, r=eddyb

re-introduce a cache for ast-ty-to-ty

It turns out that `ast_ty_to_ty` is supposed to be updating the `def`
after it finishes, but at some point in the past it stopped doing
so. This was never noticed because of the `ast_ty_to_ty_cache`, but that
cache was recently removed. This PR fixes the code to update the def
properly, but apparently that is not quite enough to make the operation
idempotent, so for now we reintroduce the cache too.

Fixes rust-lang#33586.

r? @eddyb
doc: Fix comment in std::string::String example code
…crichton

rustdoc: Fix missing type parameters on impls

They were broken by rust-lang#32558.

Fixes: rust-lang#33592
…rister

Save metadata even with -Z no-trans (e.g. for multi-crate cargo check).

Removes the item symbol map in metadata, as we can now generate them in a deterministic manner.
The `-Z no-trans` change lets the LLVM passes and linking run, but with just metadata and no code.
It fails while trying to link a binary because there's no `main` function, which is correct but not good UX.

There's also no way to easily throw away all of the artifacts to rebuild with actual code generation.
We might want `cargo check` to do that using cargo-internal information and then it would just work.

cc @alexcrichton @nikomatsakis @Aatch @michaelwoerister
@eddyb
Copy link
Member Author

eddyb commented May 13, 2016

@bors r+ p=7

@bors
Copy link
Contributor

bors commented May 13, 2016

📌 Commit 96297ea has been approved by eddyb

@bors
Copy link
Contributor

bors commented May 13, 2016

⌛ Testing commit 96297ea with merge a2831f7...

@bors
Copy link
Contributor

bors commented May 13, 2016

💔 Test failed - auto-win-msvc-64-opt-rustbuild

@nagisa
Copy link
Member

nagisa commented May 13, 2016

@bors retry force

@eddyb
Copy link
Member Author

eddyb commented May 13, 2016

@nagisa nooooo this is completely broken on windows

@eddyb
Copy link
Member Author

eddyb commented May 13, 2016

@bors r-

@bors
Copy link
Contributor

bors commented May 13, 2016

⌛ Testing commit 96297ea with merge 244b73d...

@bors
Copy link
Contributor

bors commented May 13, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@bors
Copy link
Contributor

bors commented May 14, 2016

☔ The latest upstream changes (presumably #33632) made this pull request unmergeable. Please resolve the merge conflicts.

@eddyb eddyb closed this May 14, 2016
@eddyb eddyb deleted the rollup branch May 14, 2016 14:17
@Centril Centril added the rollup A PR which is a rollup label Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup
Projects
None yet
Development

Successfully merging this pull request may close these issues.