Commit Graph

468 Commits

Author SHA1 Message Date
whitequark 42754ce710 Add profiling support, through the rustc -Z profile flag.
When -Z profile is passed, the GCDAProfiling LLVM pass is added
to the pipeline, which uses debug information to instrument the IR.
After compiling with -Z profile, the $(OUT_DIR)/$(CRATE_NAME).gcno
file is created, containing initial profiling information.
After running the program built, the $(OUT_DIR)/$(CRATE_NAME).gcda
file is created, containing branch counters.

The created *.gcno and *.gcda files can be processed using
the "llvm-cov gcov" and "lcov" tools. The profiling data LLVM
generates does not faithfully follow the GCC's format for *.gcno
and *.gcda files, and so it will probably not work with other tools
(such as gcov itself) that consume these files.
2017-05-01 09:16:20 +00:00
Ariel Ben-Yehuda a517343566 cache symbol names in ty::maps
this fixes a performance regression introduced in commit
39a58c38a0.
2017-04-26 17:45:02 +03:00
Ariel Ben-Yehuda ece6c8434b cache attributes of items from foreign crates
this avoids parsing item attributes on each call to `item_attrs`, which takes
off 33% (!) of translation time and 50% (!) of trans-item collection time.
2017-04-22 21:00:50 +03:00
Niko Matsakis e48a759f51 sort `provide` 2017-04-21 17:26:53 -04:00
Niko Matsakis 264f237f98 make `reachable_set` ref-counted
Once it is computed, no need to deep clone the set.
2017-04-21 17:26:53 -04:00
Eduard-Mihai Burtescu 6dc21b71cf rustc: use monomorphic const_eval for cross-crate enum discriminants. 2017-04-16 01:31:37 +03:00
Eduard-Mihai Burtescu 63064ec190 rustc: expose monomorphic const_eval through on-demand. 2017-04-16 01:31:06 +03:00
Eduard-Mihai Burtescu 2a17b84cbc rustc: provide adt_sized_constraint as an on-demand query. 2017-04-15 15:40:38 +03:00
Niko Matsakis c22fdf9a3a use `tcx.crate_name(LOCAL_CRATE)` rather than `LinkMeta::crate_name` 2017-04-13 18:37:47 -04:00
Tim Neumann 1dd9801fa5 Rollup merge of #41232 - arielb1:mir-rvalues, r=eddyb
move rvalue checking to MIR
2017-04-12 14:45:47 +02:00
Tim Neumann 1b006b78a6 Rollup merge of #41141 - michaelwoerister:direct-metadata-ich-final, r=nikomatsakis
ICH: Replace old, transitive metadata hashing with direct hashing approach.

This PR replaces the old crate metadata hashing strategy with a new one that directly (but stably) hashes all values we encode into the metadata. Previously we would track what data got accessed during metadata encoding and then hash the input nodes (HIR and upstream metadata) that were transitively reachable from the accessed data. While this strategy was sound, it had two major downsides:

1. It was susceptible to generating false positives, i.e. some input node might have changed without actually affecting the content of the metadata. That metadata entry would still show up as changed.
2. It was susceptible to quadratic blow-up when many metadata nodes shared the same input nodes, which would then get hashed over and over again.

The new method does not have these disadvantages and it's also a first step towards caching more intermediate results in the compiler.

Metadata hashing/cross-crate incremental compilation is still kept behind the `-Zincremental-cc` flag even after this PR. Once the new method has proven itself with more tests, we can remove the flag and enable cross-crate support by default again.

r? @nikomatsakis
cc @rust-lang/compiler
2017-04-12 14:45:42 +02:00
Tim Neumann 49082ae9f2 Rollup merge of #41063 - nikomatsakis:issue-40746-always-exec-loops, r=eddyb
remove unnecessary tasks

Remove various unnecessary tasks. All of these are "always execute" tasks that don't do any writes to tracked state (or else an assert would trigger, anyhow). In some cases, they issue lints or errors, but we''ll deal with that -- and anyway side-effects outside of a task don't cause problems for anything that I can see.

The one non-trivial refactoring here is the borrowck conversion, which adds the requirement to go from a `DefId` to a `BodyId`. I tried to make a useful helper here.

r? @eddyb

cc #40746
cc @cramertj @michaelwoerister
2017-04-12 14:45:40 +02:00
Michael Woerister ca2dce9b48 ICH: Replace old, transitive metadata hashing with direct hashing approach.
Instead of collecting all potential inputs to some metadata entry and
hashing those, we directly hash the values we are storing in metadata.
This is more accurate and doesn't suffer from quadratic blow-up when
many entries have the same dependencies.
2017-04-12 11:47:26 +02:00
Ariel Ben-Yehuda 0144613078 Move rvalue checking to MIR
Fixes #41139.
2017-04-11 23:53:20 +03:00
Corey Farwell 88e97f0541 Rollup merge of #41056 - michaelwoerister:central-defpath-hashes, r=nikomatsakis
Handle DefPath hashing centrally as part of DefPathTable (+ save work during SVH calculation)

In almost all cases where we construct a `DefPath`, we just hash it and throw it away again immediately.
With this PR, the compiler will immediately compute and store the hash for each `DefPath` as it is allocated. This way we
+ can get rid of any subsequent `DefPath` hash caching (e.g. the `DefPathHashes`),
+ don't need to allocate a transient `Vec` for holding the `DefPath` (although I'm always surprised how little these small, dynamic allocations seem to hurt performance), and
+ we don't hash `DefPath` prefixes over and over again.

That last part is because we construct the hash for `prefix::foo` by hashing `(hash(prefix), foo)` instead of hashing every component of prefix.

The last commit of this PR is pretty neat, I think:
```
The SVH (Strict Version Hash) of a crate is currently computed
by hashing the ICHes (Incremental Computation Hashes) of the
crate's HIR. This is fine, expect that for incr. comp. we compute
two ICH values for each HIR item, one for the complete item and
one that just includes the item's interface. The two hashes are
are needed for dependency tracking but if we are compiling
non-incrementally and just need the ICH values for the SVH,
one of them is enough, giving us the opportunity to save some
work in this case.
```

r? @nikomatsakis

This PR depends on https://github.com/rust-lang/rust/pull/40878 to be merged first (you can ignore the first commit for reviewing, that's just https://github.com/rust-lang/rust/pull/40878).
2017-04-07 09:20:05 -04:00
Michael Woerister edc1ac3016 ICH: Centrally compute and cache DefPath hashes as part of DefPathTable. 2017-04-07 14:36:51 +02:00
bors 4c59c92bc4 Auto merge of #40873 - cramertj:on-demandify-queries, r=nikomatsakis
On demandify reachability

cc https://github.com/rust-lang/rust/issues/40746

I tried following this guidance from #40746:
> The following tasks currently execute before a tcx is built, but they could be easily converted into queries that are requested after tcx is built. The main reason they are the way they are was to avoid a gratuitious refcell (but using the refcell map seems fine)...

but the result of moving `region_maps` out of `TyCtxt` and into a query caused a lot of churn, and seems like it could potentially result in a rather large performance hit, since it means a dep-graph lookup on every use of `region_maps` (rather than just a field access). Possibly `TyCtxt` could store a `RefCell<Option<RegionMap>>` internally and use that to prevent repeat lookups, but that feels like it's duplicating the work of the dep-graph. @nikomatsakis What did you have in mind for this?
2017-04-07 08:36:11 +00:00
Simonas Kazlauskas 201b1a9032 Properly adjust filenames when multiple emissions
Fixes #40993
2017-04-05 19:02:25 +03:00
Niko Matsakis a4d7c1fec3 push `borrowck` into its own task 2017-04-04 12:06:35 -04:00
Taylor Cramer aab2cca046 On-demandify reachability 2017-04-04 07:46:18 -07:00
Jeffrey Seyfried ec7c0aece1 Merge `ExpnId` and `SyntaxContext`. 2017-03-29 00:41:10 +00:00
Alex Crichton 51371157e2 Rollup merge of #40751 - nrc:save-callback, r=eddyb
save-analysis: allow clients to get data directly without writing to a file.
2017-03-27 15:56:23 -07:00
bors 7846dbe0c8 Auto merge of #40826 - frewsxcv:rollup, r=frewsxcv
Rollup of 7 pull requests

- Successful merges: #40642, #40734, #40740, #40771, #40807, #40820, #40821
- Failed merges:
2017-03-26 14:04:25 +00:00
bors 7dd4e2db78 Auto merge of #40347 - alexcrichton:rm-liblog, r=brson
Remove internal liblog

This commit deletes the internal liblog in favor of the implementation that
lives on crates.io. Similarly it's also setting a convention for adding crates
to the compiler. The main restriction right now is that we want compiler
implementation details to be unreachable from normal Rust code (e.g. requires a
feature), and by default everything in the sysroot is reachable via `extern
crate`.

The proposal here is to require that crates pulled in have these lines in their
`src/lib.rs`:

    #![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
    #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]

This'll mean that by default they're not using these attributes but when
compiled as part of the compiler they do a few things:

* Mark themselves as entirely unstable via the `staged_api` feature and the
  `#![unstable]` attribute.
* Allow usage of other unstable crates via `feature(rustc_private)` which is
  required if the crate relies on any other crates to compile (other than std).
2017-03-26 04:26:22 +00:00
Niko Matsakis a9f6babcda convert privacy access levels into a query 2017-03-23 19:10:45 -04:00
Alex Crichton e341d603fe Remove internal liblog
This commit deletes the internal liblog in favor of the implementation that
lives on crates.io. Similarly it's also setting a convention for adding crates
to the compiler. The main restriction right now is that we want compiler
implementation details to be unreachable from normal Rust code (e.g. requires a
feature), and by default everything in the sysroot is reachable via `extern
crate`.

The proposal here is to require that crates pulled in have these lines in their
`src/lib.rs`:

    #![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
    #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]

This'll mean that by default they're not using these attributes but when
compiled as part of the compiler they do a few things:

* Mark themselves as entirely unstable via the `staged_api` feature and the
  `#![unstable]` attribute.
* Allow usage of other unstable crates via `feature(rustc_private)` which is
  required if the crate relies on any other crates to compile (other than std).
2017-03-23 11:28:00 -07:00
Niko Matsakis a3a5ff98eb move `export_map` into the tcx 2017-03-23 14:18:25 -04:00
Corey Farwell 2233c6dbf1 Rollup merge of #40668 - cramertj:on-demandify-more, r=nikomatsakis
On-demandify associated item retrieval

Part of #40614.

I also started converting `adt_def`, but I decided to open a PR with just this bit first to make sure I'm going about this correctly.

r? @nikomatsakis
2017-03-23 08:42:47 -05:00
Corey Farwell 39e4a27204 Rollup merge of #40678 - michaelwoerister:dmi-prep, r=nikomatsakis
Some preparations for directly computing the ICH of crate-metadata.

This PR contains some small fixes in preparation for direct metadata hashing. It mostly just moves stuff into places where it will be needed (making the module structure slightly cleaner along the way) and it fixes some omissions in the MIR region eraser.

r? @nikomatsakis
2017-03-22 23:38:02 -04:00
Nick Cameron 3ec61ea921 save-analysis: allow clients to get data directly without writing to a file 2017-03-23 16:32:49 +13:00
Michael Woerister 8c00e63f3f Move Fingerprint to rustc::ich::Fingerprint. 2017-03-22 09:14:24 +01:00
Jake Goulding 9218f9772a Teach rustc --emit=mir 2017-03-21 20:19:02 -04:00
Taylor Cramer 4cd28a7387 On-demandify associated item retrieval 2017-03-20 02:37:52 -07:00
bors 1b19284ad9 Auto merge of #40220 - jseyfried:ast_macro_def, r=nrc
syntax: add `ast::ItemKind::MacroDef`, simplify hygiene info

This PR
 - adds a new variant `MacroDef` to `ast::ItemKind` for `macro_rules!` and eventually `macro` items,
 - [breaking-change] forbids macro defs without a name (`macro_rules! { () => {} }` compiles today),
 - removes `ast::MacroDef`, and
 - no longer uses `Mark` and `Invocation` to identify and characterize macro definitions.
   - We used to apply (at least) two `Mark`s to an expanded identifier's `SyntaxContext` -- the definition mark(s) and the expansion mark(s). We now only apply the latter.

r? @nrc
2017-03-11 22:48:14 +00:00
bors 8c72b7651f Auto merge of #39648 - Aatch:mir-inlining-2, r=eddyb
[MIR] Implement Inlining

Fairly basic implementation of inlining for MIR. Uses conservative
heuristics for inlining.

Doesn't handle a number of cases, but can be extended later. This is basically the same as the previous inlining PR, but without the span-related changes (as the bugs it was dealing with have since been fixed).

/cc @rust-lang/compiler
2017-03-11 08:25:44 +00:00
Alex Crichton 2b1d1bbf2a Rollup merge of #40336 - alexcrichton:fast-dep-info, r=nrc
rustc: Exit quickly on only `--emit dep-info`

This commit alters the compiler to exit quickly if the only output being emitted
is `dep-info`, which doesn't need a lot of other information to generate.

Closes #40328
2017-03-10 16:18:28 -08:00
Alex Crichton 5c8aa74d26 rustc: Exit quickly on only `--emit dep-info`
This commit alters the compiler to exit quickly if the only output being emitted
is `dep-info`, which doesn't need a lot of other information to generate.

Closes #40328
2017-03-10 08:18:24 -08:00
Simonas Kazlauskas 4ca9c97ace Remove ability for plugins to register a MIR pass
In recent months there have been a few different people investigating how to make a plugin that
registers a MIR-pass – one that isn’t intended to be eventually merged into rustc proper.

The interface to register MIR passes was added primarily for miri (& later was
found to make prototyping of rustc-proper MIR passes a tiny bit faster). Since miri does not use
this interface anymore it seems like a good time to remove this "feature".

For prototyping purposes a similar interface can be added by developers themselves in their custom
rustc build.
2017-03-10 08:09:29 -08:00
Jeffrey Seyfried 212b6c2550 Refactor out `ast::ItemKind::MacroDef`. 2017-03-10 08:08:32 -08:00
James Miller 71d0d921c2 Initial implementation of inlining for MIR
Fairly basic implementation of inlining for MIR. Uses conservative
heuristics for inlining.
2017-03-10 03:54:26 +02:00
Jeffrey Seyfried 61a9a14d29 Add warning cycle. 2017-02-28 22:15:12 +00:00
Eduard-Mihai Burtescu d9f0a949fd rustc_const_eval: demand that the MIR qualify_consts ran on each evaluated body. 2017-02-25 18:35:26 +02:00
Eduard-Mihai Burtescu 9c3c306800 rustc_typeck: move the leaves (generics, trait_def, adt_def) to on-demand. 2017-02-25 18:35:25 +02:00
Eduard Burtescu 4649f7387e rustc_typeck: lift CrateCtxt to TyCtxt. 2017-02-25 17:07:59 +02:00
Eduard-Mihai Burtescu 374ea14412 rustc_mir: expose MIR building through ty::maps::Provider. 2017-02-25 17:07:59 +02:00
Eduard Burtescu b5c4244c6c rustc: introduce a query system for type information in ty::maps. 2017-02-25 17:07:59 +02:00
Josh Driver 2d91e7aab8 Refactor macro resolution errors + add derive macro suggestions 2017-02-16 22:03:15 +10:30
Alex Burka ca9c7ae61b driver: restore partially deleted comment 2017-02-09 12:07:58 -05:00
king6cong 768f6a9b57 add and use rename_or_copy_remove fn that fallback to copy & remove 2017-02-03 17:54:34 +08:00
king6cong 5e41ec2ccc rename other than copy/remove 2017-02-03 16:13:58 +08:00