about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift
AgeCommit message (Collapse)AuthorLines
2023-06-27Provide more context for `rustc +nightly -Zunstable-options` on stable许杰友 Jieyou Xu (Joe)-2/+2
2023-06-19Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naberMichael Goulet-1/+1
Better error for non const `PartialEq` call generated by `match` Resolves #90237
2023-06-19Remove unchecked_add/sub/mul/shl/shr from CTFE/cg_ssa/cg_clifScott McMurray-17/+3
2023-06-19Promote unchecked_add/sub/mul/shl/shr to mir::BinOpScott McMurray-10/+15
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-1/+1
2023-06-16remove box_free and replace with drop implDrMeepster-6/+2
2023-06-15Merge commit '8830dccd1d4c74f1f69b0d3bd982a3f1fcde5807' into ↵bjorn3-595/+2514
sync_cg_clif-2023-06-15
2023-06-13Auto merge of #112314 - ferrocene:pa-core-alloc-abort, r=bjorn3bors-36/+0
Ignore `core`, `alloc` and `test` tests that require unwinding on `-C panic=abort` Some of the tests for `core` and `alloc` require unwinding through their use of `catch_unwind`. These tests fail when testing using `-C panic=abort` (in my case through a target without unwinding support, and `-Z panic-abort-tests`), while they should be ignored as they don't indicate a failure. This PR marks all of these tests with this attribute: ```rust #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] ``` I'm not aware of a way to test this on rust-lang/rust's CI, as we don't test any target with `-C panic=abort`, but I tested this locally on a Ferrocene target and it does indeed make the test suite pass.
2023-06-13remove patch from cranelift backend to ignore unwinding testsPietro Albini-36/+0
2023-06-04Updated cranelift codegen to reflect modified trait signatureAndrew Xie-4/+4
2023-06-02Rollup merge of #112168 - scottmcm:lower-div-rem-unchecked-to-mir, r=oli-obkMichael Goulet-4/+1
Lower `unchecked_div`/`_rem` to MIR's `BinOp::Div`/`Rem` As described in <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.BinOp.html#variant.Div>, the ordinary `BinOp`s for these are already UB for division by zero ([or overflow](https://llvm.org/docs/LangRef.html#sdiv-instruction), [demo](https://rust.godbolt.org/z/71e7P7Exh)), as MIR building is responsible for inserting code to panic for those cases regardless of whether the overflow checks are enabled. So we can lower these in the same arm that lowers `wrapping_add` to MIR `BinOp::Add` and such, as all these cases turn into ordinary `Rvalue::BinaryOp`s.
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-12/+4
2023-06-01remove unchecked_div/_rem from cg_craneliftScott McMurray-4/+1
2023-05-30Rollup merge of #112060 - lcnr:early-binder, r=jackh726Nilstrieb-1/+1
`EarlyBinder::new` -> `EarlyBinder::bind` for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR. r? `@jackh726` `@kylematsuda`
2023-05-29Rollup merge of #111827 - AngelicosPhosphoros:add_docs_to_cranelift, r=bjorn3Matthias Krüger-0/+26
Add build instructions for cranelift backend as part of Rust repo All other instructions assume that user works with separate repository than Rust compiler repository. When one follows default instructions, cranelift codegen tries to use different sys-root and compiler internal crates which leads to compiler errors when building it. I needed to do all this steps while adding new intrinsic to rustc. r? bjorn3
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-1/+1
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-1/+1
2023-05-27Rollup merge of #111952 - cjgillot:drop-replace, r=WaffleLapkinGuillaume Gomez-1/+1
Remove DesugaringKind::Replace. A simple boolean flag is enough.
2023-05-25Rollup merge of #111950 - cjgillot:expn-noinline, r=oli-obkMichael Goulet-5/+1
Remove ExpnKind::Inlined. Suggested in https://github.com/rust-lang/rust/pull/111815#issuecomment-1561903339 r? ``@oli-obk``
2023-05-25Added build instructions for cranelift backend as part of Rust repoAngelicosPhosphoros-0/+26
All other instructions assume that user works with separate repository than Rust compiler repository. When one follows default instructions, cranelift codegen tries to use different sys-root and compiler internal crates which leads to compiler errors when building it. I needed to do all this steps while adding new intrinsic to rustc.
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-1/+1
2023-05-25Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelixbors-34/+45
Support #[global_allocator] without the allocator shim This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim. Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist. To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors. (Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-5/+1
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-10/+8
2023-05-18Rollup merge of #111633 - nnethercote:avoid-ref-format, r=WaffleLapkinDylan DPC-1/+1
Avoid `&format("...")` calls in error message code. Some error message cleanups. Best reviewed one commit at a time. r? `@davidtwco`
2023-05-16Remove `LangItems::require`Nilstrieb-5/+1
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-1/+1
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-11Prevent insta-stable no alloc shim supportbjorn3-1/+8
You will need to add the following as replacement for the old __rust_* definitions when not using the alloc shim. #[no_mangle] static __rust_no_alloc_shim_is_unstable: u8 = 0;
2023-05-11Use global_fn_name instead of format!bjorn3-2/+3
2023-05-11Split AllocatorKind::fn_name in global_fn_name and default_fn_namebjorn3-2/+2
2023-05-11Don't use an allocator shim for `#[global_allocator]`bjorn3-34/+37
This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. Making it work for the default libstd allocator would require weak functions, which are not well supported on all systems.
2023-05-06use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regionsKyle Matsuda-1/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-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.
2023-05-01Box AssertKindBen Kimock-1/+1
2023-04-29Merge commit 'ef07e8e60f994ec014d049a95591426fb92ebb79' into ↵bjorn3-670/+1464
sync_cg_clif-2023-04-29
2023-04-27rename `needs_infer` to `has_infer`Boxy-2/+2
2023-04-25Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray-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.
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-2/+28
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-24Fix `rustc_index` imports outside the compilerMaybe Waffle-1/+1
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-4/+4
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-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
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-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)
2023-04-21offset_ofDrMeepster-1/+4
2023-04-20Remove WithOptconstParam.Camille GILLOT-1/+1
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-28/+2
2023-04-14Remove from cranelift too.Camille GILLOT-89/+0
2023-04-06Rename `Abort` terminator to `Terminate`Gary Guo-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.
2023-04-06Refactor unwind from Option to a new enumGary Guo-3/+3
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-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>`.
2023-03-31Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors-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`