about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2022-01-17Update compiler/rustc_codegen_llvm/src/builder.rsCaleb Zulawski-3/+3
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2022-01-17Rollup merge of #92877 - Amanieu:remove_llvm_nounwind, r=Mark-SimulacrumMatthias Krüger-18/+0
Remove LLVMRustMarkAllFunctionsNounwind This was originally introduced in #10916 as a way to remove all landing pads when performing LTO. However this is no longer necessary today since rustc properly marks all functions and call-sites as nounwind where appropriate. In fact this is incorrect in the presence of `extern "C-unwind"` which must create a landing pad when compiled with `-C panic=abort` so that foreign exceptions are caught and properly turned into aborts.
2022-01-17Use Symbol for target features in asm handlingbjorn3-4/+3
This saves a couple of Symbol::intern calls
2022-01-17rustc_codegen_llvm: Remove (almost) unused span parameter from many ↵Michael Woerister-130/+51
functions in metadata.rs.
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-114/+7
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-15initial revertEllen-1/+1
2022-01-14Remove LLVMRustMarkAllFunctionsNounwindAmanieu d'Antras-18/+0
This was originally introduced in #10916 as a way to remove all landing pads when performing LTO. However this is no longer necessary today since rustc properly marks all functions and call-sites as nounwind where appropriate. In fact this is incorrect in the presence of `extern "C-unwind"` which must create a landing pad when compiled with `-C panic=abort` so that foreign exceptions are caught and properly turned into aborts.
2022-01-13Rollup merge of #92142 - wesleywiser:fix_codecoverage_partitioning, r=tmandryMatthias Krüger-86/+34
[code coverage] Fix missing dead code in modules that are never called The issue here is that the logic used to determine which CGU to put the dead function stubs in doesn't handle cases where a module is never assigned to a CGU (which is what happens when all of the code in the module is dead). The partitioning logic also caused issues in #85461 where inline functions were duplicated into multiple CGUs resulting in duplicate symbols. This commit fixes the issue by removing the complex logic used to assign dead code stubs to CGUs and replaces it with a much simpler model: we pick one CGU to hold all the dead code stubs. We pick a CGU which has exported items which increases the likelihood the linker won't throw away our dead functions and we pick the smallest to minimize the impact on compilation times for crates with very large CGUs. Fixes #91661 Fixes #86177 Fixes #85718 Fixes #79622 r? ```@tmandry``` cc ```@richkadel``` This PR is not urgent so please don't let it interrupt your holidays! 🎄 🎁
2022-01-12Call out to binutils' dlltool for raw-dylib on windows-gnu platforms.Richard Cobbe-46/+159
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-114/+7
2022-01-11Auto merge of #92533 - Aaron1011:variant-symbol, r=petrochenkovbors-7/+7
Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef` The field is also renamed from `ident` to `name`. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-7/+7
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-1/+1
2022-01-07Rollup merge of #92375 - wesleywiser:consolidate_debuginfo_msvc_check, ↵Eric Huss-14/+14
r=michaelwoerister Consolidate checking for msvc when generating debuginfo If the target we're generating code for is msvc, then we do two main things differently: we generate type names in a C++ style instead of a Rust style and we generate debuginfo for enums differently. I've refactored the code so that there is one function (`cpp_like_debuginfo`) which determines if we should use the C++ style of naming types and other debuginfo generation or the regular Rust one. r? ``@michaelwoerister`` This PR is not urgent so please don't let it interrupt your holidays! 🎄 🎁
2022-01-07Consolidate checking for msvc when generating debuginfoWesley Wiser-14/+14
If the target we're generating code for is msvc, then we do two main things differently: we generate type names in a C++ style instead of a Rust style and we generate debuginfo for enums differently. I've refactored the code so that there is one function (`cpp_like_debuginfo`) which determines if we should use the C++ style of naming types and other debuginfo generation or the regular Rust one.
2022-01-06sess/cg: re-introduce split dwarf kindDavid Wood-15/+26
In #79570, `-Z split-dwarf-kind={none,single,split}` was replaced by `-C split-debuginfo={off,packed,unpacked}`. `-C split-debuginfo`'s packed and unpacked aren't exact parallels to single and split, respectively. On Unix, `-C split-debuginfo=packed` will put debuginfo into object files and package debuginfo into a DWARF package file (`.dwp`) and `-C split-debuginfo=unpacked` will put debuginfo into dwarf object files and won't package it. In the initial implementation of Split DWARF, split mode wrote sections which did not require relocation into a DWARF object (`.dwo`) file which was ignored by the linker and then packaged those DWARF objects into DWARF packages (`.dwp`). In single mode, sections which did not require relocation were written into object files but ignored by the linker and were not packaged. However, both split and single modes could be packaged or not, the primary difference in behaviour was where the debuginfo sections that did not require link-time relocation were written (in a DWARF object or the object file). This commit re-introduces a `-Z split-dwarf-kind` flag, which can be used to pick between split and single modes when `-C split-debuginfo` is used to enable Split DWARF (either packed or unpacked). Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-04Add simd_as intrinsicCaleb Zulawski-23/+46
2022-01-04Allow isize/usize in simd_castCaleb Zulawski-4/+16
2022-01-03RustWrapper: adapt for an LLVM API changeKrasimir Georgiev-6/+6
No functional changes intended. The LLVM commit https://github.com/llvm/llvm-project/commit/ec501f15a8b8ace2b283732740d6d65d40d82e09 removed the signed version of `createExpression`. This adapts the Rust LLVM wrappers accordingly.
2022-01-01Stabilize -Z instrument-coverage as -C instrument-coverageJosh Triplett-2/+2
Continue supporting -Z instrument-coverage for compatibility for now, but show a deprecation warning for it. Update uses and documentation to use the -C option. Move the documentation from the unstable book to stable rustc documentation.
2022-01-01Auto merge of #92419 - erikdesjardins:coldland, r=nagisabors-2/+17
Mark drop calls in landing pads `cold` instead of `noinline` Now that deferred inlining has been disabled in LLVM (#92110), this shouldn't cause catastrophic size blowup. I confirmed that the test cases from https://github.com/rust-lang/rust/issues/41696#issuecomment-298696944 still compile quickly (<1s) after this change. ~Although note that I wasn't able to reproduce the original issue using a recent rustc/llvm with deferred inlining enabled, so those tests may no longer be representative. I was also unable to create a modified test case that reproduced the original issue.~ (edit: I reproduced it on CI by accident--the first commit timed out on the LLVM 12 builder, because I forgot to make it conditional on LLVM version) r? `@nagisa` cc `@arielb1` (this effectively reverts #42771 "mark calls in the unwind path as !noinline") cc `@RalfJung` (fixes #46515) edit: also fixes #87055
2021-12-30keep noinline for system llvm < 14Erik Desjardins-1/+16
2021-12-30Auto merge of #91125 - eskarn:llvm-passes-plugin-support, r=nagisabors-26/+39
Allow loading LLVM plugins with both legacy and new pass manager Opening a draft PR to get feedback and start discussion on this feature. There is already a codegen option `passes` which allow giving a list of LLVM pass names, however we currently can't use a LLVM pass plugin (as described here : https://llvm.org/docs/WritingAnLLVMPass.html), the only available passes are the LLVM built-in ones. The proposed modification would be to add another codegen option `pass-plugins`, which can be set with a list of paths to shared library files. These libraries are loaded using the LLVM function `PassPlugin::Load`, which calls the expected symbol `lvmGetPassPluginInfo`, and register the pipeline parsing and optimization callbacks. An example usage with a single plugin and 3 passes would look like this in the `.cargo/config`: ```toml rustflags = [ "-C", "pass-plugins=/tmp/libLLVMPassPlugin", "-C", "passes=pass1 pass2 pass3", ] ``` This would give the same functionality as the opt LLVM tool directly integrated in rust build system. Additionally, we can also not specify the `passes` option, and use a plugin which inserts passes in the optimization pipeline, as one could do using clang.
2021-12-29Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisabors-1/+30
Add codegen option for branch protection and pointer authentication on AArch64 The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets.
2021-12-29Mark drop calls in landing pads cold instead of noinlineErik Desjardins-2/+2
Now that deferred inlining has been disabled in LLVM, this shouldn't cause catastrophic size blowup.
2021-12-27Address review commentsWesley Wiser-20/+27
2021-12-20[code coverage] Fix missing dead code in modules that are never calledWesley Wiser-83/+24
The issue here is that the logic used to determine which CGU to put the dead function stubs in doesn't handle cases where a module is never assigned to a CGU. The partitioning logic also caused issues in #85461 where inline functions were duplicated into multiple CGUs resulting in duplicate symbols. This commit fixes the issue by removing the complex logic used to assign dead code stubs to CGUs and replaces it with a much simplier model: we pick one CGU to hold all the dead code stubs. We pick a CGU which has exported items which increases the likelihood the linker won't throw away our dead functions and we pick the smallest to minimize the impact on compilation times for crates with very large CGUs. Fixes #86177 Fixes #85718 Fixes #79622
2021-12-20Load new pass manager plugins only if the new pm is actually usedAxel Cohen-5/+5
2021-12-20rustc_codegen_llvm: move should_use_new_llvm_pass_manager function to llvm_utilAxel Cohen-18/+19
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-12/+13
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-18Rollup merge of #92024 - pcwalton:per-codegen-unit-names, r=davidtwcoMatthias Krüger-8/+19
rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones. To avoid breaking split DWARF, we need to ensure that each codegen unit has a unique `DW_AT_name`. This is because there's a remote chance that different codegen units for the same module will have entirely identical DWARF entries for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified in section 7.32 "Type Signature Computation" to compute the DWO ID, which does not include any fields that would distinguish compilation units. So we must embed the codegen unit name into the `DW_AT_name`. Closes #88521.
2021-12-18Rollup merge of #91931 - LegionMammal978:less-inband-codegen_llvm, r=davidtwcoMatthias Krüger-392/+429
Remove `in_band_lifetimes` from `rustc_codegen_llvm` See #91867 for more information. This one took a while. This crate has dozens of functions not associated with any type, and most of them were using in-band lifetimes for `'ll` and `'tcx`.
2021-12-18Rollup merge of #91566 - cbeuw:remap-dwo-name, r=davidtwcoMatthias Krüger-3/+6
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-16rustc_codegen_llvm: Give each codegen unit a unique DWARF name on allPatrick Walton-8/+19
platforms, not just Apple ones. To avoid breaking split DWARF, we need to ensure that each codegen unit has a unique `DW_AT_name`. This is because there's a remote chance that different codegen units for the same module will have entirely identical DWARF entries for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified in section 7.32 "Type Signature Computation" to compute the DWO ID, which does not include any fields that would distinguish compilation units. So we must embed the codegen unit name into the `DW_AT_name`. Closes #88521.
2021-12-16Remove `in_band_lifetimes` from `rustc_codegen_llvm`LegionMammal978-392/+429
See #91867 for more information.
2021-12-15Remove unnecessary sigils around `Ident::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-8/+8
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-3/+4
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcmMatthias Krüger-1/+0
Stabilize `iter::zip` Hello all! As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue. As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been used in many places across the rust compiler and standard library since March without any issues. For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15Rollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obkMatthias Krüger-3/+7
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace` 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-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-13Rollup merge of #91855 - xfix:const_cstr_unchecked, r=dtolnayMatthias Krüger-1/+0
Stabilize const_cstr_unchecked Closes #90343 ``@rustbot`` modify labels: +T-libs-api
2021-12-13Revert "Produce .dwo file for Packed as well"Andy Wang-8/+11
This reverts commit 32810223c6b743de889eda96b442f621c293a848.
2021-12-13Auto merge of #91654 - nikic:llvmbc-section-flags, r=nagisabors-42/+60
Use module inline assembly to embed bitcode In LLVM 14, our current method of setting section flags to avoid embedding the `.llvmbc` section into final compilation artifacts will no longer work, see issue #90326. The upstream recommendation is to instead embed the entire bitcode using module-level inline assembly, which is what this change does. I've kept the existing code for platforms where we do not need to set section flags, but possibly we should always be using the inline asm approach (which would have to look a bit different for MachO). r? `@nagisa`
2021-12-13Fix conditions for using legacy or new pm pluginsAxel Cohen-1/+1
2021-12-13Use the existing llvm-plugins option for both legacy and new pm registrationAxel Cohen-13/+19
2021-12-13Add a codegen option to allow loading LLVM pass pluginsAxel Cohen-0/+6
2021-12-13Stabilize const_cstr_uncheckedKonrad Borowski-1/+0
2021-12-13Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`Tomasz Miąsko-3/+7
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-12Auto merge of #90716 - euclio:libloading, r=cjgillotbors-9/+9
replace dynamic library module with libloading This PR deletes the `rustc_metadata::dynamic_lib` module in favor of the popular and better tested [`libloading` crate](https://github.com/nagisa/rust_libloading/). We don't benefit from `libloading`'s symbol lifetimes since we end up leaking the loaded library in all cases, but the call-sites look much nicer by improving error handling and abstracting away some transmutes. We also can remove `rustc_metadata`'s direct dependencies on `libc` and `winapi`. This PR also adds an exception for `libloading` (and its license) to tidy, so this will need sign-off from the compiler team.