Commit Graph

132 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
Michael Woerister
e5ee01143b Rename exported_symbol_ids query to something more explicit and document what it is doing. 2018-03-06 09:47:43 +01:00
Michael Woerister
1be7f966e0 Rename is_translated_fn query to is_translated_item and make it support statics. 2018-02-19 16:47:59 +01: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
Alex Crichton
5f006cebfc rustc: Tweak #[target_feature] syntax
This is an implementation of the `#[target_feature]` syntax-related changes of
[RFC 2045][rfc]. Notably two changes have been implemented:

* The new syntax is `#[target_feature(enable = "..")]` instead of
  `#[target_feature = "+.."]`. The `enable` key is necessary instead of the `+`
  to indicate that a feature is being enabled, and a sub-list is used for
  possible expansion in the future. Additionally within this syntax the feature
  names being enabled are now whitelisted against a known set of target feature
  names that we know about.

* The `#[target_feature]` attribute can only be applied to unsafe functions. It
  was decided in the RFC that invoking an instruction possibly not defined for
  the current processor is undefined behavior, so to enable this feature for now
  it requires an `unsafe` intervention.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/2045-target-feature.md
2018-01-13 10:07:18 -08:00
Maik Klein
1df6f8321b Remove duplicated functions from trans::common.rs 2017-12-18 17:08:49 +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
84b5a3d84d rustc_trans: remove the in_memory_type_of distinction. 2017-11-19 02:14:28 +02:00
Alex Crichton
24cc38e3b0 rustc: Add LLVM nounwind with -C panic=abort
This informs LLVM that functions can't unwind, which while it should typically
have already been inferred when necessary or otherwise not impact codegen is
apparently needed on targets like ARM to avoid references to unnecessary
symbols.

Closes #44992
2017-10-11 09:05:38 -07:00
bors
d7e73e4b1a Auto merge of #44901 - michaelwoerister:on-demand-eval, r=nikomatsakis
incr.comp.: Switch to red/green change tracking, remove legacy system.

This PR finally switches incremental compilation to [red/green tracking](https://github.com/rust-lang/rust/issues/42293) and completely removes the legacy dependency graph implementation -- which includes a few quite costly passes that are simply not needed with the new system anymore.

There's still some documentation to be done and there's certainly still lots of optimizing and tuning ahead -- but the foundation for red/green is in place with this PR. This has been in the making for a long time `:)`

r? @nikomatsakis
cc @alexcrichton, @rust-lang/compiler
2017-10-04 19:14:41 +00:00
Michael Woerister
e6badfd449 incr.comp.: Use red/green tracking for CGU re-use. 2017-10-02 15:45:46 +02:00
Douglas Campos
11e141eba3 stray comma 2017-10-01 11:14:47 -04:00
Douglas Campos
b24a672613 weird formatting 2017-09-30 11:08:08 -04:00
Douglas Campos
08e1f0b9d7 fix formatting 2017-09-29 22:34:48 -04:00
Douglas Campos
29220663c1 style fixes as requested by @eddyb 2017-09-29 22:34:48 -04:00
Douglas Campos
081b29c1f6 stop using monomorphize::resolve() 2017-09-29 22:34:48 -04: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
19727c84dd rustc: Move a comment to the right spot in trans
I believe this comment here is mostly talking about the `ptrcast` function call
below, so move the comment down to that block.
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
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
Alex Crichton
2ee7493b2a Add some more with_ignore to get tests passing 2017-09-07 08:13:17 -07:00
Alex Crichton
64a70342e6 rustc: Remove a number of mutable fields in cstore
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-05 07:37:28 -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
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
Eduard-Mihai Burtescu
9bde6b6d96 rustc: expose the common DUMMY_SP query case as tcx methods. 2017-04-24 17:23:43 +03:00
Niko Matsakis
39a58c38a0 introduce the rather simpler symbol-cache in place of symbol-map
The symbol map is not good for incremental: it has inputs from every fn
in existence, and it will change if anything changes. One could imagine
cheating with the symbol-map and exempting it from the usual dependency
tracking, since the results are fully deterministic. Instead, I opted to
just add a per-CGU cache, on the premise that recomputing some symbol
names is not going to be so very expensive.
2017-04-21 17:26:53 -04:00
Niko Matsakis
8289e5a73e introduce is_foreign_item query
This may seem like overkill, but it's exactly what we want/need for
incremental compilation I think. In particular, while generating code
for some codegen unit X, we can wind up querying about any number of
external items, and we only want to be forced to rebuild X is some of
those changed from a foreign item to otherwise. Factoring this into a
query means we would re-run only if some `false` became `true` (or vice
versa).
2017-04-21 17:26:53 -04:00
Ariel Ben-Yehuda
f2c7917402 translate drop glue using MIR
Drop of arrays is now translated in trans::block in an ugly way that I
should clean up in a later PR, and does not handle panics in the middle
of an array drop, but this commit & PR are growing too big.
2017-03-18 02:53:08 +02:00
Ariel Ben-Yehuda
e1f3c67cb4 translate closure shims using MIR 2017-03-18 02:53:07 +02:00
Ariel Ben-Yehuda
65a4266f1f refactor away callee::Callee and translate virtual calls through a MIR shim
These changes are in the same commit to avoid needing to adapt
meth::trans_object_shim to the new scheme.

One codegen-units test is broken because we instantiate the shims even
when they are not needed. This will be fixed in the next PR.
2017-03-18 02:53:07 +02:00
Ariel Ben-Yehuda
aac5ba5dab resolve instances to ty::Instance directly
This removes the duplication between collector, callee, and (eventually)
MIRI.
2017-03-18 02:53:07 +02:00
Ariel Ben-Yehuda
bf80fec326 translate function shims using MIR 2017-03-18 02:53:06 +02:00
Ariel Ben-Yehuda
ffee9566bb move Instance to rustc and use it in the collector 2017-03-18 02:53:04 +02:00
Ariel Ben-Yehuda
0af3775dd2 translate tuple-variant constructors using MIR 2017-03-18 02:52:07 +02:00
Ariel Ben-Yehuda
ca8708273b more through normalization in typeck & trans
Fixes #27901.
Fixes #28828.
Fixes #38135.
Fixes #39363.
2017-03-01 16:56:08 +02:00
Eduard-Mihai Burtescu
3146ee8672 rustc: simplify tcx.closure_type(...) as it can copy the cached values. 2017-02-25 18:35:25 +02:00
Eduard-Mihai Burtescu
91374f8fe4 rustc: combine BareFnTy and ClosureTy into FnSig. 2017-02-25 17:47:15 +02:00
Eduard-Mihai Burtescu
e96a171453 rustc: move the actual values of enum discriminants into a map. 2017-02-25 17:07:59 +02:00
Ariel Ben-Yehuda
09825de61b emit "align 1" metadata on loads/stores of packed structs
According to the LLVM reference:
> A value of 0 or an omitted align argument means that the operation has
the ABI alignment for the target.

So loads/stores of fields of packed structs need to have their align set
to 1. Implement that by tracking the alignment of `LvalueRef`s.

Fixes #39376.
2017-02-08 22:23:21 +01:00
Andrew Cann
2cc84df44c Add warning for () to ! switch 2017-02-03 18:48:15 +08:00
bors
0576869085 Auto merge of #38822 - michaelwoerister:collect-fn-once-adapter, r=eddyb
trans: Fix missing closure env drop-glue in trans-item collector.

FnOnce adapters automatically generated by the compiler introduce a call to drop the closure environment. The collector didn't pick up on that because this drop call does not show up in MIR. That could lead to an assertion being triggered if the drop-glue for the environment wasn't instantiated via something else.

Fixes #38810

cc @arielb1

r? @eddyb or @nikomatsakis
2017-01-08 04:18:32 +00:00
Mark Simulacrum
c3fe2590f5 Inline and remove Builder::entry_block 2017-01-04 11:38:10 -07:00
Mark Simulacrum
901984e1d1 Builder.build_new_block -> Builder.build_sibling_block 2017-01-04 11:38:10 -07:00
Mark Simulacrum
8038489357 Use LvalueRef instead of MaybeSizedValue 2017-01-04 11:35:33 -07:00
Mark Simulacrum
937e8da349 Purge FunctionContext 2017-01-04 11:33:59 -07:00
Mark Simulacrum
1be170b01a Replace BlockAndBuilder with Builder. 2017-01-04 11:33:31 -07:00
Michael Woerister
ab8fff20d2 trans: Collect drop-glue translation item for closure env in fn-once-adapters. 2017-01-04 10:01:27 -05:00
Mark Simulacrum
afc2dcd0ca Make drop glue for unsized value pass two arguments instead of *(data, meta) 2016-12-21 12:02:09 -07:00