Commit Graph

49 Commits

Author SHA1 Message Date
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
Denis Merigoux 8d530db2c5 Generalized base:codegen_crate 2018-11-16 14:36:43 +02:00
Denis Merigoux 4787b7cac9 Removed phantomdata no longer necessary
Because CodegenContext doesn't implement Backend anymore
2018-11-16 14:11:59 +02:00
Denis Merigoux 4cc18d3de5 CommonWriteMethods are not static any more 2018-11-16 14:11:59 +02:00
bors 775eab5883 Auto merge of #55698 - nikic:remove-llvm-4-support, r=alexcrichton
Remove support for building against LLVM 4

With emscripten removed in #55626, we no longer need to support building against LLVM 4.
2018-11-11 22:38:54 +00:00
ljedrz 3dbb2cc864 codegen_llvm_back: improve common patterns 2018-11-10 19:25:22 +01:00
ljedrz c4c39e9395 codegen_llvm_back: use Cow<'static, str> where applicable 2018-11-10 19:22:38 +01:00
ljedrz 1d1dc48407 codegen_llvm_back: whitespace & formatting fixes 2018-11-10 19:22:37 +01:00
Nikita Popov 66702fcd0a Run name-anon-globals after LTO passes as well
If we're going to emit bitcode (through ThinLTOBuffer), then we
need to ensure that anon globals are named. This was already done
after optimization passes, but also has to happen after LTO passes,
as we always emit the final result in a ThinLTO-compatible manner.

Fixes #51947.
2018-11-06 19:24:28 +01:00
Nikita Popov 3cc8b17451 Remove support for building against LLVM 4
With emscripten removed in #55626, we no longer need to support
building against LLVM 4.
2018-11-05 15:04:26 +01:00
bjorn3 942864a000 Move cg_llvm:🔙:linker to cg_utils 2018-11-03 13:35:09 +01:00
Alex Crichton 086f5a55be Revert "rustc: Fix (again) simd vectors by-val in ABI"
This reverts commit 3cc8f738d4.
2018-10-23 00:59:14 -07:00
Manish Goregaokar b860765355 Rollup merge of #55073 - alexcrichton:demote-simd, r=nagisa
The issue of passing around SIMD types as values between functions has
seen [quite a lot] of [discussion], and although we thought [we fixed
it][quite a lot] it [wasn't]! This PR is a change to rustc to, again,
try to fix this issue.

The fundamental problem here remains the same, if a SIMD vector argument
is passed by-value in LLVM's function type, then if the caller and
callee disagree on target features a miscompile happens. We solve this
by never passing SIMD vectors by-value, but LLVM will still thwart us
with its argument promotion pass to promote by-ref SIMD arguments to
by-val SIMD arguments.

This commit is an attempt to thwart LLVM thwarting us. We, just before
codegen, will take yet another look at the LLVM module and demote any
by-value SIMD arguments we see. This is a very manual attempt by us to
ensure the codegen for a module keeps working, and it unfortunately is
likely producing suboptimal code, even in release mode. The saving grace
for this, in theory, is that if SIMD types are passed by-value across
a boundary in release mode it's pretty unlikely to be performance
sensitive (as it's already doing a load/store, and otherwise
perf-sensitive bits should be inlined).

The implementation here is basically a big wad of C++. It was largely
copied from LLVM's own argument promotion pass, only doing the reverse.
In local testing this...

Closes #50154
Closes #52636
Closes #54583
Closes #55059

[quite a lot]: https://github.com/rust-lang/rust/pull/47743
[discussion]: https://github.com/rust-lang/rust/issues/44367
[wasn't]: https://github.com/rust-lang/rust/issues/50154
2018-10-20 13:15:39 -07: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
Alex Crichton 3cc8f738d4 rustc: Fix (again) simd vectors by-val in ABI
The issue of passing around SIMD types as values between functions has
seen [quite a lot] of [discussion], and although we thought [we fixed
it][quite a lot] it [wasn't]! This PR is a change to rustc to, again,
try to fix this issue.

The fundamental problem here remains the same, if a SIMD vector argument
is passed by-value in LLVM's function type, then if the caller and
callee disagree on target features a miscompile happens. We solve this
by never passing SIMD vectors by-value, but LLVM will still thwart us
with its argument promotion pass to promote by-ref SIMD arguments to
by-val SIMD arguments.

This commit is an attempt to thwart LLVM thwarting us. We, just before
codegen, will take yet another look at the LLVM module and demote any
by-value SIMD arguments we see. This is a very manual attempt by us to
ensure the codegen for a module keeps working, and it unfortunately is
likely producing suboptimal code, even in release mode. The saving grace
for this, in theory, is that if SIMD types are passed by-value across
a boundary in release mode it's pretty unlikely to be performance
sensitive (as it's already doing a load/store, and otherwise
perf-sensitive bits should be inlined).

The implementation here is basically a big wad of C++. It was largely
copied from LLVM's own argument promotion pass, only doing the reverse.
In local testing this...

Closes #50154
Closes #52636
Closes #54583
Closes #55059

[quite a lot]: https://github.com/rust-lang/rust/pull/47743
[discussion]: https://github.com/rust-lang/rust/issues/44367
[wasn't]: https://github.com/rust-lang/rust/issues/50154
2018-10-19 02:35:00 -07:00
Michael Woerister ca197323b9 incr.comp.: Allow for more fine-grained testing of CGU reuse and use it to test incremental ThinLTO. 2018-09-18 16:33:24 +02:00
kennytm 07dc4b3759
Rollup merge of #53950 - michaelwoerister:more-lto-cli, r=alexcrichton
Allow for opting out of ThinLTO and clean up LTO related cli flag handling.

It turns out that there currently is no way to explicitly disable ThinLTO (except for the nightly-only `-Zthinlto` flag). This PR extends `-C lto` to take `yes` and `no` in addition to `thin` and `fat`. It should be backwards compatible.

It also cleans up how LTO mode selection is handled.

Note that merging the PR in the current state would make the new values for `-C lto` available on the stable channel. I think that would be fine but maybe some team should vote on it.
2018-09-14 00:46:45 +08:00
Michael Woerister fc47a92336 ThinLTO: Don't keep files open after mmaping them (because it's not needed). 2018-09-05 13:52:58 +02:00
Michael Woerister 24093a6bdb Allow for opting out of ThinLTO and clean up LTO related cli flag handling. 2018-09-05 12:52:17 +02:00
Michael Woerister 21d05f64aa incr.ThinLTO: Do some cleanup and add some logging. 2018-09-03 13:26:46 +02:00
Michael Woerister abd5cc3364 Always add all modules to the global ThinLTO module analysis when compiling incrementally. 2018-08-31 15:22:52 +02:00
Michael Woerister 64a738d8ce Support local ThinLTO with incremental compilation. 2018-08-31 15:22:52 +02:00
Michael Woerister d97d1e192b Persist ThinLTO import data in incr. comp. session directory. 2018-08-31 15:22:52 +02:00
Michael Woerister d662083a6c Use CGU name as LLVM module name and add some caching to CGU name generation. 2018-08-15 14:50:54 +02:00
Michael Woerister 3a3b3317d9 Fix issue around dllimport and ThinLTO as LLD runs it. 2018-08-07 14:44:48 +02: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
Alex Crichton f0bceba669 rustc: Handle linker diagnostic from LLVM
Previously linker diagnostic were being hidden when two modules were linked
together but failed to link. This commit fixes the situation by ensuring that we
have a diagnostic handler installed and also adds support for handling linker
diagnostics.
2018-07-31 10:47:27 -07:00
Irina Popa ba006440ee rustc_codegen_llvm: use safe references for ThinLTOData. 2018-07-30 20:34:51 +03:00
Irina Popa 2e3a6af7fa rustc_codegen_llvm: use safe references for ThinLTOBuffer. 2018-07-30 20:10:47 +03:00
Irina Popa ab4f93c742 rustc_codegen_llvm: use safe references for ModuleBuffer. 2018-07-30 20:10:45 +03:00
Irina Popa 894467e5b4 rustc_codegen_llvm: use safe references for Linker. 2018-07-30 20:10:41 +03:00
Irina Popa 0e3a705269 rustc_codegen_llvm: use safe references for TargetMachine. 2018-07-30 20:10:31 +03:00
Irina Popa 55af020194 rustc_codegen_llvm: use safe references for Pass. 2018-07-30 20:10:30 +03:00
Irina Popa 249d5acaec rustc_codegen_llvm: use safe references for Context and Module. 2018-07-30 18:27:52 +03:00
ljedrz 421b2ba347 Don't format!() string literals 2018-07-28 17:58:52 +02:00
Alex Crichton 829bc268a9 rustc: Remove a workaroudn in ThinLTO fixed upstream
This commit removes a hack in our ThinLTO passes which removes available
externally functions manually. The [upstream bug][1] has long since been fixed,
so we should be able to rely on LLVM natively for this now!

[1]: https://bugs.llvm.org/show_bug.cgi?id=35736
2018-07-18 11:37:56 -07:00
Michael Woerister d992090a70 Revert "Provide a way of accessing the ThinLTO module import map in rustc."
This reverts commit 9df56ca0ee.
2018-07-16 08:59:10 +02:00
Michael Woerister 5c0110f44b Revert "Persist ThinLTO import data in incr. comp. session directory."
This reverts commit 8dc7ddb976.
2018-07-16 08:58:56 +02:00
Michael Woerister 0830cc92bd Revert "Clean up LLVM module naming (just use CodegenUnit names)."
This reverts commit f6894ebe66.
2018-07-16 08:58:29 +02:00
Michael Woerister b822e699c3 Revert "Use callback-based interface to load ThinLTO import data into rustc."
This reverts commit e045a6cd8c.
2018-07-16 08:57:49 +02:00
Michael Woerister e045a6cd8c Use callback-based interface to load ThinLTO import data into rustc. 2018-07-13 12:41:22 +02:00
Michael Woerister f6894ebe66 Clean up LLVM module naming (just use CodegenUnit names). 2018-07-11 21:54:43 +02:00
Michael Woerister 8dc7ddb976 Persist ThinLTO import data in incr. comp. session directory. 2018-07-11 17:52:57 +02:00
Michael Woerister 9df56ca0ee Provide a way of accessing the ThinLTO module import map in rustc. 2018-07-11 17:51:36 +02:00
Nikita Popov 22cf833dd1 Rename -Z no-verify to -Z verify-llvm-ir
This disables IR verification by default.
2018-06-12 21:23:06 +02:00
Nikita Popov 78a16443a3 Respect -Z no-verify during LTO
Currently -Z no-verify only controls IR verification prior to
LLVM codegen, while verification is performed unconditionally
both before and after linking with (Thin)LTO.
2018-06-12 20:50:21 +02:00
Irina Popa b63d7e2b1c Rename trans to codegen everywhere. 2018-05-17 15:08:30 +03:00