about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/base.rs
AgeCommit message (Collapse)AuthorLines
2025-07-01Remove support for dyn*Michael Goulet-8/+0
2025-06-27Insert checks for enum discriminants when debug assertions are enabledBastian Kersting-0/+12
Similar to the existing nullpointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@.
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-8/+8
2025-05-25Merge commit '979dcf8e2f213e4f4b645cb62e7fe9f4f2c0c785' into ↵bjorn3-20/+49
sync_cg_clif-2025-05-25
2025-04-30Rollup merge of #134232 - bjorn3:naked_asm_improvements, r=wesleywiserMatthias Krüger-37/+2
Share the naked asm impl between cg_ssa and cg_clif This was introduced in https://github.com/rust-lang/rust/pull/128004.
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-1/+5
async_drop_in_place::{closure}, scoped async drop added.
2025-04-14Use cg_ssa's version of codegen_naked_asm in cg_clifbjorn3-37/+2
2025-03-30Merge commit 'ba315abda789c9f59f2100102232bddb30b0d3d3' into ↵bjorn3-2/+4
sync_cg_clif-2025-03-30
2025-02-10Extend the renaming to coerce_unsafe_ptrBastian Kersting-2/+2
2025-02-03Refactor contract builtin macro + error handlingCelina G. Val-2/+2
Instead of parsing the different components of a function signature, eagerly look for either the `where` keyword or the function body. - Also address feedback to use `From` instead of `TryFrom` in cranelift contract and ubcheck codegen.
2025-02-03Contracts core intrinsics.Felix S. Klock II-0/+9
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-02-01Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obkMatthias Krüger-1/+7
Implement MIR lowering for unsafe binders This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are `Copy`. Later on, I'll introduce a new trait that relaxes this requirement to being "is `Copy` or `ManuallyDrop<T>`" which more closely models how we treat union fields. Namely, wrapping unsafe binders is now `Rvalue::WrapUnsafeBinder`, which acts much like an `Rvalue::Aggregate`. Unwrapping unsafe binders are implemented as a MIR projection `ProjectionElem::UnwrapUnsafeBinder`, which acts much like `ProjectionElem::Field`. Tracking: - https://github.com/rust-lang/rust/issues/130516
2025-01-31Enforce unsafe binders must be Copy (for now)Michael Goulet-0/+4
2025-01-31Implement MIR, CTFE, and codegen for unsafe bindersMichael Goulet-1/+3
2025-01-31Insert null checks for pointer dereferences when debug assertions are enabledBastian Kersting-0/+10
Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-0/+6
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.
2024-12-22Delete `Rvalue::Len`Scott McMurray-6/+0
Everything's moved to `PtrMetadata` instead.
2024-12-06Remove polymorphizationBen Kimock-5/+3
2024-12-06Merge commit '57845a397ec15e4e6a561ed2c4bfa3dcf49144fb' into ↵bjorn3-8/+11
sync_cg_clif-2024-12-06
2024-11-23remove remaining references to `Reveal`lcnr-1/+1
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-0/+1
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <nikomat@amazon.com> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-2/+2
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-3/+7
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-09Merge commit '1fa693ca4462fc1f790693464cf765ad693616af' into ↵bjorn3-1/+1
sync_cg_clif-2024-11-09
2024-11-02Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into ↵bjorn3-10/+12
sync_cg_clif-2024-11-02
2024-10-29cg_clif: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-4/+4
2024-10-06various fixes for `naked_asm!` implementationFolkert de Vries-0/+3
- fix for divergence - fix error message - fix another cranelift test - fix some cranelift things - don't set the NORETURN option for naked asm - fix use of naked_asm! in doc comment - fix use of naked_asm! in run-make test - use `span_bug` in unreachable branch
2024-10-04Use wide pointers consistenly across the compilerUrgau-5/+5
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-5/+6
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-1/+5
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-20Do not unnecessarily eval consts in codegenMichael Goulet-3/+8
2024-08-30introduce `PrettyPrintMirOptions` for cosmetic MIR dump optionsRémy Rakic-2/+3
initially starting with `-Z mir-include-spans` because we want them in the NLL mir dump pass
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-1/+1
2024-07-15Move compiler_builtin check to the use caseMohammad Omidvar-1/+1
2024-07-07Support tail calls in mir via `TerminatorKind::TailCall`Maybe Waffle-0/+5
2024-06-30Merge commit '49cd5dd454d0115cfbe9e39102a8b3ba4616aa40' into ↵bjorn3-4/+1
sync_cg_clif-2024-06-30
2024-06-19`bug!` more uses of these in runtime stuffScott McMurray-10/+11
2024-06-08offset_of: allow (unstably) taking the offset of slice tail fieldsRalf Jung-3/+4
2024-05-29Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk许杰友 Jieyou Xu (Joe)-13/+25
Add an intrinsic for `ptr::metadata` The follow-up to #123840, so we can remove `PtrComponents` and `PtrRepr` from libcore entirely (well, after a bootstrap update). As discussed in <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/.60ptr_metadata.60.20in.20MIR/near/435637808>, this introduces `UnOp::PtrMetadata` taking a raw pointer and returning the associated metadata value. By no longer going through a `union`, this should also help future PRs better optimize pointer operations. r? ``@oli-obk``
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-13/+25
2024-05-27Omit non-needs_drop drop_in_place in vtablesMark Rousskov-4/+1
This replaces the drop_in_place reference with null in vtables. On librustc_driver.so, this drops about ~17k dynamic relocations from the output, since many vtables can now be placed in read-only memory, rather than having a relocated pointer included. This makes a tradeoff by adding a null check at vtable call sites. That's hard to avoid without changing the vtable format (e.g., to use a pc-relative relocation instead of an absolute address, and avoid the dynamic relocation that way). But it seems likely that the check is cheap at runtime.
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-8/+5
2024-05-13Merge commit '3270432f4b0583104c8b9b6f695bf97d6bbf3ac2' into ↵bjorn3-2/+35
sync_cg_clif-2024-05-13
2024-05-09Make builtin_deref just return a TyMichael Goulet-5/+2
2024-04-23Merge commit 'de5d6523738fd44a0521b6abf3e73ae1df210741' into ↵bjorn3-1/+9
sync_cg_clif-2024-04-23
2024-04-21Also handle AggregateKind::RawPtr in cg_craneliftScott McMurray-0/+13
2024-04-11Merge commit '89f54caacf90e99fc8ba0d60a28bdadea3cfdf1e' into ↵bjorn3-1/+10
sync_cg_clif-2024-04-11
2024-04-07Only traverse mono-reachable blocks in cg_clifBen Kimock-1/+1
2024-04-06Put checks that detect UB under their own flag below debug_assertionsBen Kimock-1/+1