summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2022-03-14Use new pass manager on s390x with LLVM 14Nikita Popov-4/+5
The problematic compile-time issue should be resolved with this version.
2022-03-02Auto merge of #93516 - nagisa:branch-protection, r=cjgillotbors-30/+30
No branch protection metadata unless enabled Even if we emit metadata disabling branch protection, this metadata may conflict with other modules (e.g. during LTO) that have different branch protection metadata set. This is an unstable flag and feature, so ideally the flag not being specified should act as if the feature wasn't implemented in the first place. Additionally this PR also ensures we emit an error if `-Zbranch-protection` is set on targets other than the supported aarch64. For now the error is being output from codegen, but ideally it should be moved to earlier in the pipeline before stabilization.
2022-02-19Auto merge of #94134 - matthiaskrgr:rollup-b132kjz, r=matthiaskrgrbors-0/+14
Rollup of 10 pull requests Successful merges: - #89892 (Suggest `impl Trait` return type when incorrectly using a generic return type) - #91675 (Add MemTagSanitizer Support) - #92806 (Add more information to `impl Trait` error) - #93497 (Pass `--test` flag through rustdoc to rustc so `#[test]` functions can be scraped) - #93814 (mips64-openwrt-linux-musl: correct soft-foat) - #93847 (kmc-solid: Use the filesystem thread-safety wrapper) - #93877 (asm: Allow the use of r8-r14 as clobbers on Thumb1) - #93892 (Only mark projection as ambiguous if GAT substs are constrained) - #93915 (Implement --check-cfg option (RFC 3013), take 2) - #93953 (Add the `known-bug` test directive, use it, and do some cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-18Auto merge of #94050 - michaelwoerister:fix-unsized-tuple-debuginfo, r=pnkfelixbors-9/+4
debuginfo: Support fat pointers to unsized tuples. This PR makes fat pointer debuginfo generation handle the case of unsized tuples. Fixes #93871
2022-02-18Rollup merge of #91675 - ivanloz:memtagsan, r=nagisaMatthias Krüger-0/+14
Add MemTagSanitizer Support Add support for the LLVM [MemTagSanitizer](https://llvm.org/docs/MemTagSanitizer.html). On hardware which supports it (see caveats below), the MemTagSanitizer can catch bugs similar to AddressSanitizer and HardwareAddressSanitizer, but with lower overhead. On a tag mismatch, a SIGSEGV is signaled with code SEGV_MTESERR / SEGV_MTEAERR. # Usage `-Zsanitizer=memtag -C target-feature="+mte"` # Comments/Caveats * MemTagSanitizer is only supported on AArch64 targets with hardware support * Requires `-C target-feature="+mte"` * LLVM MemTagSanitizer currently only performs stack tagging. # TODO * Tests * Example
2022-02-18Rollup merge of #93634 - matthiaskrgr:clippy_complexity_jan_2022, r=oli-obkMatthias Krüger-1/+1
compiler: clippy::complexity fixes useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-02-17Rollup merge of #94043 - DrMeepster:box_alloc_ice, r=oli-obkMatthias Krüger-1/+3
Fix ICE when using Box<T, A> with pointer sized A Fixes #78459 Note that using `Box<T, A>` with a more than pointer sized `A` or using a pointer sized `A` with a Box of a DST will produce a different ICE (#92054) which is not fixed by this PR.
2022-02-17Auto merge of #93577 - nikic:llvm-14, r=nagisabors-17/+38
Upgrade to LLVM 14 LLVM patch state: * [x] https://github.com/llvm/llvm-project/commit/a55727f334b39600bfc71144b11b42aae6b94e0b Backported. * [x] https://github.com/rust-lang/llvm-project/commit/c3c82dc12402dd41441180c0c6cf7aed7e330c53 Backported as https://github.com/llvm/llvm-project/commit/917c47b3bf0dfc45a2a5ba12c1397d647ecf4017. * [x] https://github.com/rust-lang/llvm-project/commit/6e8f9ab632d12271355d10d34c9835a7ba14e4b9 No plan to upstream. * [x] https://github.com/llvm/llvm-project/commit/319f4b2d52e31b000db75a0a2484b5f2ab90534a Backported. * [x] https://github.com/rust-lang/llvm-project/commit/8b2c25d321f877161f85218479e2d1317d770e18 No plan to upstream. * [x] https://github.com/rust-lang/llvm-project/commit/75fef2efd427362c8f16b2d09e6ebf44069e3919 No plan to upstream. * [ ] https://github.com/rust-lang/llvm-project/commit/adef757547de5a570d9f6a00d3e6ac16c666ab79 Upstreamed as https://github.com/llvm/llvm-project/commit/2d2ef384b2f6e723edb793d08f52e7f4dc94ba3a. Needs backport. * [x] https://github.com/rust-lang/llvm-project/commit/4b7c1b4910e9fa9e04f23f06be078e168ef4c0ee No plan to upstream. * [x] https://github.com/rust-lang/llvm-project/commit/3f5ab0c061adb723f25b94243828b6b5407720c8 No plan to upstream. * [x] https://github.com/rust-lang/llvm-project/commit/514d05500e0e15e358f05f5c4cec78a805858f8e No plan to upstream. * [ ] https://github.com/rust-lang/llvm-project/commit/54c586958564582b3341d1838a5de86541e5fecf Under review at https://reviews.llvm.org/D119695 and https://reviews.llvm.org/D119856. Release timeline: * LLVM 14.0.0 final planned for Mar 15. * Rust 1.60.0 planned for Apr 7. Compile-time: * https://perf.rust-lang.org/compare.html?start=250384edc5d78533e993f38c60d64e42b21684b2&end=b87df8d2c7c5d9ac448c585de10927ab2ee1b864 * A slight improvement on average, though no big changes either way. * There are some larger max-rss improvements. r? `@ghost`
2022-02-16add comment explaining the checkDrMeepster-0/+2
2022-02-16Expose unstable llvm14-builtins-abi target feature for cfg useNikita Popov-16/+24
2022-02-16Update data layout for wasm32 targetsNikita Popov-0/+3
New address spaces were added in https://reviews.llvm.org/D111154.
2022-02-16Update data layout for 32-bit msvc targetsNikita Popov-1/+11
https://reviews.llvm.org/D115942 changed the alignment of f80.
2022-02-16MemTagSanitizer SupportIvan Lozano-0/+14
Adds support for the LLVM MemTagSanitizer.
2022-02-16debuginfo: Support fat pointers to unsized tuples.Michael Woerister-9/+4
2022-02-15fix assumption that ScalarPair Box is always a fat pointerDrMeepster-1/+1
2022-02-15Auto merge of #93439 - abrown:cf-protection, r=nagisabors-1/+20
Add support for control-flow protection This change adds a flag for configuring control-flow protection in the LLVM backend. In Clang, this flag is exposed as `-fcf-protection` with options `none|branch|return|full`. This convention is followed for `rustc`, though as a codegen option: `rustc -Z cf-protection=<none|branch|return|full>`. Tracking issue for future work is #93754.
2022-02-15Rollup merge of #94001 - durin42:llvm-15-uwtable, r=nikicMatthias Krüger-5/+13
llvm: migrate to new parameter-bearing uwtable attr In https://reviews.llvm.org/D114543 the uwtable attribute gained a flag so that we can ask for sync uwtables instead of async, as the former are much cheaper. The default is async, so that's what I've done here, but I left a TODO that we might be able to do better. While in here I went ahead and dropped support for removing uwtable attributes in rustc: we never did it, so I didn't write the extra C++ bridge code to make it work. Maybe I should have done the same thing with the `sync|async` parameter but we'll see.
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-10/+10
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-14llvm: migrate to new parameter-bearing uwtable attrAugie Fackler-5/+13
In https://reviews.llvm.org/D114543 the uwtable attribute gained a flag so that we can ask for sync uwtables instead of async, as the former are much cheaper. The default is async, so that's what I've done here, but I left a TODO that we might be able to do better. While in here I went ahead and dropped support for removing uwtable attributes in rustc: we never did it, so I didn't write the extra C++ bridge code to make it work. Maybe I should have done the same thing with the `sync|async` parameter but we'll see.
2022-02-14Add support for control-flow protectionAndrew Brown-1/+20
This change adds a flag for configuring control-flow protection in the LLVM backend. In Clang, this flag is exposed as `-fcf-protection` with options `none|branch|return|full`. This convention is followed for `rustc`, though as a codegen option: `rustc -Z cf-protection=<none|branch|return|full>`. Co-authored-by: BlackHoleFox <blackholefoxdev@gmail.com>
2022-02-13Auto merge of #93670 - erikdesjardins:noundef, r=nikicbors-1/+2
Apply noundef attribute to &T, &mut T, Box<T>, bool This doesn't handle `char` because it's a bit awkward to distinguish it from `u32` at this point in codegen. Note that this _does not_ change whether or not it is UB for `&`, `&mut`, or `Box` to point to undef. It only applies to the pointer itself, not the pointed-to memory. Fixes (partially) #74378. r? `@nikic` cc `@RalfJung`
2022-02-11Rollup merge of #93782 - adamgemmell:dev/adagem01/split-pauth, r=AmanieuMatthias Krüger-13/+67
Split `pauth` target feature Per discussion on https://github.com/rust-lang/rust/issues/86941 we'd like to split `pauth` into `paca` and `pacg` in order to better support possible future environments that only have the keys available for address or generic authentication. At the moment LLVM has the one `pauth` target_feature while Linux presents separate `paca` and `pacg` flags for feature detection. Because the use of [target_feature](https://rust-lang.github.io/rfcs/2045-target-feature.html) will "allow the compiler to generate code under the assumption that this code will only be reached in hosts that support the feature", it does not make sense to simply translate `paca` into the LLVM feature `pauth`, as it will generate code as if `pacg` is available. To accommodate this we error if only one of the two features is present. If LLVM splits them in the future we can remove this restriction without making a breaking change. r? ```@Amanieu```
2022-02-10Unconditionally update symbolsbjorn3-10/+1
All paths to an ArchiveBuilder::build call update_symbols first.
2022-02-10Split PAuth target featureAdam Gemmell-13/+67
2022-02-09Rollup merge of #93503 - ↵Matthias Krüger-35/+146
michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser debuginfo: Fix DW_AT_containing_type vtable debuginfo regression This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in #89597. It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable. r? ``@wesleywiser`` This PR should fix issue https://github.com/rust-lang/rust/issues/93164. ~~The PR is blocked on https://github.com/rust-lang/rust/pull/93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
2022-02-08debuginfo: Bring back DW_AT_containing_type for vtables -- address review ↵Michael Woerister-1/+3
comments
2022-02-06apply noundef explicitly in all cases instead of relying on dereferenceable ↵Erik Desjardins-4/+0
implying it
2022-02-06`#[used(linker)]` attribute (https://github.com/dtolnay/linkme/issues/41)cynecx-0/+9
2022-02-05Apply noundef attribute to &T, &mut T, Box<T>, boolErik Desjardins-1/+6
This doesn't handle `char` because it's a bit awkward to distinguish it from u32 at this point in codegen. Note that for some types (like `&Struct` and `&mut Struct`), we already apply `dereferenceable`, which implies `noundef`, so the IR does not change.
2022-02-04Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, ↵Matthias Krüger-2/+2
r=wesleywiser Stabilize `-Z instrument-coverage` as `-C instrument-coverage` (Tracking issue for `instrument-coverage`: https://github.com/rust-lang/rust/issues/79121) This PR stabilizes support for instrumentation-based code coverage, previously provided via the `-Z instrument-coverage` option. (Continue supporting `-Z instrument-coverage` for compatibility for now, but show a deprecation warning for it.) Many, many people have tested this support, and there are numerous reports of it working as expected. Move the documentation from the unstable book to stable rustc documentation. Update uses and documentation to use the `-C` option. Addressing questions raised in the tracking issue: > If/when stabilized, will the compiler flag be updated to -C instrument-coverage? (If so, the -Z variant could also be supported for some time, to ease migrations for existing users and scripts.) This stabilization PR updates the option to `-C` and keeps the `-Z` variant to ease migration. > The Rust coverage implementation depends on (and automatically turns on) -Z symbol-mangling-version=v0. Will stabilizing this feature depend on stabilizing v0 symbol-mangling first? If so, what is the current status and timeline? This stabilization PR depends on https://github.com/rust-lang/rust/pull/90128 , which stabilizes `-C symbol-mangling-version=v0` (but does not change the default symbol-mangling-version). > The Rust coverage implementation implements the latest version of LLVM's Coverage Mapping Format (version 4), which forces a dependency on LLVM 11 or later. A compiler error is generated if attempting to compile with coverage, and using an older version of LLVM. Given that LLVM 13 has now been released, requiring LLVM 11 for coverage support seems like a reasonable requirement. If people don't have at least LLVM 11, nothing else breaks; they just can't use coverage support. Given that coverage support currently requires a nightly compiler and LLVM 11 or newer, allowing it on a stable compiler built with LLVM 11 or newer seems like an improvement. The [tracking issue](https://github.com/rust-lang/rust/issues/79121) and the [issue label A-code-coverage](https://github.com/rust-lang/rust/labels/A-code-coverage) link to a few open issues related to `instrument-coverage`, but none of them seem like showstoppers. All of them seem like improvements and refinements we can make after stabilization. The original `-Z instrument-coverage` support went through a compiler-team MCP at https://github.com/rust-lang/compiler-team/issues/278 . Based on that, `@pnkfelix` suggested that this needed a stabilization PR and a compiler-team FCP.
2022-02-04Rollup merge of #93630 - matthiaskrgr:clipperf, r=oli-obkMatthias Krüger-1/+1
clippy::perf fixes single_char_pattern and to_string_in_format_args
2022-02-04Rollup merge of #93402 - ehuss:llvm-dialog, r=michaelwoeristerMatthias Krüger-0/+7
Windows: Disable LLVM crash dialog boxes. This disables the crash dialog box on Windows. When LLVM hits an assertion, it will open a dialog box with Abort/Retry/Ignore. This is annoying on CI because CI will just hang until it times out (which can take hours). Instead of opening a dialog box, it will print a message like this: ``` Assertion failed: isa<X>(Val) && "cast<Ty>() argument of incompatible type!", file D:\Proj\rust\rust\src\llvm-project\llvm\include\llvm/Support/Casting.h, line 255 ``` Closes #92829
2022-02-03compiler: clippy::complexity fixesMatthias Krüger-1/+1
useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-02-03clippy::perf fixesMatthias Krüger-1/+1
single_char_pattern and to_string_in_format_args
2022-02-03Only disable dialogs on CI.Eric Huss-1/+6
The "CI" environment var isn't universal (for example, I think Azure uses TF_BUILD). However, we are mostly concerned with rust-lang/rust's own CI which currently is GitHub Actions which does set "CI". And I think most other providers use "CI" as well.
2022-02-03debuginfo: Bring back DW_AT_containing_type for vtables after it has ↵Michael Woerister-11/+90
accidentally been removed in https://github.com/rust-lang/rust/pull/89597. Also describe vtables as structs with a field for each entry.
2022-02-03debuginfo: Make some helper functions in ↵Michael Woerister-24/+54
rustc_codegen_llvm::debuginfo::metadata more generally applicable.
2022-02-02Auto merge of #93154 - ↵bors-17/+20
michaelwoerister:fix-generic-closure-and-generator-debuginfo, r=wesleywiser debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo. Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name. This commit also emits `{closure_env#0}` as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called `{closure#0}`). Previously both were assigned the same name. NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.
2022-02-01debuginfo: Make sure that type names for closure and generator environments ↵Michael Woerister-17/+20
are unique in debuginfo. Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name. This commit also emits '{closure_env#0}' as the name of these types in order to disambiguate them from the accompanying closure function '{closure#0}'. Previously both were assigned the same name.
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-28Auto merge of #93427 - matthiaskrgr:rollup-esd3ixl, r=matthiaskrgrbors-39/+39
Rollup of 10 pull requests Successful merges: - #92611 (Add links to the reference and rust by example for asm! docs and lints) - #93158 (wasi: implement `sock_accept` and enable networking) - #93239 (Add os::unix::net::SocketAddr::from_path) - #93261 (Some unwinding related cg_ssa cleanups) - #93295 (Avoid double panics when using `TempDir` in tests) - #93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>) - #93356 (Edit docs introduction for `std::cmp::PartialOrd`) - #93375 (fix typo `documenation`) - #93399 (rustbuild: Fix compiletest warning when building outside of root.) - #93404 (Fix a typo from #92899) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-28Rollup merge of #93261 - bjorn3:cg_ssa_refactor6, r=cjgillotMatthias Krüger-39/+39
Some unwinding related cg_ssa cleanups These should make it a bit easier for alternative codegen backends to implement unwinding.
2022-01-28Auto merge of #93006 - michaelwoerister:fix-unsized-ptr-debuginfo, ↵bors-174/+238
r=davidtwco,oli-obk Fix debuginfo for pointers/references to unsized types This PR makes the compiler emit fat pointer debuginfo in all cases. Before, we sometimes got thin-pointer debuginfo, making it impossible to fully interpret the pointed to memory in debuggers. The code is actually cleaner now, especially around generation of trait object pointer debuginfo. Fixes https://github.com/rust-lang/rust/issues/92718 ~~Blocked on https://github.com/rust-lang/rust/pull/92729.~~
2022-01-28[debuginfo] Fix and unify handling of fat pointers in debuginfo: Don't mark ↵Michael Woerister-2/+2
fat pointer fields as artificial. LLDB does not seem to see fields if they are marked with DW_AT_artificial which breaks pretty printers that use these fields for decoding fat pointers.
2022-01-27Windows: Disable LLVM crash dialog boxes.Eric Huss-0/+2
2022-01-27[debuginfo] Fix and unify handling of fat pointers in debuginfo: Change doc ↵Michael Woerister-13/+13
comment so it is not interpreted as doc-test.
2022-01-25Rollup merge of #93269 - jacobbramley:dev/pauth-option-1, r=petrochenkovMatthias Krüger-10/+67
Use error-on-mismatch policy for PAuth module flags. This agrees with Clang, and avoids an error when using LTO with mixed C/Rust. LLVM considers different behaviour flags to be a mismatch, even when the flag value itself is the same. This also makes the flag setting explicit for all uses of LLVMRustAddModuleFlag. ---- I believe that this fixes #92885, but have only reproduced it locally on Linux hosts so cannot confirm that it fixes the issue as reported. I have not included a test for this because it is covered by an existing test (`src/test/run-make-fulldeps/cross-lang-lto-clang`). It is not without its problems, though: * The test requires Clang and `--run-clang-based-tests-with=...` to run, and this is not the case on the CI. * Any test I add would have a similar requirement. * With this patch applied, the test gets further, but it still fails (for other reasons). I don't think that affects #92885.
2022-01-25Rollup merge of #93144 - wesleywiser:uninhabited_type_code_cov2, r=tmandryMatthias Krüger-4/+13
Work around missing code coverage data causing llvm-cov failures If we do not add code coverage instrumentation to the `Body` of a function, then when we go to generate the function record for it, we won't write any data and this later causes llvm-cov to fail when processing data for the entire coverage report. I've identified two main cases where we do not currently add code coverage instrumentation to the `Body` of a function: 1. If the function has a single `BasicBlock` and it ends with a `TerminatorKind::Unreachable`. 2. If the function is created using a proc macro of some kind. For case 1, this is typically not important as this most often occurs as a result of function definitions that take or return uninhabited types. These kinds of functions, by definition, cannot even be called so they logically should not be counted in code coverage statistics. For case 2, I haven't looked into this very much but I've noticed while testing this patch that (other than functions which are covered by case 1) the skipped function coverage debug message is occasionally triggered in large crate graphs by functions generated from a proc macro. This may have something to do with weird spans being generated by the proc macro but this is just a guess. I think it's reasonable to land this change since currently, we fail to generate *any* results from llvm-cov when a function has no coverage instrumentation applied to it. With this change, we get coverage data for all functions other than the two cases discussed above. Fixes #93054 which occurs because of uncallable functions which shouldn't have code coverage anyway. I will open an issue for missing code coverage of proc macro generated functions and leave a link here once I have a more minimal repro. r? ``@tmandry`` cc ``@richkadel``
2022-01-24Use error-on-mismatch policy for PAuth module flags.Jacob Bramley-10/+67
This agrees with Clang, and avoids an error when using LTO with mixed C/Rust. LLVM considers different behaviour flags to be a mismatch, even when the flag value itself is the same. This also makes the flag setting explicit for all uses of LLVMRustAddModuleFlag.
2022-01-24Merge landing_pad and set_cleanup into cleanup_landing_padbjorn3-16/+18