about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2021-12-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-2/+2
The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-20Load new pass manager plugins only if the new pm is actually usedAxel Cohen-5/+1
2021-12-19Actually set IMAGE_SCN_LNK_REMOVE for .rmetaNikita Popov-6/+5
The code intended to set the IMAGE_SCN_LNK_REMOVE flag for the .rmeta section, however the value of this flag was set to zero. Instead use the actual value provided by the object crate. This dates back to the original introduction of this code in PR #84449, so we were never setting this flag. As I'm not on Windows, I'm not sure whether that means we were embedding .rmeta into executables, or whether the section ended up getting stripped for some other reason.
2021-12-19Rollup merge of #92029 - nikic:section-flags-fix, r=davidtwcoMatthias Krüger-1/+8
Explicitly set no ELF flags for .rustc section For a data section, the object crate will set the SHF_ALLOC by default, which is exactly what we don't want. Explicitly set sh_flags to zero to avoid this. I checked with `objdump -h` that this produces the right flags for ELF. Fixes #92013.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-7/+7
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18Auto merge of #92065 - matthiaskrgr:rollup-qmpcsuj, r=matthiaskrgrbors-6/+15
Rollup of 7 pull requests Successful merges: - #91566 (Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF) - #91926 (Remove `in_band_lifetimes` from `rustc_metadata`) - #91931 (Remove `in_band_lifetimes` from `rustc_codegen_llvm`) - #92024 (rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.) - #92037 (Use a const ParamEnv when in default_method_body_is_const) - #92047 (Set `RUST_BACKTRACE=0` when running location-detail tests) - #92050 (Add a space and 2 grave accents ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-18Explicitly set no ELF flags for .rustc sectionNikita Popov-1/+8
For a data section, the object crate will set the SHF_ALLOC by default, which is exactly what we don't want. Explicitly set sh_flags to zero to avoid this.
2021-12-18Rollup merge of #91566 - cbeuw:remap-dwo-name, r=davidtwcoMatthias Krüger-6/+15
Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF `--remap-path-prefix` doesn't apply to paths to `.o` (in case of packed) or `.dwo` (in case of unpacked) files in `DW_AT_GNU_dwo_name`. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888
2021-12-17pass -Wl,-z,origin to set DF_ORIGIN when using rpathSébastien Marie-1/+4
DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string. Some implementations are just ignoring DF_ORIGIN and do substitution for $ORIGIN if present (whatever DF_ORIGIN pr Set the flag inconditionally if rpath is wanted.
2021-12-15Rollup merge of #91885 - LegionMammal978:less-inband-codegen_ssa, ↵Matthias Krüger-17/+16
r=workingjubilee Remove `in_band_lifetimes` from `rustc_codegen_ssa` See #91867 for more information. In `compiler/rustc_codegen_ssa/src/coverageinfo/map.rs`, there are several functions with an explicit `'a` lifetime but only a single `&'a self` parameter. These lifetimes should be redundant given lifetime elision, unless the existential `impl Iterator` has weird issues regarding that. Should the redundant lifetimes be removed?
2021-12-15Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514Matthias Krüger-2/+2
fix clippy::single_char_pattern perf findings
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-7/+7
2021-12-15Remove `in_band_lifetimes` from `rustc_codegen_ssa`LegionMammal978-17/+16
See #91867 for more information.
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-2/+2
2021-12-13Provide object files to llvm-dwp instead of .dwoAndy Wang-6/+6
2021-12-13Fix conditions for using legacy or new pm pluginsAxel Cohen-1/+5
2021-12-13Use the existing llvm-plugins option for both legacy and new pm registrationAxel Cohen-4/+2
2021-12-13Add a codegen option to allow loading LLVM pass pluginsAxel Cohen-0/+4
2021-12-13Auto merge of #91569 - erikdesjardins:vt-align, r=nikicbors-7/+11
Attach range metadata to alignment loads from vtables ...because alignment is always nonzero[0]. This helps eliminate redundant runtime alignment checks, when a DST is a field of a struct whose remaining fields have alignment 1. Fixes #91438. --- [0]: The [reference](https://doc.rust-lang.org/reference/type-layout.html) says that alignment must be at least 1. And in practice, the alignment field for all vtables is generated here: https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_middle/src/ty/vtable.rs#L68-L90 and is nonzero because [`Align::bytes()`](https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_target/src/abi/mod.rs#L547-L549) is always nonzero.
2021-12-13Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`Tomasz Miąsko-0/+1
The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`.
2021-12-11Rollup merge of #91643 - Amanieu:r9x18, r=joshtriplettMatthias Krüger-0/+1
asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved by the current target This supersedes https://github.com/rust-lang/rust/pull/88879. cc `@Skirmisher` r? `@joshtriplett`
2021-12-10Rollup merge of #91625 - est31:remove_indexes, r=oli-obkMatthias Krüger-4/+4
Remove redundant [..]s
2021-12-10asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved byAmanieu d'Antras-0/+1
the current target.
2021-12-09Rollup merge of #90796 - Amanieu:remove_reg_thumb, r=joshtriplettMatthias Krüger-0/+1
Remove the reg_thumb register class for asm! on ARM Also restricts r8-r14 from being used on Thumb1 targets as per #90736. cc ``@Lokathor`` r? ``@joshtriplett``
2021-12-09Remove redundant [..]sest31-4/+4
2021-12-08Auto merge of #91604 - nikic:section-flags, r=nagisabors-182/+244
Use object crate for .rustc metadata generation We already use the object crate for generating uncompressed .rmeta metadata object files. This switches the generation of compressed .rustc object files to use the object crate as well. These have slightly different requirements in that .rmeta should be completely excluded from any final compilation artifacts, while .rustc should be part of shared objects, but not loaded into memory. The primary motivation for this change is #90326: In LLVM 14, the current way of setting section flags (and in particular, preventing the setting of SHF_ALLOC) will no longer work. There are other ways we could work around this, but switching to the object crate seems like the most elegant, as we already use it for .rmeta, and as it makes this independent of the codegen backend. In particular, we don't need separate handling in codegen_llvm and codegen_gcc. codegen_cranelift should be able to reuse the implementation as well, though I have omitted that here, as it is not based on codegen_ssa. This change mostly extracts the existing code for .rmeta handling to allow using it for .rustc as well, and adjusts the codegen infrastructure to handle the metadata object file separately: We no longer create a backend-specific module for it, and directly produce the compiled module instead. This does not `fix` #90326 by itself yet, as .llvmbc will need to be handled separately. r? `@nagisa`
2021-12-07Remove the reg_thumb register class for asm! on ARMAmanieu d'Antras-0/+1
Also restricts r8-r14 from being used on Thumb1 targets as per #90736.
2021-12-07Use object crate for .rustc metadata generationNikita Popov-182/+244
We already use the object crate for generating uncompressed .rmeta metadata object files. This switches the generation of compressed .rustc object files to use the object crate as well. These have slightly different requirements in that .rmeta should be completely excluded from any final compilation artifacts, while .rustc should be part of shared objects, but not loaded into memory. The primary motivation for this change is #90326: In LLVM 14, the current way of setting section flags (and in particular, preventing the setting of SHF_ALLOC) will no longer work. There are other ways we could work around this, but switching to the object crate seems like the most elegant, as we already use it for .rmeta, and as it makes this independent of the codegen backend. In particular, we don't need separate handling in codegen_llvm and codegen_gcc. codegen_cranelift should be able to reuse the implementation as well, though I have omitted that here, as it is not based on codegen_ssa. This change mostly extracts the existing code for .rmeta handling to allow using it for .rustc as well, and adjust the codegen infrastructure to handle the metadata object file separately: We no longer create a backend-specific module for it, and directly produce the compiled module instead. This does not fix #90326 by itself yet, as .llvmbc will need to be handled separately.
2021-12-06Provide .dwo paths to llvm-dwp explicitlyAndy Wang-5/+14
2021-12-05Attach range metadata to alignment loads from vtablesErik Desjardins-7/+11
...because alignment is always nonzero. This helps eliminate redundant runtime alignment checks, when a DST is a field of a struct whose remaining fields have alignment 1.
2021-12-03LLVM codgen support for unwinding inline assemblycynecx-10/+57
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-0/+2
2021-12-01Rollup merge of #91207 - richkadel:rk-bump-coverage-version, r=tmandryMatthias Krüger-4/+4
Add support for LLVM coverage mapping format versions 5 and 6 This PR cherry-pick's Swatinem's initial commit in unsubmitted PR #90047. My additional commit augments Swatinem's great starting point, but adds full support for LLVM Coverage Mapping Format version 6, conditionally, if compiling with LLVM 13. Version 6 requires adding the compilation directory when file paths are relative, and since Rustc coverage maps use relative paths, we should add the expected compilation directory entry. Note, however, that with the compilation directory, coverage reports from `llvm-cov show` can now report file names (when the report includes more than one file) with the full absolute path to the file. This would be a problem for test results, but the workaround (for the rust coverage tests) is to include an additional `llvm-cov show` parameter: `--compilation-dir=.`
2021-11-27Use iterator instead of recursion in `codegen_place`SparrowLii-76/+67
2021-11-23Feat: make cg_ssa get_param borrow the builder mutablerdambrosio-1/+1
2021-11-23Update CoverageMappingFormat Support to Version6Arpad Borsos-4/+4
Version 5 adds Branch Regions which are a prerequisite for branch coverage. Version 6 can use the zeroth filename as prefix for other relative files.
2021-11-17Rollup merge of #90900 - andjo403:removeLlvm12Check, r=nikicMatthias Krüger-15/+0
Remove workaround for the forward progress handling in LLVM this workaround was only needed for LLVM < 12 and the minimum LLVM version was updated to 12 in #90175
2021-11-16Rollup merge of #90058 - joshtriplett:stabilize-strip, r=wesleywiserYuki Okushi-2/+12
Stabilize -Z strip as -C strip Leave -Z strip available temporarily as an alias, to avoid breaking cargo until cargo transitions to using -C strip.
2021-11-15Auto merge of #90717 - kit-981:fix-ld64-flags, r=petrochenkovbors-42/+50
Fix ld64 flags - The `-exported_symbols_list` argument appears to be malformed for `ld64` (if you are not going through `clang`). - The `-dynamiclib` argument isn't support for `ld64`. It should be guarded behind a compiler flag. These problems are fixed by these changes. I have also refactored the way linker arguments are generated to be ld/compiler agnostic and therefore less error prone. These changes are necessary to support cross-compilation to darwin targets.
2021-11-15Stabilize -Z strip as -C stripJosh Triplett-2/+12
Leave -Z strip available temporarily as an alias, to avoid breaking cargo until cargo transitions to using -C strip. (If the user passes both, the -C version wins.)
2021-11-14Remove workaround for the forward progress handling in LLVMAndreas Jonson-15/+0
2021-11-14Only use the -dynamiclib flag when the linker is not ldkit-1/+4
This is not a valid flag for ld64. When the ld64 linker is explicitly provided through `config.toml`, rustc will not successfully compile.
2021-11-14Refactor linker argument generationkit-30/+18
This commit refactors linker argument generation to leverage a helper function that abstracts away details governing how these arguments are transformed and provided to the linker. This fixes the misuse of the `-exported_symbols_list` when an ld-like linker is used rather than a compiler. A compiler would expect `-Wl,-exported_symbols_list,path` but ld would expect `-exported_symbols_list` and `path` as two seperate arguments. Prior to this change, an ld-like linker was given `-exported_symbols_list,path`.
2021-11-14Add a helper method for linker argumentskit-11/+28
Linker arguments must transformed when Rust is interacting with the linker through a compiler. This commit introduces a helper function that abstracts away details of this transformation.
2021-11-09Rollup merge of #90701 - michaelwoerister:more-artifact-sizes, r=davidtwcoMatthias Krüger-0/+13
Record more artifact sizes during self-profiling. This PR adds artifact size recording for - "linked artifacts" (executables, RLIBs, dylibs, static libs) - object files - dwo files - assembly files - crate metadata - LLVM bitcode files - LLVM IR files - codegen unit size estimates Currently the identifiers emitted for these are hard-coded as string literals. Is it worth adding constants to https://github.com/rust-lang/measureme/blob/master/measureme/src/rustc.rs instead? We don't do that for query names and the like -- but artifact kinds might be more stable than query names.
2021-11-09Rollup merge of #90688 - SparrowLii:dotprod, r=AmanieuYuki Okushi-0/+1
enable `dotprod` target feature in arm To implement `vdot` neon insturction in stdarch, we need to enable `dotprod` target feature in arm in rustc. r? `@Amanieu`
2021-11-09Auto merge of #87337 - jyn514:lint-error, r=oli-obk,flip1995bors-1/+1
Don't abort compilation after giving a lint error The only reason to use `abort_if_errors` is when the program is so broken that either: 1. later passes get confused and ICE 2. any diagnostics from later passes would be noise This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints. So it can continue to lint and compile even if there are lint errors. Closes https://github.com/rust-lang/rust/issues/82761. This is a WIP because I have a feeling it will exit with 0 even if there were lint errors; I don't have a computer that can build rustc locally at the moment.
2021-11-08Record more artifact sizes during self-profiling.Michael Woerister-0/+13
2021-11-08enable `dotprod` target feature in armSparrowLii-0/+1
2021-11-08Don't abort compilation after giving a lint errorJoshua Nelson-1/+1
The only reason to use `abort_if_errors` is when the program is so broken that either: 1. later passes get confused and ICE 2. any diagnostics from later passes would be noise This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints. So it can continue to lint and compile even if there are lint errors.