about summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2017-09-18incr.comp.: Move result fingerprinting to DepGraph::with_task().Michael Woerister-1/+44
This makes sure that we don't introduce strange cases where we have nodes outside the query system that could break red/green tracking and it will allow to keep red/green neatly encapsulated within the DepGraph implementation.
2017-09-18Auto merge of #44441 - tamird:cargo-bitflags, r=alexcrichtonbors-15/+14
Remove rustc_bitflags; use the bitflags crate r? @alexcrichton
2017-09-17Remove rustc_bitflags; use the bitflags crateTamir Duberstein-15/+14
2017-09-17rustc: Move codegen to a queryAlex Crichton-413/+353
This commit moves the actual code generation in the compiler behind a query keyed by a codegen unit's name. This ended up entailing quite a few internal refactorings to enable this, along with a few cut corners: * The `OutputFilenames` structure is now tracked in the `TyCtxt` as it affects a whole bunch of trans and such. This is now behind a query and threaded into the construction of the `TyCtxt`. * The `TyCtxt` now has a channel "out the back" intended to send data to worker threads in rustc_trans. This is used as a sort of side effect of the codegen query but morally what's happening here is the return value of the query (currently unit but morally a path) is only valid once the background threads have all finished. * Dispatching work items to the codegen threads was refactored to only rely on data in `TyCtxt`, which mostly just involved refactoring where data was stored, moving it from the translation thread to the controller thread's `CodegenContext` or the like. * A new thread locals was introduced in trans to work around the query system. This is used in the implementation of `assert_module_sources` which looks like an artifact of the old query system and will presumably go away once red/green is up and running.
2017-09-17rustc: Attach an mpsc channel to TyCtxtAlex Crichton-17/+24
This commit attaches a channel to the LLVM workers to the `TyCtxt` which will later be used during the codegen query to actually send work to LLVM workers. Otherwise this commit is just plumbing this channel throughout the compiler to ensure it reaches the right consumers.
2017-09-17rustc: Remove another global map from transAlex Crichton-29/+72
This commit removes the `crate_trans_items` field from the `CrateContext` of trans. This field, a big map, was calculated during partioning and was a set of all translation items. This isn't quite incremental-friendly because the map may change a lot but not have much effect on downstream consumers. Instead a new query was added for the one location this map was needed, along with a new comment explaining what the location is doing!
2017-09-17rustc: Move a comment to the right spot in transAlex Crichton-24/+23
I believe this comment here is mostly talking about the `ptrcast` function call below, so move the comment down to that block.
2017-09-17rustc: Mostly remove `ExportedSymbols`Alex Crichton-240/+214
This is a big map that ends up inside of a `CrateContext` during translation for all codegen units. This means that any change to the map may end up causing an incremental recompilation of a codegen unit! In order to reduce the amount of dependencies here between codegen units and the actual input crate this commit refactors dealing with exported symbols and such into various queries. The new queries are largely based on existing queries with filled out implementations for the local crate in addition to external crates, but the main idea is that while translating codegen untis no unit needs the entire set of exported symbols, instead they only need queries about particulare `DefId` instances every now and then. The linking stage, however, still generates a full list of all exported symbols from all crates, but that's going to always happen unconditionally anyway, so no news there!
2017-09-17rustc: Move some attr methods to queriesAlex Crichton-9/+53
Otherwise we may emit double errors related to the `#[export_name]` attribute, for example, and using a query should ensure that it's only emitted at most once.
2017-09-17rustc: Make trans collect/partition a queryAlex Crichton-248/+267
This commit moves the `collect_and_partition_translation_items` function into a query on `TyCtxt` instead of a free function in trans, allowing us to track dependencies and such of the function.
2017-09-17rustc: Calculate `ExportedSymbols` in a queryAlex Crichton-209/+160
This commit moves the definition of the `ExportedSymbols` structure to the `rustc` crate and then creates a query that'll be used to construct the `ExportedSymbols` set. This in turn uses the reachablity query exposed in the previous commit.
2017-09-17rustc: Use reachablility through a queryAlex Crichton-5/+3
Turns out this was already set up as a query, just wasn't using it yet!
2017-09-17rustc: Refactor trans paritioning to use tcxAlex Crichton-13/+9
This commit refactors the the `partitioning::partition` function to operate with a `TyCtxt` instead of a `SharedCrateContext` in preparation for making it a query.
2017-09-17rustc_trans: Refactor collection to use tcxAlex Crichton-155/+166
This commit refactors the `collect_crate_translation_items` function to only require the `TyCtxt` instead of a `SharedCrateContext` in preparation for query-ifying this portion of trans.
2017-09-17Rollup merge of #44553 - ↵Tim Neumann-40/+2
qmx:refactor-remove-overzealous-box-szero-optimization, r=arielb1 remove overzealous Box<ZeroSizeType> optimization
2017-09-16Rollup merge of #44560 - qmx:import-TyCtxt, r=eddybAlex Crichton-19/+19
bring TyCtxt into scope got comments both from @eddyb and @nikomatsakis (via https://github.com/rust-lang/rust/pull/44505) that we should always put `TyCtxt` in scope should I just go and import it at other places in the codebase or we just keep doing small improvements?
2017-09-16Rollup merge of #44542 - alexcrichton:fix-windows-emscripten, r=nikomatsakisAlex Crichton-2/+20
rustc: Spawn `cmd /c emcc.bat` explicitly In #42436 the behavior for spawning processes on Windows was tweaked slightly to fix various bugs, but this caused #42791 as a regression, namely that to spawn batch scripts they need to be manually spawned with `cmd /c` instead now. This updates the compiler to handle this case explicitly for Emscripten. Closes #42791
2017-09-16Auto merge of #43017 - durka:stabilize-const-invocation, r=eddybbors-1/+4
Individualize feature gates for const fn invocation This PR changes the meaning of `#![feature(const_fn)]` so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward. This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review. - `std::cell` - `Cell::new` - `RefCell::new` - `UnsafeCell::new` - `std::mem` - `size_of` - `align_of` - `std::ptr` - `null` - `null_mut` - `std::sync` - `atomic` - `Atomic{Bool,Ptr,Isize,Usize}::new` - `once` - `Once::new` - primitives - `{integer}::min_value` - `{integer}::max_value` Some other functions are const but they are also unstable or hidden, e.g. `Unique::new` so they don't have to be considered at this time. After this stabilization, the following `*_INIT` constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR. - `std::sync` - `atomic` - `ATOMIC_{BOOL,ISIZE,USIZE}_INIT` - `once` - `ONCE_INIT`
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-1/+4
2017-09-15Skip passing /natvis to lld-link until supported.MaulingMonkey-0/+12
LLVM 5.0.0's lld-link frontend errors out if passed /natvis. LLVM 6 (maybe earlier?) should at least ignore the flag. Hopefully LLVM will eventually support the flag, at which point this workaround can perhaps be simply removed, if 6? is old enough.
2017-09-14bring Ty into scopeDouglas Campos-19/+19
2017-09-14rustc: Remove `Session::dep_graph`Alex Crichton-2/+9
This commit removes the `dep_graph` field from the `Session` type according to issue #44390. Most of the fallout here was relatively straightforward and the `prepare_session_directory` function was rejiggered a bit to reuse the results in the later-called `load_dep_graph` function. Closes #44390
2017-09-13remove overzealous Box<ZeroSizeType> optimizationDouglas Campos-40/+2
2017-09-13rustc: Spawn `cmd /c emcc.bat` explicitlyAlex Crichton-2/+20
In #42436 the behavior for spawning processes on Windows was tweaked slightly to fix various bugs, but this caused #42791 as a regression, namely that to spawn batch scripts they need to be manually spawned with `cmd /c` instead now. This updates the compiler to handle this case explicitly for Emscripten. Closes #42791
2017-09-12rustc: Make `CrateStore` private to `TyCtxt`Alex Crichton-5/+2
This commit removes the `cstore_untracked` method, making the `CrateStore` trait object entirely private to the `ty/context.rs` module.
2017-09-12Remove the `cstore` reference from Session in order to prepare encapsulating ↵Michael Woerister-4/+8
CrateStore access in tcx.
2017-09-12Auto merge of #44275 - eddyb:deferred-ctfe, r=nikomatsakisbors-161/+152
Evaluate fixed-length array length expressions lazily. This is in preparation for polymorphic array lengths (aka `[T; T::A]`) and const generics. We need deferred const-evaluation to break cycles when array types show up in positions which require knowing the array type to typeck the array length, e.g. the array type is in a `where` clause. The final step - actually passing bounds in scope to array length expressions from the parent - is not done because it still produces cycles when *normalizing* `ParamEnv`s, and @nikomatsakis' in-progress lazy normalization work is needed to deal with that uniformly. However, the changes here are still useful to unlock work on const generics, which @EpicatSupercell manifested interest in, and I might be mentoring them for that, but we need this baseline first. r? @nikomatsakis cc @oli-obk
2017-09-11Auto merge of #44440 - cuviper:min_global_align, r=japaricbors-2/+22
Add `TargetOptions::min_global_align`, with s390x at 16-bit The SystemZ `LALR` instruction provides PC-relative addressing for globals, but only to *even* addresses, so other compilers make sure that such globals are always 2-byte aligned. In Clang, this is modeled with `TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now serves the same purpose for rustc. In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX, and the latter two don't have targets in rust master. Fixes #44411. r? @eddyb
2017-09-11rustc: use ConstVal::Unevaluated instead of mir::Literal::Item.Eduard-Mihai Burtescu-21/+17
2017-09-11rustc: evaluate fixed-length array length expressions lazily.Eduard-Mihai Burtescu-1/+2
2017-09-11rustc: use ty::Const for the length of TyArray.Eduard-Mihai Burtescu-8/+18
2017-09-11rustc: replace usize with u64 and ConstUsize.Eduard-Mihai Burtescu-133/+117
2017-09-11rustc: introduce ty::Const { ConstVal, Ty }.Eduard-Mihai Burtescu-3/+4
2017-09-11rustc: intern ConstVal's in TyCtxt.Eduard-Mihai Burtescu-6/+5
2017-09-09Fix bitrotted generator panic emissionJohn Kåre Alsaker-8/+8
2017-09-08Add `TargetOptions::min_global_align`, with s390x at 16-bitJosh Stone-2/+22
The SystemZ `LALR` instruction provides PC-relative addressing for globals, but only to *even* addresses, so other compilers make sure that such globals are always 2-byte aligned. In Clang, this is modeled with `TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now serves the same purpose for rustc. In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX, and the latter two don't have targets in rust master.
2017-09-08Auto merge of #44142 - alexcrichton:dllimport-query, r=nikomatsakisbors-93/+184
Migrate a slew of metadata methods to queries This PR intends to make more progress on #41417, knocking off some low-hanging fruit. Closes #44190 cc #44137
2017-09-07rustc: Remove `CrateStore::crates` as a methodAlex Crichton-2/+2
This commit moves the `crates` method to a query and then migrates all callers to use a query instead of the now-renamed `crates_untracked` method where possible. Closes #41417
2017-09-07Add some more with_ignore to get tests passingAlex Crichton-11/+20
2017-09-05rustc: Attempt to handle super long linker invocationsAlex Crichton-6/+222
This commit adds logic to the compiler to attempt to handle super long linker invocations by falling back to the `@`-file syntax if the invoked command is too large. Each OS has a limit on how many arguments and how large the arguments can be when spawning a new process, and linkers tend to be one of those programs that can hit the limit! The logic implemented here is to unconditionally attempt to spawn a linker and then if it fails to spawn with an error from the OS that indicates the command line is too big we attempt a fallback. The fallback is roughly the same for all linkers where an argument pointing to a file, prepended with `@`, is passed. This file then contains all the various arguments that we want to pass to the linker. Closes #41190
2017-09-05rustc: Store InternedString in `DefPathData`Alex Crichton-7/+7
Previously a `Symbol` was stored there, but this ended up causing hash collisions in situations that otherwise shouldn't have a hash collision. Only the symbol's string value was hashed, but it was possible for distinct symbols to have the same string value, fooling various calcuations into thinking that these paths *didn't* need disambiguating data when in fact they did! By storing `InternedString` instead we're hopefully triggering all the exising logic to disambiguate paths with same-name `Symbol` but actually distinct locations.
2017-09-05rustc: Remove `CrateStore::used_crate*`Alex Crichton-23/+30
This commit removes the `use_crates` and `used_crate_source` methods in favor of a mix of queries and helper methods being used now instead.
2017-09-05rustc: Migrate lang items to a queryAlex Crichton-15/+15
This commit moves the calculation of the `LanguageItems` structure into a query rather than being calculated before the `TyCtxt` exists, with the eventual end goal of removing some `CrateStore` methods.
2017-09-05rustc: Flag some CrateStore methods as "untracked"Alex Crichton-4/+8
The main use of `CrateStore` *before* the `TyCtxt` is created is during resolution, but we want to be sure that any methods used before resolution are not used after the `TyCtxt` is created. This commit starts moving the methods used by resolve to all be named `{name}_untracked` where the rest of the compiler uses just `{name}` as a query. During this transition a number of new queries were added to account for post-resolve usage of these methods.
2017-09-05rustc: Remove a number of mutable fields in cstoreAlex Crichton-8/+15
This commit started by moving methods from `CrateStore` to queries, but it ended up necessitating some deeper refactorings to move more items in general to queries. Before this commit the *resolver* would walk over the AST and process foreign modules (`extern { .. }` blocks) and collect `#[link]` annotations. It would then also process the command line `-l` directives and such. This information was then stored as precalculated lists in the `CrateStore` object for iterating over later. After this, commit, however, this pass no longer happens during resolution but now instead happens through queries. A query for the linked libraries of a crate will crawl the crate for `extern` blocks and then process the linkage annotations at that time.
2017-09-05rustc: Move {plugin,derive}_registrar_fn to queriesAlex Crichton-2/+2
2017-09-05rustc: Migrate `CStore::native_libraries` to a queryAlex Crichton-7/+17
2017-09-05rustc: Migrate `CStore::expored_symbols` to a queryAlex Crichton-2/+0
2017-09-05rustc: Move a few more cstore methods to queriesAlex Crichton-18/+74
This comit applies the following changes: * Deletes the `is_allocator` query as it's no longer used * Moves the `is_sanitizer_runtime` method to a query * Moves the `is_profiler_runtime` method to a query * Moves the `panic_strategy` method to a query * Moves the `is_no_builtins` method to a query * Deletes the cstore method of `is_compiler_builtins`. The query was added in #42588 but the `CrateStore` method was not deleted A good bit of these methods were used late in linking during trans so a new dedicated structure was created to ship a calculated form of this information over to the linker rather than having to ship the whole of `TyCtxt` over to linking.
2017-09-05Auto merge of #44308 - eddyb:local-index, r=arielb1bors-49/+50
[MIR] Restrict ProjectionElem::Index and Storage{Live,Dead} to Local. (see #44285) r? @nikomatsakis