about summary refs log tree commit diff
path: root/src/librustc_driver/driver.rs
AgeCommit message (Collapse)AuthorLines
2017-08-10Merge remote-tracking branch 'origin/master' into genAlex Crichton-19/+26
2017-08-10Auto merge of #43522 - alexcrichton:rewrite-lints, r=michaelwoeristerbors-11/+11
rustc: Rearchitect lints to be emitted more eagerly In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite. Closes https://github.com/rust-lang/rust/issues/42511
2017-08-10driver: factor out `continue_parse_after_error` so it can be controlled via ↵Nick Cameron-8/+15
driver API
2017-08-09run AddCallGuards for *all* call edges before running AddValidationRalf Jung-5/+6
2017-08-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-58/+25
2017-08-09rustc: Rearchitect lints to be emitted more eagerlyAlex Crichton-11/+11
In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite.
2017-08-04Auto merge of #43403 - RalfJung:mir-validate, r=nikomatsakisbors-6/+13
Add MIR Validate statement This adds statements to MIR that express when types are to be validated (following [Types as Contracts](https://internals.rust-lang.org/t/types-as-contracts/5562)). Obviously nothing is stabilized, and in fact a `-Z` flag has to be passed for behavior to even change at all. This is meant to make experimentation with Types as Contracts in miri possible. The design is definitely not final. Cc @nikomatsakis @aturon
2017-07-31async-llvm(18): Instantiate OngoingCrateTranslation before starting translation.Michael Woerister-3/+3
2017-07-31async-llvm(13): Submit LLVM work packages from base::trans_crate().Michael Woerister-4/+3
2017-07-31async-llvm(9): Move OngoingCrateTranslation into back::write.Michael Woerister-2/+2
2017-07-31async-llvm(8): Clean up resource management and drop LLVM modules ASAP.Michael Woerister-2/+0
2017-07-31async-llvm(1): Run LLVM already in trans_crate().Michael Woerister-47/+10
2017-07-30Reorder passes so that AddValidation can run after ElaborateDropsRalf Jung-10/+13
2017-07-30add a pass for validation commands; for now just emit the initial AcquireValidRalf Jung-0/+4
2017-07-28Generator literal supportJohn Kåre Alsaker-0/+4
2017-07-24Make keep_ast configurable by driver clientsNick Cameron-4/+4
2017-07-19Add empty MIR pass for non-lexical lifetimesPaul Faria-0/+1
2017-07-05rustc: Implement the #[global_allocator] attributeAlex Crichton-0/+8
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-07-02report the total number of errors on compilation failureAriel Ben-Yehuda-20/+14
Prior to this PR, when we aborted because a "critical pass" failed, we displayed the number of errors from that critical pass. While that's the number of errors that caused compilation to abort in *that place*, that's not what people really want to know. Instead, always report the total number of errors, and don't bother to track the number of errors from the last pass that failed. This changes the compiler driver API to handle errors more smoothly, and therefore is a compiler-api-[breaking-change]. Fixes #42793.
2017-06-28Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate.Felix S. Klock II-1/+2
Turn `elaborate_drops` and `rustc_peek` implementations into MIR passes that also live in `rustc_mir` crate. Rewire things so `rustc_driver` uses the `ElaborateDrops` from `rustc_mir` crate.
2017-06-19Auto merge of #39409 - pnkfelix:mir-borrowck2, r=nikomatsakisbors-0/+3
MIR EndRegion Statements (was MIR dataflow for Borrows) This PR adds an `EndRegion` statement to MIR (where the `EndRegion` statement is what terminates a borrow). An earlier version of the PR implemented a dataflow analysis on borrow expressions, but I am now factoring that into a follow-up PR so that reviewing this one is easier. (And also because there are some revisions I want to make to that dataflow code, but I want this PR to get out of WIP status...) This is a baby step towards MIR borrowck. I just want to get the review process going while I independently work on the remaining steps.
2017-06-16Auto merge of #42598 - cramertj:track-more-metadata, r=nikomatsakisbors-1/+2
Track more crate metadata Part of https://github.com/rust-lang/rust/issues/41417 r? @nikomatsakis
2017-06-14on-demand dylib dependency formatsTaylor Cramer-1/+1
2017-06-13On-demand is_const_fnTaylor Cramer-0/+1
2017-06-12Add post-pass to remove EndRegions of unborrowed extents.Felix S. Klock II-0/+3
2017-06-04Merge branch 'profiling' of github.com:whitequark/rust into profilingMarco Castelluccio-3/+5
2017-05-17Auto merge of #41911 - michaelwoerister:querify_trait_def, r=nikomatsakisbors-0/+3
Remove interior mutability from TraitDef by turning fields into queries This PR gets rid of anything `std::cell` in `TraitDef` by - moving the global list of trait impls from `TraitDef` into a query, - moving the list of trait impls relevent for some self-type from `TraitDef` into a query - moving the specialization graph of trait impls into a query, and - moving `TraitDef::object_safety` into a query. I really like how querifying things not only helps with incremental compilation and on-demand, but also just plain makes the code cleaner `:)` There are also some smaller fixes in the PR. Commits can be reviewed separately. r? @eddyb or @nikomatsakis
2017-05-15Remove interior mutability from TraitDef by turning fields into queries.Michael Woerister-0/+3
2017-05-13Add lint for unused macrosest31-0/+2
2017-05-10rustc: Add a new `-Z force-unstable-if-unmarked` flagAlex Crichton-1/+1
This commit adds a new `-Z` flag to the compiler for use when bootstrapping the compiler itself. We want to be able to use crates.io crates, but we also want the usage of such crates to be as ergonomic as possible! To that end compiler crates are a little tricky in that the crates.io crates are not annotated as unstable, nor do they expect to pull in unstable dependencies. To cover all these situations it's intended that the compiler will forever now bootstrap with `-Z force-unstable-if-unmarked`. This flags serves a dual purpose of forcing crates.io crates to themselves be unstable while also allowing them to use other "unstable" crates.io crates. This should mean that adding a dependency to compiler no longer requires upstream modification with unstable/staged_api attributes for inclusion!
2017-05-08incr.comp.: Hash more pieces of crate metadata to detect changes there.Michael Woerister-2/+1
2017-05-02remove `mir_passes` from `Session` and add a FIXMENiko Matsakis-2/+2
2017-05-02pacify the mercilous tidyNiko Matsakis-1/+2
2017-05-02support inlining by asking for optimizer mir for calleesNiko Matsakis-1/+1
I tested this with it enabled 100% of the time, and we were able to run mir-opt tests successfully.
2017-05-02remove `Pass` and (temporarily) drop `Inline`Niko Matsakis-1/+1
2017-05-02rename `mir_map` to `queries` and remove `build_mir_for_crate`Niko Matsakis-10/+1
2017-05-02convert the `inline` pass to use the new multi resultNiko Matsakis-1/+1
This involves changing various details about that system, though the basic shape remains the same.
2017-05-02retool MIR passes completelyNiko Matsakis-19/+0
The new setup is as follows. There is a pipeline of MIR passes that each run **per def-id** to optimize a particular function. You are intended to request MIR at whatever stage you need it. At the moment, there is only one stage you can request: - `optimized_mir(def_id)` This yields the final product. Internally, it pulls the MIR for the given def-id through a series of steps. Right now, these are still using an "interned ref-cell" but they are intended to "steal" from one another: - `mir_build` -- performs the initial construction for local MIR - `mir_pass_set` -- performs a suite of optimizations and transformations - `mir_pass` -- an individual optimization within a suite So, to construct the optimized MIR, we invoke: mir_pass_set((MIR_OPTIMIZED, def_id)) which will build up the final MIR.
2017-05-02move to only def-id passesNiko Matsakis-1/+1
this temporary disables `inline`
2017-05-02rewrite `Passes` to have sets of passesNiko Matsakis-36/+38
Also, store the completed set of passes in the tcx.
2017-05-02introduce `DefIdPass` and remove all impls of `Pass` but `Inline`Niko Matsakis-22/+22
2017-05-02simplify the MirPass traits and passes dramaticallyNiko Matsakis-2/+1
Overall goal: reduce the amount of context a mir pass needs so that it resembles a query. - The hooks are no longer "threaded down" to the pass, but rather run automatically from the top-level (we also thread down the current pass number, so that the files are sorted better). - The hook now receives a *single* callback, rather than a callback per-MIR. - The traits are no longer lifetime parameters, which moved to the methods -- given that we required `for<'tcx>` objecs, there wasn't much point to that. - Several passes now store a `String` instead of a `&'l str` (again, no point).
2017-05-02rework `MirPass` API to be stateless and extract helper fnsNiko Matsakis-1/+1
2017-05-01Add profiling support, through the rustc -Z profile flag.whitequark-3/+5
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-04-30introduce per-fn RegionMapsTaylor Cramer-4/+0
Instead of requesting the region maps for the entire crate, request for a given item etc. Several bits of code were modified to take `&RegionMaps` as input (e.g., the `resolve_regions_and_report_errors()` function). I am not totally happy with this setup -- I *think* I'd rather have the region maps be part of typeck tables -- but at least the `RegionMaps` works in a "parallel" way to `FreeRegionMap`, so it's not too bad. Given that I expect a lot of this code to go away with NLL, I didn't want to invest *too* much energy tweaking it.
2017-04-30On-demandify region mappingTaylor Cramer-5/+6
2017-04-26cache symbol names in ty::mapsAriel Ben-Yehuda-2/+2
this fixes a performance regression introduced in commit 39a58c38a0b9ac9e822a1732f073abe8ddf65cfb.
2017-04-22cache attributes of items from foreign cratesAriel Ben-Yehuda-0/+2
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-21sort `provide`Niko Matsakis-1/+2
2017-04-21make `reachable_set` ref-countedNiko Matsakis-1/+1
Once it is computed, no need to deep clone the set.