about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
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/+243
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/+243
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.
2021-11-07more clippy fixesMatthias Krüger-2/+2
2021-11-06Rollup merge of #90642 - matthiaskrgr:clippy_matches, r=cjgillotMatthias Krüger-4/+1
use matches!() macro in more places
2021-11-06use matches!() macro in more placesMatthias Krüger-4/+1
2021-11-06Auto merge of #90641 - matthiaskrgr:mut, r=cjgillotbors-1/+1
pointee_info_at() does not need mutable access
2021-11-06pointee_info_at() does not need mutable accessMatthias Krüger-1/+1
2021-11-05Initialize LLVM time trace profiler on each code generation threadTomasz Miąsko-51/+73
In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread.
2021-11-05Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkovbors-2/+2
clippy::perf fixes
2021-11-04clippy::perf fixesMatthias Krüger-2/+2
2021-11-03Update aarch64 `target_feature` list for LLVM 12.Adam Gemmell-8/+17
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-27Auto merge of #89652 - rcvalle:rust-cfi, r=nagisabors-3/+47
Add LLVM CFI support to the Rust compiler This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-27Auto merge of #89937 - JohnTitor:fix-89875, r=Amanieubors-1/+4
Properly check `target_features` not to trigger an assertion Fixes #89875 I think it should be a condition instead of an assertion to check if it's a register as it's possible that `reg` is a register class. Also, this isn't related to the issue directly, but `is_target_supported` doesn't check `target_features` attributes. Is there any way to check it on rustc_codegen_llvm? r? `@Amanieu`
2021-10-26Properly check `target_features` not to trigger an assertionYuki Okushi-1/+4
2021-10-26Auto merge of #85830 - bjorn3:separate_provide_extern, r=cjgillotbors-6/+6
Avoid a branch on key being local for queries that use the same local and extern providers Currently based on https://github.com/rust-lang/rust/pull/85810 as it slightly conflicts with it. Only the last two commits are new.