Commit Graph

972 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
bors 2971d491b9 Auto merge of #41508 - michaelwoerister:generic-path-remapping, r=alexcrichton
Implement a file-path remapping feature in support of debuginfo and reproducible builds

This PR adds the `-Zremap-path-prefix-from`/`-Zremap-path-prefix-to` commandline option pair and is a more general implementation of #41419. As opposed to the previous attempt, this implementation should enable reproducible builds regardless of the working directory of the compiler.

This implementation of the feature is more general in the sense that the re-mapping will affect *all* paths the compiler emits, including the ones in error messages.

r? @alexcrichton
2017-04-28 12:09:37 +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
Michael Woerister 39ffea31df Implement a file-path remapping feature in support of debuginfo and reproducible builds. 2017-04-26 15:44:02 +02: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
Ariel Ben-Yehuda e1377a4f47 avoid calling `mk_region` unnecessarily
this improves typeck & trans performance by 1%. This looked hotter on
callgrind than it is on a CPU.
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
Niko Matsakis 93e10977d8 propagate other obligations that were left out
cc #32730 -- I left exactly one instance where I wasn't sure of the
right behavior.
2017-04-19 07:20:36 -04:00
Niko Matsakis 8388772f42 kill a bunch of one off tasks 2017-04-18 08:20:12 -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
Corey Farwell e6f6b445aa Rollup merge of #40702 - mrhota:global_asm, r=nagisa
Implement global_asm!() (RFC 1548)

This is a first attempt. ~~One (potential) problem I haven't solved is how to handle multiple usages of `global_asm!` in a module/crate. It looks like `LLVMSetModuleInlineAsm` overwrites module asm, and `LLVMAppendModuleInlineAsm` is not provided in LLVM C headers 😦~~

I can provide more detail as needed, but honestly, there's not a lot going on here.

r? @eddyb

CC @Amanieu @jackpot51

Tracking issue: #35119
2017-04-14 17:41:03 -04:00
Niko Matsakis c22fdf9a3a use `tcx.crate_name(LOCAL_CRATE)` rather than `LinkMeta::crate_name` 2017-04-13 18:37:47 -04:00
A.J. Gardner da0742c070 Add global_asm tests 2017-04-12 19:12:50 -05: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
Simonas Kazlauskas e18c59fd48 Fix some nits 2017-04-11 16:06:30 +03:00
Austin Hicks 63ebf08be5 Initial attempt at implementing optimization fuel and re-enabling struct field reordering. 2017-04-11 14:36:05 +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
Oliver Schneider eb447f4ef4
Fix various useless derefs and slicings 2017-03-27 08:58:00 +02: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
Ariel Ben-Yehuda 2b9fea1300 move the drop expansion code to rustc_mir 2017-03-18 02:53:07 +02:00
Tobias Schottdorf 7bfc64ab0f Improve wording in the -{W,A,F,D} options
Fixes #28708.
2017-03-12 06:12:05 -04:00
bors 744e69663e Auto merge of #40446 - arielb1:rollup, r=alexcrichton
Rollup of 12 pull requests

- Successful merges: #40146, #40299, #40315, #40319, #40344, #40345, #40372, #40373, #40400, #40404, #40419, #40431
- Failed merges:
2017-03-12 02:50:17 +00: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
Ariel Ben-Yehuda b1e03fe4bb Rollup merge of #40431 - fsasm:master, r=BurntSushi
rustc: Whitelist the FMA target feature

This commit adds the entry `"fma\0"` to the whitelist for the x86
target. LLVM already supports fma but rustc did not directly. Previously
rustc permitted `+fma` in the target-feature argument and enabled the use
of FMA instructions, but it did not list it in the configuration and
attributes.

fixes #40406
2017-03-11 21:57:50 +02: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