Commit Graph

170 Commits

Author SHA1 Message Date
Niko Matsakis
6d0f9319df refactor ParamEnv::empty(Reveal) into two distinct methods
- `ParamEnv::empty()` -- does not reveal all, good for typeck
- `ParamEnv::reveal_all()` -- does, good for trans
- `param_env.with_reveal_all()` -- converts an existing parameter environment
2018-03-13 11:21:30 -04:00
Alex Crichton
62c8e255d1 Rollup merge of #48651 - PramodBisht:issues/48425, r=oli-obk
Fixed #48425 : Various functions taking a `TyCtxt` and a `Span` should be taking a `TyCtxtAt`

Hi @oli-obk
I have done some code refactoring to fix #48425, Please let me know if anything else is required on this.
2018-03-07 07:09:52 -08:00
Pramod Bisht
6fdf6377cc Fixed #48425 2018-03-04 20:27:55 +05:30
Amanieu d'Antras
02e021b6d4 Add bitreverse intrinsic 2018-02-28 18:23:54 +00:00
Eduard-Mihai Burtescu
9c3dc7e872 rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. 2018-02-01 00:01:08 +02:00
Eduard-Mihai Burtescu
e69dacb431 rustc_trans: rename ccx to cx. 2018-01-14 08:56:44 +02:00
Eduard-Mihai Burtescu
fb7de6a041 rustc_trans: rename CrateContext to CodegenCx. 2018-01-14 08:55:57 +02:00
Eduard-Mihai Burtescu
2931af62f0 rustc_trans: access fields directly on CrateContext. 2018-01-14 08:55:43 +02:00
Eduard-Mihai Burtescu
7b3ac21427 rustc_trans: remove unused TargetDataRef accessor. 2018-01-14 08:52:16 +02:00
Eduard-Mihai Burtescu
d0d13204a6 rustc_trans: collapse {Local,Shared}CrateContext. 2018-01-14 08:52:16 +02:00
Michael Woerister
94f3037f4b Shorten names of some compiler generated artifacts. 2018-01-08 12:30:52 +01:00
Simonas Kazlauskas
b719578f48 Use name-discarding LLVM context
This is only applicable when neither of --emit=llvm-ir or --emit=llvm-bc are not
requested.

In case either of these outputs are wanted, but the benefits of such context are
desired as well, -Zfewer_names option provides the same functionality regardless
of the outputs requested.
2018-01-05 19:08:44 +02:00
Maik Klein
45f8a3b30c Move partitioning.rs to rustc_mir 2017-12-18 17:08:49 +02:00
Maik Klein
282b231af2 Move has_metadata back to context.rs 2017-12-18 17:08:49 +02:00
Maik Klein
7996f63ce4 Move meta_data into TyS 2017-12-18 17:08:49 +02:00
Maik Klein
c06e3aa446 Refactor paths to middle::trans to mir::mono 2017-12-18 17:08:49 +02:00
Eduard-Mihai Burtescu
cdeb4b0d25 rustc: encode scalar pairs in layout ABI. 2017-11-19 02:43:32 +02:00
Eduard-Mihai Burtescu
ac60872077 rustc_trans: generate LLVM pointee types based on alignment. 2017-11-19 02:14:33 +02:00
Eduard-Mihai Burtescu
b723af284a rustc_trans: go through layouts uniformly for fat pointers and variants. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
3fd6b00082 rustc_trans: query LLVM types from a layout instead of a Ty. 2017-11-19 02:14:32 +02:00
Eduard-Mihai Burtescu
8864668d53 rustc: re-complicate the TyLayout API and use better names. 2017-11-19 02:14:29 +02:00
Eduard-Mihai Burtescu
8afa3a01e6 rustc_trans: always insert alignment padding, even before the first field. 2017-11-19 02:14:28 +02:00
Eduard-Mihai Burtescu
0a1fcc32a6 rustc_trans: use *[T; 0] for slice data pointers instead of *T. 2017-11-19 02:14:28 +02:00
Eduard-Mihai Burtescu
b8671bef97 rustc_trans: remove obsolete Type methods. 2017-11-19 02:14:28 +02:00
Amanieu d'Antras
fdf7ba2ce9 Move tls-model to a -Z option since it is unstable 2017-11-06 21:10:49 +00:00
Amanieu d'Antras
ad1bb2e465 Cache the TLS model in the crate context 2017-11-03 00:29:54 +00:00
Amanieu d'Antras
b233a6e096 Add support for specifying the TLS model 2017-11-03 00:29:54 +00:00
Amanieu d'Antras
37b015fb91 Fix error message for invalid code/reloc models 2017-11-03 00:28:50 +00:00
Paul Liétar
1e9e3191ab Move type_has_metadata to trans_utils 2017-10-27 23:36:18 +02:00
Paul Lietar
77f7e85d7f Implement RFC 1861: Extern types 2017-10-27 23:01:34 +02:00
Marco Concetto Rudilosso
d870a96f28 trans_ -> fully_ prefix 2017-10-21 22:50:21 +01:00
Marco Concetto Rudilosso
69f5f0d193 added trans_ prefix and pluralised types. Solved failing test on the incremental test-suite. 2017-10-21 22:50:20 +01:00
Marco Concetto Rudilosso
113ebe4f1d Create NormalizeTy query 2017-10-21 22:50:15 +01:00
Alex Crichton
ded38dbfc2 rustc: Enable LTO and multiple codegen units
This commit is a refactoring of the LTO backend in Rust to support compilations
with multiple codegen units. The immediate result of this PR is to remove the
artificial error emitted by rustc about `-C lto -C codegen-units-8`, but longer
term this is intended to lay the groundwork for LTO with incremental compilation
and ultimately be the underpinning of ThinLTO support.

The problem here that needed solving is that when rustc is producing multiple
codegen units in one compilation LTO needs to merge them all together.
Previously only upstream dependencies were merged and it was inherently relied
on that there was only one local codegen unit. Supporting this involved
refactoring the optimization backend architecture for rustc, namely splitting
the `optimize_and_codegen` function into `optimize` and `codegen`. After an LLVM
module has been optimized it may be blocked and queued up for LTO, and only
after LTO are modules code generated.

Non-LTO compilations should look the same as they do today backend-wise, we'll
spin up a thread for each codegen unit and optimize/codegen in that thread. LTO
compilations will, however, send the LLVM module back to the coordinator thread
once optimizations have finished. When all LLVM modules have finished optimizing
the coordinator will invoke the LTO backend, producing a further list of LLVM
modules. Currently this is always a list of one LLVM module. The coordinator
then spawns further work to run LTO and code generation passes over each module.

In the course of this refactoring a number of other pieces were refactored:

* Management of the bytecode encoding in rlibs was centralized into one module
  instead of being scattered across LTO and linking.
* Some internal refactorings on the link stage of the compiler was done to work
  directly from `CompiledModule` structures instead of lists of paths.
* The trans time-graph output was tweaked a little to include a name on each
  bar and inflate the size of the bars a little
2017-09-30 00:22:15 -07:00
Michael Woerister
74d6b850fd incr.comp.: Fix rebase fallout. 2017-09-18 12:14:52 +02:00
Michael Woerister
d5b1fee6fd incr.comp.: Remove tcx from StableHashingContext. 2017-09-18 11:29:47 +02:00
Michael Woerister
3cc3ae22bd incr.comp.: Move result fingerprinting to DepGraph::with_task().
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-18 11:25:34 +02:00
Alex Crichton
6d614ddc2e rustc: Move codegen to a query
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-17 10:25:50 -07:00
Alex Crichton
2eada58706 rustc: Remove another global map from trans
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-17 09:41:43 -07:00
Alex Crichton
afb85cfd33 rustc: Mostly remove ExportedSymbols
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-17 09:41:43 -07:00
Alex Crichton
132bde7cf1 rustc: Make trans collect/partition a query
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-17 09:41:43 -07:00
Alex Crichton
dba3ddd8d4 rustc: Calculate ExportedSymbols in a query
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-17 09:41:43 -07:00
Alex Crichton
c72240acf7 rustc_trans: Refactor collection to use tcx
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-17 09:41:43 -07:00
Douglas Campos
3fe4612d14 bring Ty into scope 2017-09-14 21:54:21 -04:00
Eduard-Mihai Burtescu
3ce31eb990 rustc: replace usize with u64 and ConstUsize. 2017-09-11 08:41:15 +03:00
Alex Crichton
a2e2aba07d rustc: Migrate lang items to a query
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-05 07:37:57 -07:00
Vadim Petrochenkov
de4dbe5789 rustc: Remove some dead code 2017-08-19 13:27:16 +03:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Michael Woerister
2f07eb3261 trans: Internalize symbols at the trans-item level, without relying on LLVM. 2017-07-13 13:28:16 +02:00
Marco Castelluccio
ecba8d6a23 Merge branch 'profiling' of github.com:whitequark/rust into profiling 2017-06-04 15:54:39 +01:00