about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2024-03-15interpret/allocation: fix aliasing issue in interpreter and refactor getters ↵Ralf Jung-3/+14
a bit - rename mutating functions to be more scary - add a new raw bytes getter
2024-03-14remove unnecessary sized checksLukas Markeffsky-4/+4
2024-03-14Rename some things around validation error reporting to signal that it is in ↵Oli Scherer-7/+9
fact about validation failures
2024-03-14Move the entire success path into `eval_body_using_ecx`Oli Scherer-41/+33
2024-03-14Move validation into eval_body_using_ecxOli Scherer-6/+4
2024-03-14Share the `InterpCx` creation between static and const evaluationOli Scherer-19/+11
2024-03-14Remove an argument that can be computed cheaplyOli Scherer-7/+3
2024-03-14Directly pass in the stack instead of computing it from a machineOli Scherer-5/+6
2024-03-14Move generate_stacktrace_from_stack away from InterpCx to avoid having to ↵Oli Scherer-36/+31
know the `Machine` type
2024-03-14Move InterpCx into eval_in_interpreterOli Scherer-9/+9
2024-03-14Move error handling into const_validate_mplaceOli Scherer-11/+6
2024-03-14Move only usage of `take_static_root_alloc` to its definition and inline itOli Scherer-24/+19
2024-03-14Generalize `eval_in_interpreter` with a helper traitOli Scherer-10/+34
2024-03-14Fix accidental re-addition of removed code in a previous PROli Scherer-3/+0
2024-03-14Auto merge of #122243 - RalfJung:local-place-sanity-check, r=oli-obkbors-70/+59
interpret: ensure that Place is never used for a different frame We store the address where the stack frame stores its `locals`. The idea is that even if we pop and push, or switch to a different thread with a larger number of frames, then the `locals` address will most likely change so we'll notice that problem. This is made possible by some recent changes by `@WaffleLapkin,` where we no longer use `Place` across things that change the number of stack frames. I made these debug assertions for now, just to make sure this can't cost us any perf. The first commit is unrelated but it's a one-line comment change so it didn't warrant a separate PR... r? `@oli-obk`
2024-03-13placate tidy.Felix S. Klock II-1/+1
2024-03-13downgrade mutable-ptr-in-final-value from hard-error to future-incompat lint ↵Felix S. Klock II-6/+13
to address issue 121610.
2024-03-13Auto merge of #122240 - RalfJung:miri-addr-reuse, r=oli-obkbors-2/+4
miri: add some chance to reuse addresses of previously freed allocations The hope is that this can help us find ABA issues. Unfortunately this needs rustc changes so I can't easily run the regular benchmark suite. I used `src/tools/miri/tests/pass/float_nan.rs` as a substitute: ``` Before: Benchmark 1: ./x.py run miri --stage 0 --args src/tools/miri/tests/pass/float_nan.rs --args --edition=2021 Time (mean ± σ): 9.570 s ± 0.013 s [User: 9.279 s, System: 0.290 s] Range (min … max): 9.561 s … 9.579 s 2 runs After: Benchmark 1: ./x.py run miri --stage 0 --args src/tools/miri/tests/pass/float_nan.rs --args --edition=2021 Time (mean ± σ): 9.698 s ± 0.046 s [User: 9.413 s, System: 0.279 s] Range (min … max): 9.666 s … 9.731 s 2 runs ``` That's a ~1.3% slowdown, which seems fine to me. I have seen a lot of noise in this style of benchmarking so I don't quite trust this anyway; we can make further experiments in the Miri repo after this migrated there. r? `@oli-obk`
2024-03-12Exhaustively match on the mutability and nestednessOli Scherer-7/+9
2024-03-12s/mt/mutability/Oli Scherer-4/+4
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-36/+110
2024-03-12Add `nested` bool to `DefKind::Static`.Oli Scherer-1/+1
Will be used in the next commit
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-10/+11
2024-03-11Rollup merge of #122249 - RalfJung:machine-read-hook, r=oli-obkJubilee-12/+45
interpret: do not call machine read hooks during validation Fixes https://github.com/rust-lang/miri/issues/3347 r? ``@oli-obk``
2024-03-11Rollup merge of #121893 - RalfJung:const-interior-mut-tests, r=oli-obkJubilee-5/+6
Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking Basically these are the parts of https://github.com/rust-lang/rust/pull/121786 that can be salvaged. r? ``@oli-obk``
2024-03-11const-checking: add some corner case tests, and fix some nitsRalf Jung-5/+5
2024-03-11Auto merge of #122132 - nnethercote:diag-renaming3, r=nnethercotebors-13/+12
Diagnostic renaming 3 A sequel to https://github.com/rust-lang/rust/pull/121780. r? `@davidtwco`
2024-03-11Rename `DecorateLint` as `LintDiagnostic`.Nicholas Nethercote-1/+1
To match `derive(LintDiagnostic)`.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-5/+4
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-7/+7
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-11Remove unused impls from some subdiagnostics.Nicholas Nethercote-1/+1
2024-03-10Rollup merge of #122290 - RalfJung:mir-printing, r=compiler-errorsMatthias Krüger-1/+1
MIR printing: print the path of uneval'd const Currently it just prints `const _` which makes it impossible to say which constant is being referred to. Also refer to promoteds in a consistent way; previously MIR printing would do ``` promoted[0] in C1: &Option<Cell<i32>> = { // ... } ``` Now that should be ``` const C1::promoted[0]: &Option<Cell<i32>> = { // ... } ``` We don't seem to have a test for that so I tried it by hand, it seems to work: ``` const main::promoted[12]: &[&str; 3] = { let mut _0: &[&str; 3]; let mut _1: [&str; 3]; let mut _2: &str; let mut _3: &str; let mut _4: &str; let mut _5: &str; bb0: { _3 = const "b"; _2 = &(*_3); _5 = const "c"; _4 = &(*_5); _1 = [const "a", move _2, move _4]; _0 = &_1; return; } } ```
2024-03-10MIR printing: print the path of uneval'd const; refer to promoteds in a ↵Ralf Jung-1/+1
consistent way
2024-03-10use Instance::expect_resolve() instead of unwraping Instance::resolve()Ralf Jung-4/+2
2024-03-10remove unnecessary frame parameter from after_local_allocatedRalf Jung-4/+4
2024-03-10Auto merge of #121662 - saethlin:precondition-unification, r=RalfJungbors-6/+12
Distinguish between library and lang UB in assert_unsafe_precondition As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186, `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do). `debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation. Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR. r? RalfJung
2024-03-09interpret: do not call machine read hooks during validationRalf Jung-12/+45
2024-03-09remove some frame parameters that are no longer neededRalf Jung-17/+17
2024-03-09remove a machine hook that is no longer usedRalf Jung-24/+0
2024-03-09interpret: ensure that Place is never used for a different frameRalf Jung-33/+46
2024-03-09Only enable library UB checks in const-eval/Miri when debug_assertions are ↵Ben Kimock-1/+1
enabled Co-authored-by: Ralf Jung <post@ralfj.de>
2024-03-09interpret: pass Size and Align to before_memory_deallocationRalf Jung-2/+4
2024-03-09miri: do not apply aliasing restrictions to Box with custom allocatorRalf Jung-7/+11
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-6/+12
2024-03-08Rollup merge of #122076 - WaffleLapkin:mplace-args, r=RalfJungMatthias Krüger-26/+52
Tweak the way we protect in-place function arguments in interpreters Use `MPlaceTy` instead of `PlaceTy` in `FnArg` and ignore (copy) locals in an earlier step ("Locals that don't have their address taken are as protected as they can ever be"). This seems to be crucial for tail call support (as they can't refer to caller's locals which are killed when replacing the stack frame). r? `@RalfJung` cc `@oli-obk` see https://github.com/rust-lang/rust/pull/121273#issuecomment-1980210690
2024-03-08Tweak the way we protect in-place function arguments in interpretersMaybe Waffle-26/+52
Use `MPlaceTy` instead of `PlaceTy` in `FnArg` and ignore (copy) locals in an earlier step ("Locals that don't have their address taken are as protected as they can ever be"). This seems to be crucial for tail call support (as they can't refer to caller's locals which are killed when replacing the stack frame).
2024-03-08Rollup merge of #122183 - RalfJung:read-discriminant-uninhabited-variant, ↵Matthias Krüger-1/+7
r=tmiasko interpret: update comment about read_discriminant on uninhabited variants
2024-03-08Rollup merge of #122173 - compiler-errors:ptr-equality-in-ctfe, r=lcnrMatthias Krüger-1/+0
Don't ICE in CTFE if raw/fn-ptr types differ Fixes #121688 r? lcnr
2024-03-08interpret: update comment about read_discriminant on uninhabited variantsRalf Jung-1/+7
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-13/+11
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``