about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/interpret/mod.rs
AgeCommit message (Collapse)AuthorLines
2025-09-09allow `#[rustc_align_static(N)]` on `static`sFolkert de Vries-1/+10
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
2025-07-09Add opaque TypeId handles for CTFEOli Scherer-5/+28
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-2/+2
default data address space
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-1/+1
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-26const-eval: allow constants to refer to mutable/external memory, but reject ↵Ralf Jung-2/+2
such constants as patterns
2025-03-15Move codec module back into middleMichael Goulet-2/+2
2025-03-10Convert `ShardedHashMap` to use `hashbrown::HashTable`Josh Stone-15/+5
The `hash_raw_entry` feature has finished fcp-close, so the compiler should stop using it to allow its removal. Several `Sharded` maps were using raw entries to avoid re-hashing between shard and map lookup, and we can do that with `hashbrown::HashTable` instead.
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-1/+1
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-1/+1
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-02-01Shard AllocMap LockMark Rousskov-24/+42
This improves performance on many-seed parallel (-Zthreads=32) miri executions from managing to use ~8 cores to using 27-28 cores. That's pretty reasonable scaling for the simplicity of this solution.
2025-01-28miri: optimize zeroed allocSpecificProtagonist-2/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-01-09Remove the now-useless `Result` from `lit_to_const`Oli Scherer-9/+0
2025-01-09Use error constant instead of explicit error handlingOli Scherer-2/+0
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-3/+3
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-2/+6
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-09make return type of get_alloc_info a struct, and reduce some code ↵Ralf Jung-3/+83
duplication with validity checking
2024-11-03compiler: Directly use rustc_abi in metadata and middleJubilee Young-1/+1
Stop reexporting ReprOptions from middle::ty
2024-10-19interpret errors: add map_err_kind, rename InterpError -> InterpErrorKindRalf Jung-1/+1
2024-10-01make InterpResult a dedicated type to avoid accidentally discarding the errorRalf Jung-6/+6
2024-09-30panic when an interpreter error gets unintentionally discardedRalf Jung-6/+6
2024-09-23Check vtable projections for validity in miriMichael Goulet-7/+9
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-08-06miri: make vtable addresses not globally uniqueRalf Jung-94/+51
2024-07-29Reformat `use` declarations.Nicholas Nethercote-21/+14
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-22Auto merge of #127442 - saethlin:alloc-decoding-lock, r=oli-obkbors-89/+25
Try to fix ICE from re-interning an AllocId with different allocation contents As far as I can tell, based on my investigation in https://github.com/rust-lang/rust/issues/126741, the racy decoding scheme implemented here was never fully correct, but the arrangement of Allocations that's required to ICE the compiler requires some very specific MIR optimizations to create. As far as I can tell, GVN likes to create the problematic pattern, which is why we're noticing this problem now. So the solution here is to not do racy decoding. If two threads race to decoding an AllocId, one of them is going to sit on a lock until the other is done.
2024-07-21Explain why the new setup can't deadlockBen Kimock-1/+13
2024-07-17Remove in-progress allocation decoding statesBen Kimock-89/+13
2024-07-14Add cache for `allocate_str`Adwin White-6/+11
2024-07-02Miri function identity hack: account for possible inliningRalf Jung-23/+50
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-0/+1
2024-05-13interpret: move error macros into error.rsRalf Jung-129/+8
2024-05-13Remove `extern crate rustc_middle` from `rustc_const_eval`.Nicholas Nethercote-11/+27
This requires exporting the interpreter macros so they can be used with `use crate::interpret::*`.
2024-05-09Remove `TinyList`.Nicholas Nethercote-9/+8
It is optimized for lists with a single element, avoiding the need for an allocation in that case. But `SmallVec<[T; 1]>` also avoids the allocation, and is better in general: more standard, log2 number of allocations if the list exceeds one item, and a much more capable API. This commit removes `TinyList` and converts the two uses to `SmallVec<[T; 1]>`. It also reorders the `use` items in the relevant file so they are in just two sections (`pub` and non-`pub`), ordered alphabetically, instead of many sections. (This is a relevant part of the change because I had to decide where to add a `use` item for `SmallVec`.)
2024-04-29Remove `extern crate rustc_macros` from `rustc_middle`.Nicholas Nethercote-1/+1
2024-03-20resolve clippy errorsonur-ozkan-2/+2
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-1/+11
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-1/+1
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-4/+4
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-15Add new query just for static initializersOli Scherer-5/+6
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1
2024-02-15Use generic `NonZero` internally.Markus Reiter-4/+4
2024-01-04Remove unused `struct_error` function.Nicholas Nethercote-6/+5
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-1/+1
is immutable
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-19Expand Miri's BorTag GC to a Provenance GCBen Kimock-7/+0
2023-11-16Let Miri see the AllocId for all TyCtxt allocationsBen Kimock-0/+7
2023-10-15more precise error for 'based on misaligned pointer' caseRalf Jung-5/+6
2023-10-15place evaluation: require the original pointer to be aligned if an access ↵Ralf Jung-1/+1
happens
2023-09-19move ConstValue into mirRalf Jung-1/+1
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-18Remove unused `Lift` derives.Nicholas Nethercote-1/+1
I found these by commenting out all `Lift` derives and then adding back the ones that were necessary to successfully compile.