about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/back
AgeCommit message (Collapse)AuthorLines
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-5/+5
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-5/+5
2020-03-27Remove `no_integrated_as` mode.Nicholas Nethercote-38/+25
Specifically, remove both `-Z no_integrated_as` and `TargetOptions::no_integrated_as`. The latter was only used for the `msp430_none_elf` platform, for which it's no longer required.
2020-03-26Convert a chained if-else to a match.Nicholas Nethercote-33/+42
It makes things a little clearer.
2020-03-26Introduce `EmitObj`.Nicholas Nethercote-17/+15
Currently, there are three fields in `ModuleConfig` that dictate how object files are emitted: `emit_obj`, `obj_is_bitcode`, and `embed_bitcode`. Some of the combinations of these fields are nonsensical, in particular having both `obj_is_bitcode` and `embed_bitcode` true at the same time. Also, currently: - we needlessly emit and then delete a bytecode file if `obj_is_bitcode` is true but `emit_obj` is false; - we needlessly embed bitcode in the LLVM module if `embed_bitcode` is true and `emit_obj` is false. This commit combines the three fields into one, with a new type `EmitObj` (and the auxiliary `BitcodeSection`) which can encode five different possibilities. In the old code, `set_flags` would set `obj_is_bitcode` and `embed_bitcode` on all three of the configs (`modules`, `allocator`, `metadata`) if the relevant other conditions were met, even if no object code needed to be emitted for one or more of them. Whereas `start_async_codegen` would set `emit_obj`, but only for those configs that need it. In the new code, `start_async_codegen` does all the work of setting `emit_obj`, and it only does that for the configs that need it. `set_flags` no longer sets anything related to object file emission.
2020-03-24Rollup merge of #70289 - nnethercote:refactor-codegen, r=eddybMazdak Farrokhzad-92/+82
Refactor `codegen` `codegen` in `src/librustc_codegen_llvm/back/write.rs` is long and has complex control flow. These commits refactor it and make it easier to understand.
2020-03-23Factor out a repeated `config.no_integrated_as` test.Nicholas Nethercote-23/+25
2020-03-23Introduce a local variable `config_emit_normal_obj`.Nicholas Nethercote-3/+5
This adds a missing `!config.obj_is_bitcode` condition to two places that should have it. As a result, when `obj_is_bitcode` and `no_integrated_as` are both true, the compiler will no longer unnecessarily emit asm, convert it to an object file, and then overwrite that object file with bitcode.
2020-03-23Factor out a repeated `config.obj_is_bitcode` test.Nicholas Nethercote-9/+11
2020-03-23Remove an unnecessary block scope.Nicholas Nethercote-89/+79
2020-03-23Combine `ModuleConfig::embed_bitcode{,_marker}`.Nicholas Nethercote-3/+3
Because the `(true, true)` combination isn't valid.
2020-03-23Remove some local variables.Nicholas Nethercote-19/+13
I find the code easier to read if the values in `config` are all used directly, rather than a mix of `config` values and local variables. It will also faciliate some of the following commits. Also, use `config.bitcode_needed()` in one place.
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-3/+3
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-4/+4
2020-03-06fix various typosMatthias Krüger-4/+4
2020-03-04Don't use "if let" bindings to only check a value and not actually bind ↵Matthias Krüger-1/+1
anything. For example: `if let Some(_) = foo() {}` can be reduced to `if foo().is_some() {}` (clippy::redundant_pattern_matching)
2020-02-29Rollup merge of #69551 - matthiaskrgr:len_zero, r=Mark-SimulacrumDylan DPC-1/+1
use is_empty() instead of len() == x to determine if structs are empty.
2020-02-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-1/+1
2020-02-27use char instead of &str for single char patternsMatthias Krüger-1/+1
2020-02-13add selfprofiling for new llvm passmanagerAndreas Jonson-2/+79
2020-02-12Add support for new pass managerNikita Popov-18/+121
The new pass manager can be enabled using -Z new-llvm-pass-manager=on.
2020-02-10self-profile: Support arguments for generic_activities.Michael Woerister-57/+69
2020-01-09Change -Z time event naming scheme and make them generic activitiesJohn Kåre Alsaker-9/+25
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-2/+2
2020-01-05Use self profile infrastructure for -Z time and -Z time-passesJohn Kåre Alsaker-111/+96
2020-01-02Normalize `syntax::symbol` imports.Mazdak Farrokhzad-1/+1
2019-12-24x.py fmt after previous deignoreMark Rousskov-242/+251
2019-12-22Format the worldMark Rousskov-301/+266
2019-12-20save LTO import information and check it when trying to reuse build products.Felix S. Klock II-10/+114
adopts simple strategy devised with assistance from mw: Instead of accumulating (and acting upon) LTO import information over an unbounded number of prior compilations, just see if the current import set matches the previous import set. if they don't match, then you cannot reuse the PostLTO build product for that module. In either case (of a match or a non-match), we can (and must) unconditionally emit the current import set as the recorded information in the incremental compilation cache, ready to be loaded during the next compiler run for use in the same check described above. resolves issue 59535.
2019-12-11rustc: Link LLVM directly into rustc againAlex Crichton-4/+8
This commit builds on #65501 continue to simplify the build system and compiler now that we no longer have multiple LLVM backends to ship by default. Here this switches the compiler back to what it once was long long ago, which is linking LLVM directly to the compiler rather than dynamically loading it at runtime. The `codegen-backends` directory of the sysroot no longer exists and all relevant support in the build system is removed. Note that `rustc` still supports a dynamically loaded codegen backend as it did previously, it just no longer supports dynamically loaded codegen backends in its own sysroot. Additionally as part of this the `librustc_codegen_llvm` crate now once again explicitly depends on all of its crates instead of implicitly loading them through the sysroot. This involved filling out its `Cargo.toml` and deleting all the now-unnecessary `extern crate` annotations in the header of the crate. (this in turn required adding a number of imports for names of macros too). The end results of this change are: * Rustbuild's build process for the compiler as all the "oh don't forget the codegen backend" checks can be easily removed. * Building `rustc_codegen_llvm` is much simpler since it's simply another compiler crate. * Managing the dependencies of `rustc_codegen_llvm` is much simpler since it's "just another `Cargo.toml` to edit" * The build process should be a smidge faster because there's more parallelism in the main rustc build step rather than splitting `librustc_codegen_llvm` out to its own step. * The compiler is expected to be slightly faster by default because the codegen backend does not need to be dynamically loaded. * Disabling LLVM as part of rustbuild is still supported, supporting multiple codegen backends is still supported, and dynamic loading of a codegen backend is still supported.
2019-12-07Rollup merge of #67033 - cuviper:ValueName2, r=rkruppeYuki Okushi-4/+4
Migrate to LLVM{Get,Set}ValueName2 The deprecated `LLVM{Get,Set}ValueName` only work with NUL-terminated strings, but the `2` variants use explicit lengths, which fits better with Rust strings and slices. We now use these in new helper functions `llvm::{get,set}_value_name` that convert to/from `&[u8]`. Closes #64223. r? @rkruppe
2019-12-05Auto merge of #66952 - 0dvictor:print, r=rkruppebors-8/+5
Use Module::print() instead of a PrintModulePass llvm::Module has a print() method. It is unnecessary to create a pass just for the purpose of printing LLVM IR.
2019-12-04Migrate to LLVM{Get,Set}ValueName2Josh Stone-4/+4
The deprecated `LLVM{Get,Set}ValueName` only work with NUL-terminated strings, but the `2` variants use explicit lengths, which fits better with Rust strings and slices. We now use these in new helper functions `llvm::{get,set}_value_name` that convert to/from `&[u8]`.
2019-12-03Rollup merge of #66957 - parthsane:pvs/ftx_lld_linker, r=alexcrichtonMazdak Farrokhzad-1/+2
Change Linker for x86_64-fortanix-unknown-sgx target to rust-lld Changed linker for `x86_64-fortanix-unknown-sgx` target to `rust-lld` This change needed the RelaxELFRelocations flag to be set for it to work correctly r? @jethrogb
2019-12-03Move cgu_reuse_tracker to librustc_sessionMark Rousskov-1/+1
2019-12-03Change linker for x86_64-fortanix-unknown-sgx to rust-lldParth Sane-1/+2
For SGX, the relocation using the relocation table is done by the code in rust/src/libstd/sys/sgx/abi/reloc.rs and this code should not require relocation. Setting RelaxELFRelocations flag if allows this to happen, hence adding a Target Option for it.
2019-12-02Use Module::print() instead of a PrintModulePassVictor Ding-8/+5
llvm::Module has a print() method. It is unnecessary to create a pass just for the purpose of printing LLVM IR.
2019-12-01rustc_plugin: Remove support for plugins adding LLVM passesVadim Petrochenkov-14/+0
2019-11-29Use LLVMAddAnalysisPasses instead of Rust's wrapperVictor Ding-4/+4
LLVM exposes a C API `LLVMAddAnalysisPasses` and hence Rust's own wrapper `LLVMRustAddAnalysisPasses` is not needed anymore.
2019-11-22Create sanitizer passes in a separate functionTomasz Miąsko-20/+26
2019-11-22Add support for tracking origins of uninitialized memoryTomasz Miąsko-2/+2
2019-11-22Add support for sanitizer recoveryTomasz Miąsko-2/+1
2019-11-22Move sanitizer passes creation from ssa to llvmTomasz Miąsko-4/+25
2019-11-13Revert "Auto merge of #65134 - ↵Robin Kruppe-1/+3
davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, r=rkruppe" This reverts commit 3f0e16473de5ec010f44290a8c3ea1d90e0ad7a2, reversing changes made to 61a551b4939ec1d5596e585351038b8fbd0124ba.
2019-11-06Auto merge of #65134 - davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, ↵bors-3/+1
r=rkruppe improper_ctypes: `extern "C"` fns cc #19834. Fixes #65867. This pull request implements the change [described in this comment](https://github.com/rust-lang/rust/issues/19834#issuecomment-466671572). cc @rkruppe @varkor @shepmaster
2019-11-05codegen_llvm: remove unnecessary "extern C"David Wood-4/+1
Signed-off-by: David Wood <david@davidtw.co>
2019-11-05improper_ctypes: `extern "C"` fnsDavid Wood-0/+1
2019-10-29Allow specifying key "llvm-abiname" in target specificationGui Andrade-1/+2
This addresses #65024, as it allows RISC-V target specification files to set "llvm-abiname": "lp64d". In general, it is useful for the programmer to be able to set this codegen parameter, which other languages usually expose under a compiler argument like "-mabi=<XYZ>".
2019-10-29Auto merge of #65435 - michaelwoerister:fix-issue-64153, r=alexcrichtonbors-2/+4
Fix #64153 This PR changes how the compiler detects if an object file from an upstream crate is a Rust object file or not. Instead of checking if the name starts with the crate name and ends with `.o` (which is not always the case, as described in #64153), it now just checks if the filename ends with `.rcgu.o`. This fixes #64153. However, ideally we'd clean up the code around filename generation some more. Then this check could be made more robust. r? @alexcrichton
2019-10-22Fix issue #64153 by checking for .rcgu.o suffix when trying to identify Rust ↵Michael Woerister-2/+4
generated object files.