Commit Graph

53314 Commits

Author SHA1 Message Date
Björn Steinbrink
49b2cdf47c [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 #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 #33111
2016-05-11 22:18:46 +02:00
billyevans
bf09a9eda0 Add detailed error explanation for E0505
Part of #32777
2016-05-11 20:58:19 +01:00
Amanieu d'Antras
5cbfa1285d Fix typo in std::sync::Once documentation 2016-05-11 20:42:26 +01:00
Amanieu d'Antras
c91b104884 Export OnceState from libstd 2016-05-11 20:30:20 +01:00
Guillaume Gomez
10f9f30139 Rollup merge of #33558 - bnewbold:trivial-book-tweaks, r=steveklabnik
trivial tweaks to documentation (book)

These are small things I found while reading through The Book. The `<hash>` and `panic!` lines are simply to improve readability, while I believe the proceeding/following distinction is a bug (but might be a English dialect distinction?).

I've read `rust/CONTRIBUTING`, i'm not sure if there is anything I need to do other than submit this PR.

r? @steveklabnik
2016-05-11 21:30:20 +02:00
Guillaume Gomez
3bb96abce5 Rollup merge of #33489 - GuillaumeGomez:howto, r=alexcrichton
Improve help for make command

r? @steveklabnik
2016-05-11 21:30:19 +02:00
Guillaume Gomez
521c0ae1e8 Rollup merge of #33401 - GuillaumeGomez:index_indication, r=pnkfelix
Add rustc_on_unimplemented for Index implementation on slice

Reopening of #31071.

It also extends the possibility of `#[rustc_on_unimplemented]` by providing a small type filter in order to find the ones which corresponds the most.

r? @pnkfelix
2016-05-11 21:30:19 +02:00
bors
700279f4bf Auto merge of #33561 - alexcrichton:fix-nightiles, r=brson
mk: Fix dependencies of unwind crate on musl

The libunwind.a library was accidentally only being included for the standard
library, not the new unwind crate which implements an unwinder.
2016-05-11 12:07:06 -07:00
Masood Malekghassemi
4e5a2e01cf Remove unification despite ambiguity in projection 2016-05-11 11:47:09 -07:00
Michael Woerister
64bc3c266c trans: Make collector handle the drop_in_place() intrinsic. 2016-05-11 14:30:33 -04:00
James Miller
f4dd4be86a Add test for collecting items in statics 2016-05-11 13:59:14 -04:00
James Miller
dace30659f Inspect MIR for statics in item collection 2016-05-11 13:58:52 -04:00
Michael Woerister
85b155f6f1 trans: Don't try to place declarations during codegen unit partitioning. 2016-05-11 13:58:23 -04:00
Michael Woerister
e3f19cb0b3 trans: Move TransItem to its own module. 2016-05-11 13:49:44 -04:00
Alex Crichton
3e12c78172 mk: Fix dependencies of unwind crate on musl
The libunwind.a library was accidentally only being included for the standard
library, not the new unwind crate which implements an unwinder.
2016-05-11 10:47:56 -07:00
Eduard Burtescu
5541fdfcd1 Use symlink_metadata in tidy to avoid panicking on broken symlinks. 2016-05-11 20:09:50 +03:00
Björn Steinbrink
00f6513259 Only break critical edges where actually needed
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 #33111
2016-05-11 18:35:12 +02:00
bnewbold
8e8f3911aa trivial fixes to documentation (book) 2016-05-11 11:53:25 -04:00
ggomez
4a3acfd937 Update to eddyb's PR 2016-05-11 17:01:15 +02:00
bors
e37f8593e4 Auto merge of #33556 - steveklabnik:rollup, r=steveklabnik
Rollup of 9 pull requests

- Successful merges: #33129, #33260, #33345, #33386, #33522, #33524, #33528, #33539, #33542
- Failed merges: #33342, #33475, #33517
2016-05-11 07:03:12 -07:00
Steve Klabnik
403970f96c Rollup merge of #33542 - GuillaumeGomez:move_since, r=steveklabnik
Improve "since" tag placement

Continuation of #33431.

r? @steveklabnik
2016-05-11 09:27:44 -04:00
Steve Klabnik
4b8e7cb504 Rollup merge of #33539 - nikomatsakis:static-error, r=pnkfelix
fix DFS for region error reporting

This was causing terrible error reports, because the algorithm was incorrectly identifying the constraints.

r? @eddyb
2016-05-11 09:27:44 -04:00
Steve Klabnik
130e76b46a Rollup merge of #33528 - cramertj:E0061typeo, r=jseyfried
E0061 typo fix

Fixed silly typo.
2016-05-11 09:27:44 -04:00
Steve Klabnik
8c6796f0a7 Rollup merge of #33524 - briangreenery:briangreenery-fast-and-loose, r=steveklabnik
doc: Fix tiny typo in vec-alloc.md

Change `fast an loose` to `fast and loose`.
2016-05-11 09:27:44 -04:00
Steve Klabnik
30df9d0201 Rollup merge of #33522 - mbrubeck:inline-rawvec-cap, r=nagisa
Inline RawVec::cap

This was showing up in a Servo profile.
2016-05-11 09:27:43 -04:00
Steve Klabnik
4fe787134a Rollup merge of #33386 - cramertj:E0504, r=steveklabnik
Add detailed error explanation for E0504

Part of #32777
2016-05-11 09:27:43 -04:00
Steve Klabnik
3b75f4b56e Rollup merge of #33345 - birkenfeld:issue-31754, r=pnkfelix
middle: reset loop labels while visiting closure

This should fix #31754 and follow-up #25343.  Before the latter, the closure was visited twice in the context of the enclosing fn, which made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context of the main fn (which is intended, since it is not a separate item) but resets the found loop labels while being visited.

Fixes: #31754

Note: I amended the test file from #25343, but I don't know if the original or amended test are effective, since as far as I could see, compiletest's run-pass tests do not check for zero warnings emitted?

/cc @Manishearth
2016-05-11 09:27:43 -04:00
Steve Klabnik
82c4f5915b Rollup merge of #33260 - mrmiywj:help-on-pattern-guard, r=guillaumegomez
add help on pattern guard
2016-05-11 09:27:42 -04:00
Steve Klabnik
c5e0099a20 Rollup merge of #33129 - GuillaumeGomez:fmt_doc, r=steveklabnik
Doc improvement on std::fmt module

Part of #29355.

r? @steveklabnik
2016-05-11 09:27:42 -04:00
Guillaume Gomez
e6c0ff65ed Create Weight enum
Add more comments for the global understanding
2016-05-11 13:24:24 +02:00
ggomez
61e6169ffe Improve weight algorithm and tests 2016-05-11 13:24:22 +02:00
Guillaume Gomez
b8fad79a07 Improve error message for Index trait on slices 2016-05-11 13:22:01 +02:00
ggomez
e9797d4be5 Extend rustc_on_unimplemented flag: if a message is available at an impl, this message will be displayed instead 2016-05-11 13:18:57 +02:00
bors
c049541741 Auto merge of #33239 - eddyb:mir-temp-drops, r=arielb1
mir: drop temps outside-in by scheduling the drops inside-out.

It was backwards all along, but only noticeable with multiple drops in one rvalue scope. Fixes #32433.
2016-05-11 03:15:05 -07:00
Eduard Burtescu
e940de64ca mir: drop temps outside-in by scheduling the drops inside-out. 2016-05-11 10:46:36 +03:00
Ms2ger
c0e321abcb Make LocalCrateReader private to creader. 2016-05-11 09:32:05 +02:00
Ms2ger
5511e6568f Hand ownership of the Definitions to map_crate. 2016-05-11 09:32:05 +02:00
Sean Gillespie
94a055263e Add regression test for ICE in constant blocks 2016-05-10 23:48:12 -07:00
Alex Crichton
8d65591cf2 rustbuild: Tighten dependencies of build scripts
Ensure that `rerun-if-changed` is printed for all build scripts to ensure that
they've all got the right list of dependencies.
2016-05-10 23:41:19 -07:00
bors
c7ab8840c8 Auto merge of #33425 - eddyb:rift, r=nikomatsakis
Split the type context into a global and a local (inference-only) one.

After this change, each `InferCtxt` creates its own local type interner for types with inference by-products.
Most of the code which handles both a global and a local interner uses `'gcx` and `'tcx` for them.
A reference to the type context in that situation (e.g. `infcx.tcx`) is `TyCtxt<'a, 'gcx, 'tcx>`.
The global type context which used to be `&'a TyCtxt<'tcx>` is now `TyCtxt<'a, 'tcx, 'tcx>`.

In order to minimize the number of extra lifetime parameters, many functions became methods.
Where possible (some inherent impls), lifetime parameters were added on the impl, not each method.

As inference by-products no longer escape their inference contexts, memory usage is lower.
Example of `-Z time-passes` excerpt for `librustc`, stage1 (~100MB gains):
Before "rustc: Split local type contexts interners from the global one.":
```
time: 0.395; rss: 335MB item-types checking
time: 15.392; rss: 472MB        item-bodies checking
time: 0.000; rss: 472MB drop-impl checking
time: 1.140; rss: 478MB const checking
time: 0.139; rss: 478MB privacy checking
time: 0.024; rss: 478MB stability index
time: 0.072; rss: 478MB intrinsic checking
time: 0.038; rss: 478MB effect checking
time: 0.255; rss: 478MB match checking
time: 0.128; rss: 484MB liveness checking
time: 1.372; rss: 484MB rvalue checking
time: 1.404; rss: 597MB MIR dump
time: 0.809; rss: 599MB MIR passes
```
After:
```
time: 0.467; rss: 337MB item-types checking
time: 17.443; rss: 395MB        item-bodies checking
time: 0.000; rss: 395MB drop-impl checking
time: 1.423; rss: 401MB const checking
time: 0.141; rss: 401MB privacy checking
time: 0.024; rss: 401MB stability index
time: 0.116; rss: 401MB intrinsic checking
time: 0.038; rss: 401MB effect checking
time: 0.382; rss: 401MB match checking
time: 0.132; rss: 407MB liveness checking
time: 1.678; rss: 407MB rvalue checking
time: 1.614; rss: 503MB MIR dump
time: 0.957; rss: 512MB MIR passes
```

**NOTE**: Functions changed to methods weren't re-indented to keep this PR easier to review.
Once approved, the changes will be mechanically performed.
However, indentation changes of function arguments are there - and I believe there's a way to hide whitespace-only changes in diffs on GitHub.
2016-05-10 23:40:09 -07:00
ggomez
7a9f4c22ff Add E0500 error explanation 2016-05-11 08:03:34 +02:00
Eduard Burtescu
42eb7032fa Fixup indentation after methodification. 2016-05-11 08:48:12 +03:00
bors
80ec1b9f10 Auto merge of #33512 - birkenfeld:issue-25944, r=sanxiyn
rustdoc: remove artificial indentation of doctest code

The indentation makes the examples look nicer when printed (when is this done?), but breaks tests using multi-line string literals.

Fixes: #25944
2016-05-10 20:14:46 -07:00
Pavel Sountsov
ba04a52b96 Also rename the print_from_ast. 2016-05-10 19:21:44 -07:00
Eduard Burtescu
a1c170fc35 rustc: Split local type contexts interners from the global one. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
31a07b0ce6 rustc_typeck: Generalize over 'tcx != 'gcx. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
3a3013613a rustc: Remove the unnecessary ast_ty_to_ty_cache. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
20652162ca rustc: More interning for data used in Ty<'tcx>. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
8f72d8127f rustc: Generalize a minimum set of functions over 'tcx != 'gcx. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
f0b2b3c441 rustc: Remove a redundant lifetime parameter from ExprUseVisitor. 2016-05-11 04:14:58 +03:00