Commit Graph

45 Commits

Author SHA1 Message Date
Nicholas Nethercote
87b103d4a9 Add a "total" measurement to -Ztime-passes.
This is useful for getting the total compilation time at the end.
To do this, the patch changes `print_time_passes_entry` to not increment
the depth, which means that `print_time_passes_entry_internal` is no
longer needed.
2019-07-05 08:19:48 +10:00
Mazdak Farrokhzad
88c007cd04
Rollup merge of #62249 - czipperz:use-mem-take-instead-of-replace-default, r=dtolnay,Centril
Use mem::take instead of mem::replace with default
2019-07-04 01:38:46 +02:00
Chris Gregory
636f5e6d11 Convert more usages over 2019-07-01 20:21:12 -07:00
Michael Woerister
b7fe2ca5e0 Stabilize profile-guided optimization. 2019-06-21 09:54:58 +02:00
Eduard-Mihai Burtescu
f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
Eduard-Mihai Burtescu
fff08cb043 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-12 13:38:28 +03:00
Eduard-Mihai Burtescu
17cdd356da rustc: replace TyCtxt<'tcx, 'gcx, 'tcx> with TyCtxt<'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Michael Woerister
64ee32e53a Rename PgoGenerate to something more general. 2019-05-28 16:14:34 +02:00
Michael Woerister
e943426045 Use a PathBuf instead of String for representing the pgo-use path internally. 2019-05-27 14:32:03 +02:00
Chandler Deng
ba3785ec0a add targetarch for CodegenContext 2019-05-16 15:05:56 -07:00
Nicholas Nethercote
999c1fc281 Remove the equality operation between Symbol and strings.
And also the equality between `Path` and strings, because `Path` is made
up of `Symbol`s.
2019-05-13 09:31:30 +10:00
Nicholas Nethercote
fb084a48e2 Pass a Symbol to check_name, emit_feature_err, and related functions. 2019-05-13 09:29:22 +10:00
Nicholas Nethercote
7bcb0cffb6 In JSON output, emit a directive after metadata is generated.
To implement pipelining, Cargo needs to know when metadata generation is
finished. This commit adds code to do that. Unfortunately, metadata file
writing currently occurs very late during compilation, so pipelining
won't produce a speed-up. Moving metadata file writing earlier will be a
follow-up.

The change involves splitting the existing `Emitter::emit` method in
two: `Emitter::emit_diagnostic` and `Emitter::emit_directive`.

The JSON directives look like this:
```
{"directive":"metadata file written: liba.rmeta"}
```
The functionality is behind the `-Z emit-directives` option, and also
requires `--error-format=json`.
2019-04-30 08:51:57 +10:00
Nicholas Nethercote
3fc0936546 Don't generate unnecessary rmeta files. 2019-04-24 09:55:11 +10:00
Mazdak Farrokhzad
021a8eca47
Rollup merge of #59874 - michaelwoerister:pgo-updates-1, r=cramertj
Clean up handling of `-Z pgo-gen` commandline option.

This PR adapts the `-Z pgo-gen` flag to how Clang and GCC handle the corresponding `-fprofile-generate` flag. In particular, the flag now optionally takes a directory to place the profiling data in and allows to omit the argument (instead of having to pass an empty string).
2019-04-14 00:39:46 +02:00
Wesley Wiser
56e434d84d Use measureme in self-profiler
Related to #58372
Related to #58967
2019-04-12 20:27:29 -04:00
Michael Woerister
7b1df42acc Clean up handling of -Zpgo-gen commandline option. 2019-04-11 14:50:32 +02:00
Mazdak Farrokhzad
9f9529acd5
Rollup merge of #58507 - Zoxc:time-extended, r=michaelwoerister
Add a -Z time option which prints only passes which runs once

This ensures `-Z time-passes` fits on my screen =P

r? @michaelwoerister
2019-04-01 17:29:48 +02:00
Simonas Kazlauskas
8d4afbe413 Use informational target machine for metadata
Since there is nothing to optimise there...
2019-03-27 04:03:42 +02:00
John Kåre Alsaker
e842f570d9 Add a -Z time option which prints only passes which runs once 2019-03-20 07:54:46 +01:00
Wesley Wiser
4c8cc14186 Replace TimeLine with SelfProfiler 2019-03-10 11:10:55 -04:00
Esteban Küber
7a55a004fa Make -Z treat-err-as-bug take a number of errors to be emitted
`-Z treat-err-as-bug=0` will cause `rustc` to panic after the first
error is reported. `-Z treat-err-as-bug=2` will cause `rustc` to
panic after 3 errors have been reported.
2019-03-06 19:51:32 -08:00
Wesley Wiser
25b8c614f0 Wrap the self-profiler in an Arc<Mutex<>>
This will allow us to send it across threads and measure things like
LLVM time.
2019-03-03 10:07:29 -05:00
Mazdak Farrokhzad
1d34f2c228 librustc_codegen_ssa: deny(elided_lifetimes_in_paths) 2019-02-25 08:52:46 +01:00
Mazdak Farrokhzad
2a539a1b91
Rollup merge of #58378 - alexcrichton:incremental-lto, r=michaelwoerister
rustc: Implement incremental "fat" LTO

Currently the compiler will produce an error if both incremental
compilation and full fat LTO is requested. With recent changes and the
advent of incremental ThinLTO, however, all the hard work is already
done for us and it's actually not too bad to remove this error!

This commit updates the codegen backend to allow incremental full fat
LTO. The semantics are that the input modules to LTO are all produce
incrementally, but the final LTO step is always done unconditionally
regardless of whether the inputs changed or not. The only real
incremental win we could have here is if zero of the input modules
changed, but that's so rare it's unlikely to be worthwhile to implement
such a code path.

cc #57968
cc rust-lang/cargo#6643
2019-02-14 08:24:15 +01:00
Mazdak Farrokhzad
1c1d2e44c5
Rollup merge of #58057 - michaelwoerister:stabilize-xlto, r=alexcrichton
Stabilize linker-plugin based LTO (aka cross-language LTO)

This PR stabilizes [linker plugin based LTO](https://github.com/rust-lang/rust/issues/49879), also known as "cross-language LTO" because it allows for doing inlining and other optimizations across language boundaries in mixed Rust/C/C++ projects.

As described in the tracking issue, it works by making `rustc` emit LLVM bitcode instead of machine code, the same as `clang` does. A linker with the proper plugin (like LLD) can then run (Thin)LTO across all modules.

The feature has been implemented over a number of pull requests and there are various [codegen](https://github.com/rust-lang/rust/blob/master/src/test/codegen/no-dllimport-w-cross-lang-lto.rs) and [run](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/cross-lang-lto-clang)-[make](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs) [tests](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/cross-lang-lto) that make sure that it keeps working.

It also works for building big projects like [Firefox](https://treeherder.mozilla.org/#/jobs?repo=try&revision=2ce2d5ddcea6fbff790503eac406954e469b2f5d).

The PR makes the feature available under the `-C linker-plugin-lto` flag. As discussed in the tracking issue it is not cross-language specific and also not LLD specific. `-C linker-plugin-lto` is descriptive of what it does. If someone has a better name, let me know `:)`
2019-02-13 04:36:59 +01:00
bors
b244f61b77 Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnik
Cosmetic improvements to doc comments

This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase).

r? @steveklabnik

Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-12 19:09:24 +00:00
Michael Woerister
04f425d2c3 Stabilize linker-plugin based LTO. 2019-02-12 15:10:29 +01:00
Alex Crichton
e983b4f64e rustc: Implement incremental "fat" LTO
Currently the compiler will produce an error if both incremental
compilation and full fat LTO is requested. With recent changes and the
advent of incremental ThinLTO, however, all the hard work is already
done for us and it's actually not too bad to remove this error!

This commit updates the codegen backend to allow incremental full fat
LTO. The semantics are that the input modules to LTO are all produce
incrementally, but the final LTO step is always done unconditionally
regardless of whether the inputs changed or not. The only real
incremental win we could have here is if zero of the input modules
changed, but that's so rare it's unlikely to be worthwhile to implement
such a code path.

cc #57968
cc rust-lang/cargo#6643
2019-02-12 04:58:31 -08:00
Alexander Regueiro
c3e182cf43 rustc: doc comments 2019-02-10 23:42:32 +00:00
Taiki Endo
be71fccf11 librustc_codegen_ssa => 2018 2019-02-09 23:31:47 +09:00
Simonas Kazlauskas
f38d0da893 Implement optimize(size) and optimize(speed) 2019-01-24 20:13:50 +02:00
Peter Jin
b91d211b40 Add a target option "merge-functions" taking values in ("disabled",
"trampolines", or "aliases (the default)) to allow targets to opt out of
the MergeFunctions LLVM pass. Also add a corresponding -Z option with
the same name and values.

This works around: https://github.com/rust-lang/rust/issues/57356

Motivation:

Basically, the problem is that the MergeFunctions pass, which rustc
currently enables by default at -O2 and -O3, and `extern "ptx-kernel"`
functions (specific to the NVPTX target) are currently not compatible
with each other. If the MergeFunctions pass is allowed to run, rustc can
generate invalid PTX assembly (i.e. a PTX file that is not accepted by
the native PTX assembler ptxas). Therefore we would like a way to opt
out of the MergeFunctions pass, which is what our target option does.

Related work:

The current behavior of rustc is to enable MergeFunctions at -O2 and -O3,
and also to enable the use of function aliases within MergeFunctions.
MergeFunctions both with and without function aliases is incompatible with
the NVPTX target.

clang's "solution" is to have a "-fmerge-functions" flag that opts in to
the MergeFunctions pass, but it is not enabled by default.
2019-01-05 09:59:25 -08:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07: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
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
Nikita Popov
8128d0d1a9 Serialize modules into ThinBuffer after initial optimization
Instead of keeping all modules in memory until thin LTO and only
serializing them then, serialize the module immediately after
it finishes optimizing.
2018-12-04 16:24:20 +01:00
Nikita Popov
bc2db43b9e Remove unnecessary parts of run_fat_lto signature
Fat LTO merges into one module, so only return one module.
2018-12-04 16:10:24 +01:00
Nikita Popov
bdbee6311b Separate out methods for running thin and fat LTO 2018-12-04 16:10:24 +01:00
Nikita Popov
a17de6980a Separate codepaths for fat and thin LTO in write.rs
These are going to have different intermediate artifacts, so
create separate codepaths for them.
2018-12-04 16:10:24 +01:00
Nikita Popov
2c1883c1a6 Refactor LTO type determination
Instead of only determining whether some form of LTO is necessary,
determine whether thin, fat or no LTO is necessary. I've rewritten
the conditions in a way that I think is more obvious, i.e. specified
LTO type + additional preconditions.
2018-12-04 16:10:24 +01:00
Nikita Popov
9c657e82df Extract free_worker closure 2018-12-04 16:10:24 +01:00
Eduard-Mihai Burtescu
0b569249c8 [eddyb] rustc_codegen_ssa: rename interfaces to traits. 2018-11-16 15:08:18 +02:00
Eduard-Mihai Burtescu
d1410ada92 [eddyb] rustc_codegen_ssa: avoid a Clone bound on TargetMachine. 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