about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/util
AgeCommit message (Collapse)AuthorLines
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-1/+1
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-7/+9
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-05Pretty print pattern type values with `transmute` if they don't satisfy ↵Oli Scherer-13/+42
their pattern
2025-02-03Remove hook calling via `TyCtxtAt`.Nicholas Nethercote-5/+4
All hooks receive a `TyCtxtAt` argument. Currently hooks can be called through `TyCtxtAt` or `TyCtxt`. In the latter case, a `TyCtxtAt` is constructed with a dummy span and passed to the hook. However, in practice hooks are never called through `TyCtxtAt`, and always receive a dummy span. (I confirmed this via code inspection, and double-checked it by temporarily making the `TyCtxtAt` code path panic and running all the tests.) This commit removes all the `TyCtxtAt` machinery for hooks. All hooks now receive `TyCtxt` instead of `TyCtxtAt`. There are two existing hooks that use `TyCtxtAt::span`: `const_caller_location_provider` and `try_destructure_mir_constant_for_user_output`. For both hooks the span is always a dummy span, probably unintentionally. This dummy span use is now explicit. If a non-dummy span is needed for these two hooks it would be easy to add it as an extra argument because hooks are less constrained than queries.
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-1/+2
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-0/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-09interpret: clean up deduplicating allocation functionsRalf Jung-6/+3
2024-11-19`InterpCx` store `TypingEnv` instead of a `ParamEnv`lcnr-2/+2
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-16/+13
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-03compiler: Directly use rustc_abi in const_evalJubilee Young-1/+1
2024-10-31stop using `ParamEnv::reveal` while handling MIRlcnr-16/+7
2024-10-30Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errorsJubilee-7/+7
Rename `rustc_abi::Abi` to `BackendRepr` Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights. Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-7/+7
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
2024-10-29TypingMode :thinking:lcnr-2/+3
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-1/+1
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-01make InterpResult a dedicated type to avoid accidentally discarding the errorRalf Jung-2/+1
2024-09-30panic when an interpreter error gets unintentionally discardedRalf Jung-1/+3
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-16layout computation: eagerly error for unexpected unsized fieldsLukas Markeffsky-3/+5
2024-09-16make `LayoutCx` not genericLukas Markeffsky-2/+2
2024-09-08clarify comments and names in check_validity_requirementRalf Jung-9/+11
2024-09-08interpret: reset padding during validationRalf Jung-1/+1
2024-09-08interpret: reset provenance on typed copiesRalf Jung-4/+8
2024-08-14Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errorsbors-1/+1
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-1/+1
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-1/+1
2024-08-08Normalize struct tail properly in disalignment checkMichael Goulet-1/+1
2024-08-06pass the right `ParamEnv` to `might_permit_raw_init_strict`y21-5/+5
2024-08-03Miri: add a flag to do recursive validity checkingRalf Jung-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-8/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-13rename CompileTimeInterpreter -> CompileTimeMachine, CompileTimeEvalContext ↵Ralf Jung-4/+4
-> CompileTimeInterpCx to match the terms used in the shared interpreter infrastructure
2024-05-27interpret: get rid of 'mir lifetime everywhereRalf Jung-2/+2
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_const_eval`.Nicholas Nethercote-0/+2
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-3/+6
2024-05-13Remove `extern crate rustc_middle` from `rustc_const_eval`.Nicholas Nethercote-0/+3
This requires exporting the interpreter macros so they can be used with `use crate::interpret::*`.
2024-05-09Make builtin_deref just return a TyMichael Goulet-1/+1
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+1
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-2/+2
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-1/+1
2024-03-02Rollup merge of #121731 - oli-obk:eager_opaque_checks, r=compiler-errorsGuillaume Boisseau-22/+3
Now that inlining, mir validation and const eval all use reveal-all, we won't be constraining hidden types here anymore r? `@compiler-errors` one bubble down, two more to go the test is unrelated, just something I noticed would be good to test in both the old solver and the new.
2024-02-28Now that inlining, mir validation and const eval all use reveal-all, we ↵Oli Scherer-22/+3
won't be constraining hidden types here anymore
2024-02-27Split rustc_type_ir to avoid rustc_ast from depending on itOli Scherer-2/+1
2024-02-21make it possible for outside crates to inspect a mir::ConstValue with the ↵Ralf Jung-2/+7
interpreter
2024-02-10unstably allow constants to refer to statics and read from immutable staticsRalf Jung-4/+4
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+1
2024-01-25Auto merge of #119627 - oli-obk:const_prop_lint_n̵o̵n̵sense, r=cjgillotbors-2/+2
Remove all ConstPropNonsense We track all locals and projections on them ourselves within the const propagator and only use the InterpCx to actually do some low level operations or read from constants (via `OpTy` we get for said constants). This helps moving the const prop lint out from the normal pipeline and running it just based on borrowck information. This in turn allows us to make progress on https://github.com/rust-lang/rust/pull/108730#issuecomment-1875557745 there are various follow up cleanups that can be done after this PR (e.g. not matching on Rvalue twice and doing binop checks twice), but lets try landing this one first. r? `@RalfJung`
2024-01-23partially inline `eval_rvalue_into_place` for const prop lintOli Scherer-2/+2
2024-01-22const-eval interner: from-scratch rewrite using mutability information from ↵Ralf Jung-0/+1
provenance rather than types
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-1/+1