about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2022-11-16Rollup merge of #103750 - calebzulawski:master, r=workingjubileeMatthias Krüger-0/+3
Fix some misleading target feature aliases This is the first half of a fix for #100752. It looks like these aliases were added in #78361 and slipped under the radar, as these features are not AVX512. These features _do_ add AVX512 instructions when used _in combination_ with AVX512F, but without AVX512F, these features still provide 128-bit and 256-bit vector instructions. A user might be mislead into thinking these features imply AVX512F (which is true of the actual AVX512 features). This PR allows using the names as defined by LLVM, which matches Intel documentation. A future PR should change the `std::arch` intrinsics to use these names, and finally remove these aliases from rustc. r? ```@workingjubilee``` cc ```@Amanieu```
2022-11-16cleanup and dedupe CTFE and Miri error reportingRalf Jung-1/+1
2022-11-16Merge basic blocks where possible when generating LLVM IR.Nicholas Nethercote-140/+257
In `codegen_assert_terminator` we decide if a BB's successor is a candidate for merging, which requires that it be the only successor, and that it only have one predecessor. That result then gets passed down, and if it reaches `funclet_br` with the appropriate BB characteristics, then no `br` instruction is issued, a `MergingSucc::True` result is passed back, and the merging proceeds in `codegen_block`. The commit also adds `CachedLlbb`, a new type to help keep track of each BB that has been merged into its predecessor.
2022-11-16Use `&mut Bx` more.Nicholas Nethercote-208/+167
For the next commit, `FunctionCx::codegen_*_terminator` need to take a `&mut Bx` instead of consuming a `Bx`. This triggers a cascade of similar changes across multiple functions. The resulting code is more concise and replaces many `&mut bx` expressions with `bx`.
2022-11-15Introduce composite debuginfo.Camille GILLOT-7/+69
2022-11-14Issue error when `-C link-self-contained` option is used on unsupported ↵StackDoubleFlow-0/+7
platforms Document supported targets for `-C link-self-contained` Move `LinkSelfContainedDefault::True` from wasm_base to wasm32_wasi
2022-11-15Auto merge of #104091 - BelovDV:issue-103044, r=petrochenkovbors-15/+40
Wrap bundled static libraries into object files Fixes #103044 (not sure, couldn't test locally) Bundled static libraries should be wrapped into object files as it's done for metadata file. r? `@petrochenkov`
2022-11-14Wrap bundlen static libraries into object filesDaniil Belov-15/+40
2022-11-13Rollup merge of #104357 - RalfJung:is-sized, r=cjgillotMatthias Krüger-5/+5
add is_sized method on Abi and Layout, and use it This avoids the double negation of `!is_unsized()` that we have quite a lot.
2022-11-13Store a LocalDefId in hir::AnonConst.Camille GILLOT-6/+6
2022-11-13add is_sized method on Abi and Layout, and use itRalf Jung-5/+5
2022-11-12Allow actual AVX512-related feature names in the case of some misleading aliasesCaleb Zulawski-0/+3
2022-11-12linker: Link `profiler_builtins` even if it's marked as `NotLinked`Vadim Petrochenkov-3/+4
2022-11-12linker: Support mixing crates built with different values of ↵Vadim Petrochenkov-9/+7
`-Zpacked_bundled_libs` So you can change the value of `-Zpacked_bundled_libs` without rebuilding standard library
2022-11-12linker: Move some inner functions to the outsideVadim Petrochenkov-133/+127
Inline `fn unlib`
2022-11-12linker: Simplify linking of `compiler_builtins` and `profiler_builtins`Vadim Petrochenkov-74/+46
This also fixes linking of native libraries bundled into these crates when `-Zpacked-bundled-libs` is enabled
2022-11-12linker: Factor out native library linking to a separate functionVadim Petrochenkov-213/+207
2022-11-11Rollup merge of #102215 - alexcrichton:wasm-link-whole-archive, r=estebankManish Goregaokar-2/+2
Implement the `+whole-archive` modifier for `wasm-ld` This implements the `Linker::{link_whole_staticlib,link_whole_rlib}` methods for the `WasmLd` linker used on wasm targets. Previously these methods were noops since I think historically `wasm-ld` did not have support for `--whole-archive` but nowadays it does, so the flags are passed through.
2022-11-11rustc_codegen_ssa: Better code generation for niche discriminants.Michael Benfield-49/+145
In some cases we can avoid arithmetic before checking whether a niche represents an untagged variant. This is relevant to #101872
2022-11-11Improve generating Custom entry functionAyush Singh-1/+2
This commit is aimed at making compiler generated entry functions (Basically just C `main` right now) more generic so other targets can do similar things for custom entry. This was initially implemented as part of https://github.com/rust-lang/rust/pull/100316. Currently, this moves the entry function name and Call convention to the target spec. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-09Add constructor for `Diagnostic` that takes `Vec<(DiagnosticMessage, Style)>`SLASHLogin-2/+1
2022-11-09Add `replace_args` method for `rustc_errors::diagnostic::Diagnostic`SLASHLogin-3/+1
2022-11-09Delay diagnostic translation in `rustc_codegen_ssa`SLASHLogin-9/+18
2022-11-07Rollup merge of #104045 - Ayush1325:type_array, r=nikicYuki Okushi-0/+1
Add type_array to BaseTypeMethods Moved `type_array` function to `rustc_codegen_ssa::BaseTypeMethods` trait. This allows using normal `alloca` function to create arrays as suggested in https://github.com/rust-lang/rust/pull/104022. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-06Add type_array to BaseTypeMethodsAyush Singh-0/+1
Moved type_array function to rustc_codegen_ssa::BaseTypeMethods trait. This allows using normal alloca function to create arrays as suggested in https://github.com/rust-lang/rust/pull/104022. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-05Auto merge of #103691 - ↵bors-13/+13
michaelwoerister:consistent-slice-and-str-cpp-like-debuginfo-names, r=wesleywiser [debuginfo] Make cpp-like debuginfo type names for slices and str consistent. Before this PR, the compiler would emit the debuginfo name `slice$<T>` for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>` would end up with the same type name `Foo<slice$<T> >` in debuginfo, making it impossible to disambiguate between them by name. Similarly, `&str` would get the name `str` in debuginfo, so the debuginfo name for `Foo<str>` and `Foo<&str>` would be the same. In contrast, `*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >` and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose information about the type. This PR removes all special handling for slices and `str`. The types `&[bool]`, `&mut [bool]`, and `&str` thus get the names `ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and `ref$<str$>` respectively -- as one would expect. The new special name for slices is `slice2$` to differentiate it from the previous name `slice$`, which has different semantics. The same is true for `str` and `str$`. This kind of versioning already has a precedent with the case of `enum$` and `enum2$` and hopefully will make it easier to transition existing consumers of these names. cc `@rust-lang/wg-debugging` `@vadimcn` r? `@wesleywiser` UPDATE: Here is a table to clarify the changes | Rust type | DWARF name | C++-like name (before) | C++-like name (after) | |-----------|------------|------------------------|------------------------| | `[T]` | `[T]` | `slice$<T>` | `slice2$<T>` | | `&[T]` | `&[T]` | `slice$<T>` | `ref$<slice2$<T> >` | | `&mut [T]` | `&mut [T]` | `slice$<T>` | `ref_mut$<slice2$<T> >`| | `str` | `str` | `str` | `str$` | | `&str` | `&str` | `str` | `ref$<str$>` | | `&mut str` | `&mut str` | `str` | `ref_mut$<str$>`| | `*const [T]` | `*const [T]` | `ptr_const$<slice$<T> >` | `ptr_const$<slice2$<T> >` | | `*mut [T]` | `*mut [T]` | `ptr_mut$<slice$<T> >` | `ptr_mut$<slice2$<T> >` | As you can see, before the PR many types would end up with the same name, making it impossible to distinguish between them in NatVis or other places where types are matched or looked up by name. The DWARF version of names is not changed.
2022-11-05Rollup merge of #103660 - ozkanonur:master, r=jyn514Dylan DPC-1/+2
improve `filesearch::get_or_default_sysroot` `fn get_or_default_sysroot` is now improved and used in `miri` and `clippy`, and tests are still passing as they should. So we no longer need to implement custom workarounds/hacks to find sysroot in tools like miri/clippy. Resolves https://github.com/rust-lang/rust/issues/98832 re-opened from #103581
2022-11-04improve `filesearch::get_or_default_sysroot` r=ozkanonurOnur Özkan-1/+2
Signed-off-by: Onur Özkan <work@onurozkan.dev>
2022-11-04UPDATE - accept dyn error and make Box<dyn error> conform to IntoDiagnosticArgJhonny Bill Mena-22/+21
2022-11-04UPDATE - address PR CommentsJhonny Bill Mena-83/+40
FIX - StrippingDebugInfoFailed typo DELETE - unneeded FIXME comment UPDATE - only declare the error with ExtractBundledLibsError as an enum and use the Diagnostic derive macro
2022-11-04FIX - Migrate missing errors in link.rsJhonny Bill Mena-4/+17
2022-11-04ADD - ExtractBundledLibsError. Migrated extract_bundled_libs to translatable ↵Jhonny Bill Mena-19/+90
diagnostics
2022-11-04UPDATE - Complete link.rs migration to new diagnostics infraestructureJhonny Bill Mena-80/+173
2022-11-01Rollup merge of #103638 - ia0:multivalue, r=nagisaManish Goregaokar-0/+1
Add `multivalue` target feature to WASM target This PR is similar to #99643 and #97808. It addresses #96472 for the `multivalue` target feature. The problem I am trying to fix is to remove the following warning when compiling with `-C target-feature=+multivalue` for `--target=wasm32-unknown-unknown`. ``` warning: unknown feature specified for `-Ctarget-feature`: `multivalue` | = note: it is still passed through to the codegen backend = note: consider filing a feature request ```
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-4/+14
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-31[debuginfo] Make debuginfo type names for slices and str consistent.Michael Woerister-13/+13
Before this PR, the compiler would emit the debuginfo name `slice$<T>` for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>` would end up with the same type name `Foo<slice$<T> >` in debuginfo, making it impossible to disambiguate between them by name. Similarly, `&str` would get the name `str` in debuginfo, so the debuginfo name for `Foo<str>` and `Foo<&str>` would be the same. In contrast, `*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >` and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose information about the type. This PR removes all special handling for slices and `str`. The types `&[bool]`, `&mut [bool]`, and `&str` thus get the names `ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and `ref$<str$>` respectively -- as one would expect.
2022-10-31Rollup merge of #103603 - camsteffen:refactor-lang, r=oli-obkDylan DPC-7/+6
Lang item cleanups Various cleanups related to lang items.
2022-10-31Use `br` instead of `switch` in more cases.Nicholas Nethercote-2/+28
`codegen_switchint_terminator` already uses `br` instead of `switch` when there is one normal target plus the `otherwise` target. But there's another common case with two normal targets and an `otherwise` target that points to an empty unreachable BB. This comes up a lot when switching on the tags of enums that use niches. The pattern looks like this: ``` bb1: ; preds = %bb6 %3 = load i8, ptr %_2, align 1, !range !9, !noundef !4 %4 = sub i8 %3, 2 %5 = icmp eq i8 %4, 0 %_6 = select i1 %5, i64 0, i64 1 switch i64 %_6, label %bb3 [ i64 0, label %bb4 i64 1, label %bb2 ] bb3: ; preds = %bb1 unreachable ``` This commit adds code to convert the `switch` to a `br`: ``` bb1: ; preds = %bb6 %3 = load i8, ptr %_2, align 1, !range !9, !noundef !4 %4 = sub i8 %3, 2 %5 = icmp eq i8 %4, 0 %_6 = select i1 %5, i64 0, i64 1 %6 = icmp eq i64 %_6, 0 br i1 %6, label %bb4, label %bb2 bb3: ; No predecessors! unreachable ``` This has a surprisingly large effect on compile times, with reductions of 5% on debug builds of some crates. The reduction is all due to LLVM taking less time. Maybe LLVM is just much better at handling `br` than `switch`. The resulting code is still suboptimal. - The `icmp`, `select`, `icmp` sequence is silly, converting an `i1` to an `i64` and back to an `i1`. But with the current code structure it's hard to avoid, and LLVM will easily clean it up, in opt builds at least. - `bb3` is usually now truly dead code (though not always, so it can't be removed universally).
2022-10-29Cleanup weak lang itemsCameron Steffen-7/+6
2022-10-27Add `multivalue` target feature to WASM targetJulien Cretin-0/+1
2022-10-27Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functionsMaybe Waffle-4/+3
Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions`
2022-10-25Rollup merge of #103511 - nnethercote:bb-tweaks, r=bjorn3Dylan DPC-82/+75
Codegen tweaks Best reviewed one commit at a time. r? `@bjorn3`
2022-10-25Simplify `cast_shift_expr_rhs`.Nicholas Nethercote-24/+18
It's only ever used with shift operators.
2022-10-25Inline and remove `cast_shift_rhs`.Nicholas Nethercote-9/+0
It has a single call site.
2022-10-25Clarify some cleanup stuff.Nicholas Nethercote-6/+10
- Rearrange the match in `llbb_with_landing_pad` so the `(Some,Some)` cases are together. - Add assertions to indicate two MSVC-only paths.
2022-10-25Rename two `TerminatorCodegenHelper` methods.Nicholas Nethercote-13/+16
`TerminatorCodegenHelper` has three methods `llblock`, `llbb`, and `lltarget`. They're all similar, but the names given no indication of the differences. This commit renames `lltarget` as `llbb_with_landing_pad`, and `llblock` as `llbb_with_cleanup`. These aren't fantastic names, but at least it's now clear that `llbb` is the lowest-level of the three and the other two wrap it.
2022-10-25rustc_codegen_ssa: use more consistent naming.Nicholas Nethercote-30/+31
Ensure: - builders always have a `bx` suffix; - backend basic blocks always have an `llbb` suffix, - paired builders and basic blocks have consistent prefixes.
2022-10-24Support raw-dylib functions being used inside inlined functionsDaniel Paoliello-5/+37
2022-10-23Introduce dedicated `-Zdylib-lto` flag for enabling LTO on `dylib`sJakub Beránek-4/+12
2022-10-23Allow LTO for dylibsbjorn3-11/+29