summaryrefslogtreecommitdiff
path: root/compiler/rustc_codegen_cranelift
Commit message (Collapse)AuthorAgeFilesLines
* Remove `LangItems::require`Nilstrieb2023-05-161-5/+1
| | | | | It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
* use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regionsKyle Matsuda2023-05-061-1/+1
|
* Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote2023-05-0314-38/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
* Box AssertKindBen Kimock2023-05-011-1/+1
|
* Merge commit 'ef07e8e60f994ec014d049a95591426fb92ebb79' into ↵bjorn32023-04-2951-670/+1464
| | | | sync_cg_clif-2023-04-29
* rename `needs_infer` to `has_infer`Boxy2023-04-272-2/+2
|
* Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray2023-04-251-1/+1
| | | | They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
* Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger2023-04-252-2/+28
| | | | This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
* Fix `rustc_index` imports outside the compilerMaybe Waffle2023-04-241-1/+1
|
* Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle2023-04-244-4/+4
|
* Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors2023-04-222-28/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
| * Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras2023-04-162-28/+2
| |
* | Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors2023-04-221-1/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
| * | offset_ofDrMeepster2023-04-211-1/+4
| |/
* | Remove WithOptconstParam.Camille GILLOT2023-04-201-1/+1
|/
* Remove from cranelift too.Camille GILLOT2023-04-141-89/+0
|
* Rename `Abort` terminator to `Terminate`Gary Guo2023-04-062-2/+2
| | | | | | Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
* Refactor unwind from Option to a new enumGary Guo2023-04-061-3/+3
|
* Use `FieldIdx` in various things related to aggregatesScott McMurray2023-04-011-3/+4
| | | | Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
* Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors2023-03-311-0/+12
|\ | | | | | | | | | | | | | | | | | | | | | | Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
| * A MIR transform that checks pointers are alignedBen Kimock2023-03-231-0/+12
| |
* | Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray2023-03-301-1/+2
| | | | | | | | | | | | | | | | And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
* | Rollup merge of #109716 - scottmcm:field-to-fieldidx, r=oli-obkMatthias Krüger2023-03-299-18/+18
|\ \ | | | | | | | | | | | | | | | | | | | | | Move `mir::Field` → `abi::FieldIdx` The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
| * | Move `mir::Field` → `abi::FieldIdx`Scott McMurray2023-03-289-18/+18
| | | | | | | | | | | | | | | | | | The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
* | | Support TLS access into dylibs on WindowsJohn Kåre Alsaker2023-03-291-6/+16
|/ /
* | Rollup merge of #108480 - Zoxc:rayon-tlv, r=cuvipernils2023-03-282-3/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | Use Rayon's TLV directly This accesses Rayon's `TLV` thread local directly avoiding wrapper functions. This makes rustc work with https://github.com/rust-lang/rustc-rayon/pull/10. r? `@cuviper`
| * | Update indexmap and rayon cratesJohn Kåre Alsaker2023-03-252-3/+3
| |/
* | Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray2023-03-253-3/+3
|/ | | | | | Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
* Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obkbors2023-03-232-10/+4
|\ | | | | | | | | | | | | | | | | | | Add `CastKind::Transmute` to MIR ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~ Includes lowering `transmute` calls to it, so it's used. Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
| * Add `CastKind::Transmute` to MIRScott McMurray2023-03-222-10/+4
| | | | | | | | | | | | Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
* | Remove Ty::is_region_ptrMu422023-03-201-3/+1
|/
* Tweak implementation of overflow checking assertionsTomasz Miąsko2023-03-161-11/+4
| | | | | Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
* Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiaskobors2023-03-151-23/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Implement checked Shl/Shr at MIR building. This does not require any special handling by codegen backends, as the overflow behaviour is entirely determined by the rhs (shift amount). This allows MIR ConstProp to remove the overflow check for constant shifts. ~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).` I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~ EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
| * Implement checked Shl/Shr at MIR building.Camille GILLOT2023-02-271-23/+0
| |
* | Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into ↵bjorn32023-03-1552-792/+873
| | | | | | | | sync_cg_clif-2023-03-15
* | Remove uses of `box_syntax` in rustc and toolsclubby7892023-03-122-6/+6
| |
* | Auto merge of #109001 - matthiaskrgr:rollup-a3agnwp, r=matthiaskrgrbors2023-03-111-18/+10
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 8 pull requests Successful merges: - #105798 (Relax ordering rules for `asm!` operands) - #105962 (Stabilize path_as_mut_os_str) - #106085 (use problem matchers for tidy CI) - #107711 (Stabilize movbe target feature) - #108017 (Add `--no-undefined-version` link flag and fix associated breakage) - #108891 (Remove an extraneous include) - #108902 (no more do while :<) - #108912 (Document tool lints) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| * \ Rollup merge of #108017 - chbaker0:fix-105967, r=chbaker0Matthias Krüger2023-03-101-18/+10
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add `--no-undefined-version` link flag and fix associated breakage LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402. Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See https://github.com/rust-lang/rust/issues/105967#issuecomment-1428671533 for details. This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated. Fixes #105967
| | * | Don't export of __rust_* alloc symbols if not codegenedCollin Baker2023-03-091-18/+10
| | | |
* | | | Auto merge of #104527 - ferrocene:pa-more-licenses, r=pnkfelixbors2023-03-111-9/+3
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add more license annotations This PR updates the `.reuse/dep5` file to include more accurate licensing data for everything in the repository (*excluding* submodules and dependencies). Some decisions were made in this PR: * The standard copyright attribution for files maintained by us is "The Rust Project Developers (see https://thanks.rust-lang.org)", to avoid having to maintain an in-tree `AUTHORS` file. * For files that have specific licensing terms, we added the terms to the `.reuse/dep5` rather than adding SPDX comments in the files themselves. * REUSE picks up any comment/text line with `Copyright` on it, so I had to sprinkle around `REUSE-IgnoreStart` and `REUSE-IgnoreEnd` comments. The rendered `COPYRIGHT` file is available at https://gist.github.com/pietroalbini/efb81103f69596d39758114f3f6a8688. r? `@pnkfelix`
| * | | replace legacy copyright annotations in submodulesPietro Albini2023-03-091-9/+3
| | | |
* | | | Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT2023-03-092-0/+2
| |/ / |/| |
* | | Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger2023-03-082-3/+1
|\ \ \ | |/ / |/| | | | | | | | | | | Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
| * | Remove DropAndReplace terminatorGiacomo Pasini2023-03-072-3/+1
| | | | | | | | | | | | | | | PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
* | | Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, ↵bors2023-03-071-0/+4
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=pnkfelix,m-ou-se,scottmcm Add `round_ties_even` to `f32` and `f64` Tracking issue: #96710 Redux of #82273. See also #55107 Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this. Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`). Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight. Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
| * | Use rint instead of roundevenJules Bertholet2022-12-111-0/+2
| | | | | | | | | | | | | | | | | | | | | Use rint intrinsic instead of roundeven to impement `round_ties_even`. They do the same thing when rounding mode is default, which Rust assumes. And `rint` has better platform support. Keeps `roundeven` around in `core::intrinsics`, it's doing no harm there.
| * | Add `round_ties_even` to `f32` and `f64`Jules Bertholet2022-12-111-0/+2
| | |
* | | Unify all validity check intrinsicsNilstrieb2023-02-271-49/+31
| | | | | | | | | | | | | | | Also merges the inhabitedness check into the query to further unify the code paths.
* | | Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errorsMatthias Krüger2023-02-271-3/+7
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
| * | Unify validity checks into a single queryNilstrieb2023-02-231-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.