Commit Graph

202 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu
08d27441ec rustc: move the formatter into ty::print::PrintCx. 2019-03-15 09:26:13 +02:00
Eduard-Mihai Burtescu
387cacf76b rustc: remove ty::item_path::RootMode by moving local logic into the printer. 2019-03-15 09:26:13 +02:00
Eduard-Mihai Burtescu
7d211e5b12 rustc: rewrite ty::item_path to be more functional than mutation-oriented. 2019-03-15 09:26:13 +02:00
Eduard-Mihai Burtescu
7505bb6bbb rustc_codegen_utils: revert some symbol_names refactors (while keeping the functional changes). 2019-03-15 09:26:13 +02:00
Eduard-Mihai Burtescu
228d6f45d8 rustc: remove unnecessary extern_prelude logic from ty::item_path. 2019-03-15 09:26:13 +02:00
John Kåre Alsaker
51938c61f6 Make the rustc driver and interface demand driven 2019-03-10 04:49:45 +01:00
ljedrz
cd06038b54 HirIdification: replace NodeId method calls 2019-03-07 09:22:43 +01:00
varkor
2ce19ae3d1 Use non_erasable_generics for codegen
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-03-05 22:07:37 +00:00
ljedrz
e72584c3a1 hir: remove NodeId from TraitItem 2019-03-01 11:18:49 +01:00
csmoe
ccfa5d6df8 replace &'tcx Substs with SubstsRef 2019-02-26 19:30:57 +08:00
Mazdak Farrokhzad
d7a4dd1074
Rollup merge of #58259 - taiki-e:librustc_codegen_utils-2018, r=Centril
librustc_codegen_utils => 2018

Transitions `librustc_codegen_utils` to Rust 2018; cc #58099

r? @Centril
2019-02-09 00:15:59 +01:00
Taiki Endo
0e622a8ba1 librustc_codegen_utils => 2018 2019-02-08 21:06:07 +09:00
Guillaume Gomez
8b886e07f5 Remove images' url to make it work even without internet connection 2019-02-07 11:06:19 +01:00
Denys Zariaiev
8d53c9247c SymbolPathBuffer shallow refactoring 2019-01-28 01:16:59 +01:00
Denys Zariaiev
d3903d5f9c Create nvptx64-nvidia-cuda target specification 2019-01-27 16:04:09 +01:00
Mark Simulacrum
db97c48ad6 Remove quote_*! macros and associated APIs 2019-01-24 07:37:34 -07:00
Igor Matuszewski
ff19a53ef0 Querify entry_fn 2019-01-15 11:10:51 +01:00
Mazdak Farrokhzad
2e1094429d
Rollup merge of #57570 - Xanewok:querify-some, r=Zoxc
Querify local `plugin_registrar_fn` and `proc_macro_decls_static`

Instead of calculating them as part of the `Session`, we do that in the query system.
It's also nice that these queries are already defined for external crates - here, we provide the queries for the local crate.

r? @nikomatsakis
2019-01-14 20:31:56 +01:00
Igor Matuszewski
59d7d7d54b Querify local plugin_registrar_fn 2019-01-13 23:53:58 +01:00
Igor Matuszewski
fb6040096c Querify local proc_macro_decls_static 2019-01-13 23:52:00 +01:00
lqd
e5318f3f9b MetadataOnlyCodegenBackend: remove is_inline call
This function has no side effects, and its result is ignored.
2019-01-09 14:21:46 +01:00
lqd
c075e245de Codegen: run the collector only once
Use the `collect_and_partition_mono_items ` query to avoid calling the collector
2019-01-07 19:48:45 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
bors
059e6a6f57 Auto merge of #56578 - alexreg:cosmetic-1, r=alexreg
Various minor/cosmetic improvements to code

r? @Centril 😄
2018-12-08 03:50:16 +00:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
bors
0a77980796 Auto merge of #56258 - euclio:fs-read-write, r=euclio
use top level `fs` functions where appropriate

This commit replaces many usages of `File::open` and reading or writing
with `fs::read_to_string`, `fs::read` and `fs::write`. This reduces code
complexity, and will improve performance for most reads, since the
functions allocate the buffer to be the size of the file.

I believe that this commit will not impact behavior in any way, so some
matches will check the error kind in case the file was not valid UTF-8.
Some of these cases may not actually care about the error.
2018-12-07 23:26:14 +00:00
bors
4a45578bc5 Auto merge of #56502 - Zoxc:hir-func, r=eddyb
Use a function to access the Hir map to be able to turn it into a query later

r? @eddyb
2018-12-07 20:04:06 +00:00
Andy Russell
2f6226518b
use top level fs functions where appropriate
This commit replaces many usages of `File::open` and reading or writing
with `fs::read_to_string`, `fs::read` and `fs::write`. This reduces code
complexity, and will improve performance for most reads, since the
functions allocate the buffer to be the size of the file.

I believe that this commit will not impact behavior in any way, so some
matches will check the error kind in case the file was not valid UTF-8.
Some of these cases may not actually care about the error.
2018-12-07 12:54:11 -05:00
ljedrz
adaeb10b5b codegen_utils, driver: fix clippy errors 2018-12-06 21:14:23 +01:00
John Kåre Alsaker
a70babed03 Use a function to access the Hir map to be able to turn it into a query later 2018-12-06 17:24:36 +01:00
ljedrz
d0c64bb296 cleanup: remove static lifetimes from consts 2018-12-04 12:46:10 +01:00
bors
21f2684950 Auto merge of #56198 - bjorn3:cg_ssa_refactor, r=eddyb
Refactor rustc_codegen_ssa

cc #56108 (not all things are done yet)

This removes an unsafe method from cg_ssa.

r? @eddyb
cc @sunfishcode
2018-12-02 18:02:20 +00:00
Eduard-Mihai Burtescu
e305994beb proc_macro: introduce a "bridge" between clients (proc macros) and servers (compiler front-ends). 2018-11-30 06:15:19 +02:00
bjorn3
8698f5c43d Remove __build_diagnostic_array! from cg_utils 2018-11-29 18:19:41 +01:00
Eduard-Mihai Burtescu
9f49a2626e [eddyb] rustc_codegen_utils: remove extraneous #![allow(dead_code)]. 2018-11-16 15:08:18 +02:00
Denis Merigoux
b9e5cf99a9 Separating the back folder between backend-agnostic and LLVM-specific code 2018-11-16 15:08:18 +02:00
Denis Merigoux
c9f26c2155 Beginning of moving all backend-agnostic code to rustc_codegen_ssa 2018-11-16 14:55:42 +02:00
Denis Merigoux
b02e5cce16 Moved Backend interface into rustc_codegen_utils 2018-11-16 14:40:16 +02:00
Eduard-Mihai Burtescu
b06836e71a [eddyb/rebase cleanup] move type_{needs_drop,is_sized,is_freeze} to rustc_codegen_utils 2018-11-16 14:40:16 +02:00
Denis Merigoux
566fa4d003 Moved common.rs enums 2018-11-16 14:38:19 +02:00
Denis Merigoux
39fd4d9274 Starting to move backend-agnostic code into codegen_utils
IntPredicate moved
2018-11-16 14:38:19 +02:00
Pietro Albini
66fcb3ceb2
Rollup merge of #55901 - euclio:speling, r=petrochenkov
fix various typos in doc comments
2018-11-15 11:04:42 +01:00
Michael Woerister
4cfc97924f xLTO: Don't pass --plugin-opt=thin to LLD. That's not supported anymore. 2018-11-14 14:42:49 +01:00
Andy Russell
4e35cbb22e
fix various typos in doc comments 2018-11-13 14:45:31 -05:00
Bruce Mitchener
a62af858e0 Fix typos. 2018-11-11 20:52:36 +07:00
ljedrz
3968ada006 codegen_llvm_back: use mem::replace instead of swap where more concise 2018-11-10 19:25:24 +01:00
ljedrz
0195d9b95f codegen_llvm_back: use to_owned instead of to_string with string literals 2018-11-10 19:25:23 +01:00
ljedrz
3dbb2cc864 codegen_llvm_back: improve common patterns 2018-11-10 19:25:22 +01:00
ljedrz
1d1dc48407 codegen_llvm_back: whitespace & formatting fixes 2018-11-10 19:22:37 +01:00
bors
06118eac4c Auto merge of #55626 - nikic:update-emscripten, r=alexcrichton
Update emscripten

This updates emscripten to 1.38.15, which is based on LLVM 6.0.1 and would allow us to drop code for handling LLVM 4.

The main issue I ran into is that exporting statics through `EXPORTED_FUNCTIONS` no longer works. As far as I understand exporting non-functions doesn't really make sense under emscripten anyway, so I've modified the symbol export code to not even try.

Closes #52323.
2018-11-10 01:16:02 +00:00
kennytm
9d9146ad95
Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwco
refactor: use shorthand fields

refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07 21:27:00 +08:00
teresy
eca11b99a7 refactor: use shorthand fields 2018-11-06 15:05:44 -05:00
Nikita Popov
c14bc575d6 Don't export non-function symbols with emscripten
Emscripten only provides an export mechanism for functions.
Exporting statics does not make sense conceptually in this case,
and will result in emcc undefined function errors.
2018-11-04 18:50:58 +01:00
bjorn3
c8599191e8 Remove rustc_metadata_utils, which contains only one function 2018-11-03 14:31:09 +01:00
bjorn3
942864a000 Move cg_llvm:🔙:linker to cg_utils 2018-11-03 13:35:09 +01:00
bors
cae6efc37d Auto merge of #54183 - qnighy:by-value-object-safety, r=oli-obk
Implement by-value object safety

This PR implements **by-value object safety**, which is part of unsized rvalues #48055. That means, with `#![feature(unsized_locals)]`, you can call a method `fn foo(self, ...)` on trait objects. One aim of this is to enable `Box<FnOnce>`  in the near future.

The difficulty here is this: when constructing a vtable for a trait `Foo`, we can't just put the function `<T as Foo>::foo` into the table. If `T` is no larger than `usize`, `self` is usually passed directly. However, as the caller of the vtable doesn't know the concrete `Self` type, we want a variant of `<T as Foo>::foo` where `self` is always passed by reference.

Therefore, when the compiler encounters such a method to be generated as a vtable entry, it produces a newly introduced instance called `InstanceDef::VtableShim(def_id)` (that wraps the original instance). the shim just derefs the receiver and calls the original method. We give different symbol names for the shims by appending `::{{vtable-shim}}` to the symbol path (and also adding vtable-shimness as an ingredient to the symbol hash).

r? @eddyb
2018-10-27 19:29:35 +00:00
Shotaro Yamada
3878d24ef6 Remove redundant clone 2018-10-26 12:07:39 +09:00
Masaki Hara
2075316064 Include InstanceDef's discriminant in the symbol hash. 2018-10-24 21:59:07 +09:00
Masaki Hara
824315a722 Distinguish vtable shims in symbol paths. 2018-10-24 21:59:06 +09:00
bors
ca2639e82e Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasper
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations

The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`.

An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).
2018-10-20 11:22:48 +00:00
Oliver Scherer
3c9258e604 Prefer Default::default over FxHash*::default in struct constructors 2018-10-19 14:34:44 +02:00
Oliver Scherer
ee81739dc1 Deprecate the FxHashMap() and FxHashSet() constructor function hack 2018-10-19 14:34:44 +02:00
ljedrz
d28aed6dc4 Prefer unwrap_or_else to unwrap_or in case of function calls/allocations 2018-10-19 09:45:45 +02:00
David Wood
02357e459b
Attempt to resolve linking issues.
This commit takes a different approach to add the `crate::` prefix to
item paths than previous commits. Previously, recursion was stopped
after a prelude crate name was pushed to the path. It is theorized that
this was the cause of the linking issues since the same path logic is
used for symbol names and that not recursing meant that details were
being missed that affect symbol names. As of this commit, instead of
ceasing recursion, a flag is passed through to any subsequent recursive
calls so that the same effect can be achieved by checking that flag.
2018-10-02 01:16:08 +02:00
David Wood
9e2d6e1e62
Add crate:: to trait suggestions in Rust 2018.
In the 2018 edition, when suggesting traits to import that implement a
given method that is being invoked, suggestions will now include the
`crate::` prefix if the suggested trait is local to the current crate.
2018-10-02 01:16:05 +02:00
bors
6310be458f Auto merge of #54601 - cuviper:prep-1.31, r=Mark-Simulacrum
Bump to 1.31.0 and bootstrap from 1.30 beta

Closes #54594.
2018-09-30 01:45:50 +00:00
Josh Stone
ce034951fb Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
Igor Matuszewski
cddd00a1e6 Move filename_for_metadata to codegen_utils
This function isn't strictly tied to LLVM (it's more of a utility) and
it's now near an analogous, almost identical `filename_for_input` (for
rlibs and so forth).
Also this means not depending on the backend when one wants to know the
accurate .rmeta output filename.
2018-09-28 01:53:59 +02:00
toidiu
731f4efae5 stabalize infer outlives requirements (RFC 2093).
Co-authored-by: nikomatsakis
2018-09-11 11:40:04 -04:00
varkor
e2a1cce9c5 Rename hir::map::NodeKind to hir::Node 2018-08-27 21:46:23 +01:00
varkor
11665ca45a Remove path prefixes from NodeKind 2018-08-27 21:46:13 +01:00
varkor
befc4b1100 Rename hir::map::Node to hir::map::NodeKind 2018-08-27 21:45:46 +01:00
bors
70a21e89f1 Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis
fix for late-bound regions

Fix for https://github.com/rust-lang/rust/issues/53419

r? @nikomatsakis
2018-08-27 17:42:45 +00:00
Alex Crichton
0a2282e128 rustc: Continue to tweak "std internal symbols"
In investigating [an issue][1] with `panic_implementation` defined in an
executable that's optimized I once again got to rethinking a bit about the
`rustc_std_internal_symbol` attribute as well as weak lang items. We've sort of
been non-stop tweaking these items ever since their inception, and this
continues to the trend.

The crux of the bug was that in the reachability we have a [different branch][2]
for non-library builds which meant that weak lang items (and std internal
symbols) weren't considered reachable, causing them to get eliminiated by
ThinLTO passes. The fix was to basically tweak that branch to consider these
symbols to ensure that they're propagated all the way to the linker.

Along the way I've attempted to erode the distinction between std internal
symbols and weak lang items by having weak lang items automatically configure
fields of `CodegenFnAttrs`. That way most code no longer even considers weak
lang items and they're simply considered normal functions with attributes about
the ABI.

In the end this fixes the final comment of #51342

[1]: https://github.com/rust-lang/rust/issues/51342#issuecomment-414368019
[2]: 35bf1ae257/src/librustc/middle/reachable.rs (L225-L238)
2018-08-26 16:34:14 -07:00
Niko Matsakis
73fb1622b3 check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
varkor
6f637da50c Remove Ty prefix from Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error} 2018-08-22 16:07:44 +01:00
bjorn3
d52047faf0 Remove LinkMeta struct 2018-08-18 12:08:06 +02:00
Guillaume Gomez
3e9a1a1b82
Rollup merge of #53230 - memoryruins:nll_bootstrap_4, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap: part 4

#53172

r? @nikomatsakis
2018-08-12 23:26:56 +02:00
memoryruins
4b42a2100b [nll] librustc_codegen_utils: enable feature(nll) for bootstrap 2018-08-09 15:33:06 -04:00
Mark Rousskov
bf103700c6 Move SVH structure to data structures 2018-08-09 10:00:25 -06:00
Mark Rousskov
0ae2aa2320 Use diagnostic API on Session 2018-08-04 06:54:36 -06:00
Mark Rousskov
a9093a4dd8 Move share_generics getter onto options directly 2018-08-04 06:54:36 -06:00
Mark Rousskov
2a9344206b Normalize variants of CrateType to standard style
This is a clippy-breaking change.
2018-08-04 06:53:15 -06:00
Mark Rousskov
d4beecaed3 Move validate_crate_name to rustc_metadata 2018-08-03 11:09:02 -06:00
Tatsuyuki Ishi
e098985939 Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
ljedrz
715b8852e4 Deny bare trait objects in in src/librustc_codegen_utils 2018-07-11 17:39:49 +02:00
Alex Crichton
42eb85002a Upgrade to LLVM's master branch (LLVM 7)
This commit upgrades the main LLVM submodule to LLVM's current master branch.
The LLD submodule is updated in tandem as well as compiler-builtins.

Along the way support was also added for LLVM 7's new features. This primarily
includes the support for custom section concatenation natively in LLD so we now
add wasm custom sections in LLVM IR rather than having custom support in rustc
itself for doing so.

Some other miscellaneous changes are:

* We now pass `--gc-sections` to `wasm-ld`
* The optimization level is now passed to `wasm-ld`
* A `--stack-first` option is passed to LLD to have stack overflow always cause
  a trap instead of corrupting static data
* The wasm target for LLVM switched to `wasm32-unknown-unknown`.
* The syntax for aligned pointers has changed in LLVM IR and tests are updated
  to reflect this.
* The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug]

Nowadays we've been mostly only upgrading whenever there's a major release of
LLVM but enough changes have been happening on the wasm target that there's been
growing motivation for quite some time now to upgrade out version of LLD. To
upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet
another version of LLVM on the builders.

The revision of LLVM in use here is arbitrarily chosen. We will likely need to
continue to update it over time if and when we discover bugs. Once LLVM 7 is
fully released we can switch to that channel as well.

[llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
2018-07-10 13:43:01 -07:00
bjorn3
c7c534fa0e Move llvm_target_features back to llvm_util 2018-07-07 10:55:47 +02:00
bjorn3
c504d26c1c Move time_graph.rs to rustc/util 2018-07-07 10:52:31 +02:00
bjorn3
cd4989ee94 Leave fixme comment 2018-07-07 10:52:18 +02:00
bjorn3
097de536e4 Fix metadata_only metadata encoding 2018-07-07 10:52:15 +02:00
bjorn3
edd6ed571f Fix some errors 2018-07-07 10:51:54 +02:00
bjorn3
95ed511514 Mostly fix compiling without LLVM (with metadata_only backend) 2018-07-07 10:51:51 +02:00
bjorn3
6ceb1637b2 Move some functions out of rustc_codegen_llvm and fix metadata_only backend 2018-07-07 10:47:22 +02:00
Zack M. Davis
057715557b migrate codebase to ..= inclusive range patterns
These were stabilized in March 2018's #47813, and are the Preferred Way
to Do It going forward (q.v. #51043).
2018-06-26 07:53:30 -07:00
Eduard-Mihai Burtescu
5a5c7ded0d rustc: rename ty::maps to ty::query. 2018-06-14 18:05:12 +03:00
John Kåre Alsaker
b7aabaa3fc Update recursion limits 2018-06-01 14:56:01 +02:00
Vadim Petrochenkov
1e4269cb83 Add Ident::as_str helper 2018-05-26 15:20:23 +03:00
iancormac84
b79edf008f Added extra hashing step. 2018-05-17 16:41:33 -04:00
iancormac84
9041d81f78 Code structure edits. 2018-05-17 16:41:29 -04:00
iancormac84
9a746d5c1d Removed use of TypeIdHasher in symbol hash generation and replaced it with StableHasher. 2018-05-17 16:41:26 -04:00
Irina Popa
b63d7e2b1c Rename trans to codegen everywhere. 2018-05-17 15:08:30 +03:00