Commit Graph

91 Commits

Author SHA1 Message Date
Oliver Schneider
b33e4e784e
Fully use miri in trans 2018-03-08 08:34:05 +01:00
Wesley Wiser
368e586a3d Add linkage to TransFnAttrs
Part of #47320
2018-03-06 20:19:39 -05: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
89b3ef3e8e Allow for instantiating statics from upstream crates. 2018-02-19 16:49:20 +01:00
Michael Woerister
15ff0adcde Use DefId instead of NodeId in MonoItem::Static. 2018-02-19 13:29:22 +01:00
Michael Woerister
d5ed655a08 Use DefId instead of NodeId while generating debuginfo for statics. 2018-02-19 12:41:10 +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
Eduard-Mihai Burtescu
d0d13204a6 rustc_trans: collapse {Local,Shared}CrateContext. 2018-01-14 08:52:16 +02:00
Maik Klein
45f8a3b30c Move partitioning.rs to rustc_mir 2017-12-18 17:08:49 +02:00
Maik Klein
1df6f8321b Remove duplicated functions from trans::common.rs 2017-12-18 17:08:49 +02:00
Maik Klein
b9ab487a7a Rename TransItemExt to MonoItemExt 2017-12-18 17:08:48 +02:00
Maik Klein
1181f45813 Rename TransItem to MonoItem 2017-12-18 17:08:48 +02:00
Michael Woerister
0bfc2b92c3 Make CGU-local globals private so they don't show up in the local symbol table. 2017-12-07 17:08:33 +01: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
Eduard-Mihai Burtescu
f44b099187 rustc_trans: avoid working with sizes/offsets and alignments as integers. 2017-11-19 02:14:24 +02: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
Michael Woerister
e6badfd449 incr.comp.: Use red/green tracking for CGU re-use. 2017-10-02 15:45:46 +02: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
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
Josh Stone
95a5a0ed16 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.
2017-09-08 14:49:51 -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
Eduard-Mihai Burtescu
c457b26e33 rustc_trans: do not pass floating-point values to LLVM through FFI. 2017-08-02 17:28:11 +03:00
Michael Woerister
2f07eb3261 trans: Internalize symbols at the trans-item level, without relying on LLVM. 2017-07-13 13:28:16 +02:00
achernyak
5a7946df70 is_foreign_item 2017-05-05 08:15:08 -05: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
Niko Matsakis
c446cb086b just take tcx where we can
The more we can things dependent on just tcx, the easier it will
be to make queries etc later on.
2017-04-21 17:26:53 -04: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
Eduard-Mihai Burtescu
6563374ed2 rustc: replace interior_unsafe with a Freeze trait. 2017-04-20 14:39:31 +03:00
Eduard-Mihai Burtescu
8854164d0c rustc_const_eval: move ConstEvalErr to the rustc crate. 2017-04-16 01:31:06 +03:00
Eduard-Mihai Burtescu
c977daf97c rustc_trans: avoid sizing_type_of everywhere possible. 2017-04-08 23:40:54 +03:00
Jorge Aparicio
bbe5411587 document the implementation a bit more 2017-04-05 21:11:22 -05:00
Jorge Aparicio
c1635d7e61 cast the #[used] static to *i8
to match the type signature of the llvm.used variable
2017-04-05 21:02:52 -05:00
Jorge Aparicio
4c7e277340 add an #[used] attribute
similar to GCC's __attribute((used))__. This attribute prevents LLVM from
optimizing away a non-exported symbol, within a compilation unit (object file),
when there are no references to it.

This is better explained with an example:

```
#[used]
static LIVE: i32 = 0;

static REFERENCED: i32 = 0;

static DEAD: i32 = 0;

fn internal() {}

pub fn exported() -> &'static i32 {
    &REFERENCED
}
```

Without optimizations, LLVM pretty much preserves all the static variables and
functions within the compilation unit.

```
$ rustc --crate-type=lib --emit=obj symbols.rs && nm -C symbols.o
0000000000000000 t drop::h1be0f8f27a2ba94a
0000000000000000 r symbols::REFERENCED::hb3bdfd46050bc84c
0000000000000000 r symbols::DEAD::hc2ea8f9bd06f380b
0000000000000000 r symbols::LIVE::h0970cf9889edb56e
0000000000000000 T symbols::exported::h6f096c2b1fc292b2
0000000000000000 t symbols::internal::h0ac1aadbc1e3a494
```

With optimizations, LLVM will drop dead code. Here `internal` is dropped because
it's not a exported function/symbol (i.e. not `pub`lic). `DEAD` is dropped for
the same reason. `REFERENCED` is preserved, even though it's not exported,
because it's referenced by the `exported` function. Finally, `LIVE` survives
because of the `#[used]` attribute even though it's not exported or referenced.

```
$ rustc --crate-type=lib -C opt-level=3 --emit=obj symbols.rs && nm -C symbols.o
0000000000000000 r symbols::REFERENCED::hb3bdfd46050bc84c
0000000000000000 r symbols::LIVE::h0970cf9889edb56e
0000000000000000 T symbols::exported::h6f096c2b1fc292b2
```

Note that the linker knows nothing about `#[used]` and will drop `LIVE`
because no other object references to it.

```
$ echo 'fn main() {}' >> symbols.rs
$ rustc symbols.rs && nm -C symbols | grep LIVE
```

At this time, `#[used]` only works on `static` variables.
2017-04-05 13:40:11 -05: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
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
e7a48821c0 rustc_const_eval: always demand typeck_tables for evaluating constants. 2017-02-25 18:35:26 +02:00
Eduard-Mihai Burtescu
45c8c5678a rustc: rename TyCtxt's map field to hir. 2017-01-26 13:41:28 +02:00
Eduard-Mihai Burtescu
cde0a7e7e0 rustc: store ty::Tables separately for each body (except closures'). 2017-01-06 22:23:29 +02:00
Mark-Simulacrum
6441c977cb Remove push_ctxt 2016-12-20 20:02:50 -07:00
Vadim Chugunov
bc019dfb39 Emit 'dllimport' attribute for dylib foreign items on Windows. 2016-12-01 16:22:04 -08:00
Jeffrey Seyfried
e85a0d70b8 Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Eduard Burtescu
3f9eba1c7c rustc: clean up lookup_item_type and remove TypeScheme. 2016-11-10 16:49:53 +02:00
Michael Woerister
e6aa92c432 trans: Make names of internal symbols independent of CGU translation order.
Every codegen unit gets its own local counter for generating new symbol
names. This makes bitcode and object files reproducible at the binary
level even when incremental compilation is used.
2016-10-21 14:58:53 -04:00
Matt Ickstadt
b9a8c1a063 Fix incorrect LLVM Linkage enum
The `Linkage` enum in librustc_llvm got out of sync with the version in LLVM and it caused two variants of the #[linkage=""] attribute to break.

This adds the functions `LLVMRustGetLinkage` and `LLVMRustSetLinkage` which convert between the Rust Linkage enum and the LLVM one, which should stop this from breaking every time LLVM changes it.

Fixes #33992
2016-09-04 16:12:01 -05:00