summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
AgeCommit message (Collapse)AuthorLines
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-1/+1
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-14Auto merge of #95826 - carbotaniuman:miri-permissive-provenance, r=RalfJungbors-34/+103
Initial work on Miri permissive-exposed-provenance Rustc portion of the changes for portions of a permissive ptr-to-int model for Miri. The main changes here are changing `ptr_get_alloc` and `get_alloc_id` to return an Option, and also making ptr-to-int casts have an expose side effect.
2022-05-13Add bound_type_ofJack Huey-5/+4
2022-05-13Rustc changes for permissive provenancecarbotaniuman-34/+103
2022-05-11Apply CR suggestions; add real tracking issueScott McMurray-0/+2
2022-05-11Add a debug check for ordering, and check for isize overflow in CTFEScott McMurray-3/+10
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-5/+19
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11Auto merge of #96220 - RalfJung:scalar-no-padding, r=oli-obkbors-53/+53
tighten sanity checks around Scalar and ScalarPair While investigating https://github.com/rust-lang/rust/issues/96185 I noticed codegen has tighter sanity checks here than Miri does, so I added some more assertions. Strangely, some of them fail, so I also needed to add a HACK... that is probably worth looking into. This does not fix that issue, but it changes the ICE messages, making it quite clear that we have a scalar whose size is not the same as that of the surrounding layout. r? `@oli-obk`
2022-05-11avoid computing Scalar size/align in debug buildsRalf Jung-3/+3
2022-05-10Introduce EarlyBinderJack Huey-4/+5
2022-05-10fmtRalf Jung-3/+1
2022-05-10update/remove some old commentsRalf Jung-5/+1
2022-05-10even tighter checks for layouts on immediate field projectionsRalf Jung-6/+11
2022-05-10disable one check for now until #96185 is fixedRalf Jung-4/+5
2022-05-10tighten sanity checks around Scalar and ScalarPairRalf Jung-44/+44
2022-05-06Fix inaccurate function name in `rustc_const_eval` docspierwill-3/+3
2022-05-05give it a scary nameRalf Jung-10/+13
2022-05-04interpret: debug-check ScalarPair layout informationRalf Jung-43/+86
2022-04-26account for custom DSTs in valtree -> constvalue conversionb-naber-0/+6
2022-04-21deduplicate a lot of codeb-naber-18/+6
2022-04-21implement valtree -> constvalue conversionb-naber-6/+28
2022-04-20Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obkDylan DPC-6/+23
Miri/interpreter debugging tweaks Some changes I made to make debugging Miri with trace logging less terrible. r? ``@oli-obk``
2022-04-19Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obkDylan DPC-45/+58
Miri provenance cleanup Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here. ``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type. r? ``@oli-obk``
2022-04-18avoid an unnecessary call to Pointer::into_parts, and caution against ↵Ralf Jung-3/+2
into_pointer_or_addr
2022-04-18add method to get absolute address of a pointer (useful only for Miri)Ralf Jung-6/+4
2022-04-18avoid pairing up AllocId and PointerTag, which is redundantRalf Jung-23/+40
2022-04-17ptr_get_alloc_id: don't return an actual PointerRalf Jung-30/+29
2022-04-17downgrade really verbose logging to traceRalf Jung-2/+2
2022-04-17interpret: more debug logging for read_scalar and write_scalarRalf Jung-4/+21
2022-04-17add caution to some commentsRalf Jung-1/+1
2022-04-17when writing uninit to an allocation, also clear relocations like other ↵Ralf Jung-5/+10
writes do
2022-04-16Rollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obkDylan DPC-1/+1
Include Refs in Valtree Creation This adds references to `const_to_valtree`, which isn't used in the compiler yet, but after the previous changes we made to the thir and mir representations and this change we should be able to finally introduce them in the next PR. I wasn't able to properly test this code, except indirectly by including a call of `const_to_valtree` in the code that currently creates constants (`turn_into_const_value`). r? `@lcnr` cc `@oli-obk` `@RalfJung`
2022-04-14Remove some now-dead code that was only relevant before deaggregation.Oli Scherer-19/+3
The code was broken anyway, if the deaggregator is disabled, it would have ICE on any non-enum Adt
2022-04-12use len on mplace instead of reading immediate, remove dead codeb-naber-2/+2
2022-04-11Add new `Deinit` statement kindJakob Degen-0/+46
2022-04-08use deref on ImmTyb-naber-1/+1
2022-04-08create leafs for slicesb-naber-45/+4
2022-04-07interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internalRalf Jung-30/+39
2022-04-06Auto merge of #95707 - RalfJung:initialized, r=oli-obkbors-4/+22
interp/validity: enforce Scalar::Initialized This is a follow-up to https://github.com/rust-lang/rust/pull/94527, to also account for the new kind of `Scalar` layout inside the validity checker. r? `@oli-obk`
2022-04-06Rollup merge of #95693 - RalfJung:more-context, r=oli-obkDylan DPC-6/+11
interp: pass TyCtxt to Machine methods that do not take InterpCx This just seems like something you might need, so let's consistently have it. One day we might have to add `ParamEnv` as well, though that seems less likely (and in Miri you can always use `reveal_all` anyway). It might make sense to have a type that packages `TyCtxt` and `ParamEnv`, this pairing occurs quite frequently in rustc... r? `@oli-obk`
2022-04-05interp/validity: enforce Scalar::InitializedRalf Jung-4/+22
2022-04-05interp: pass TyCtxt to Machine methods that do not take InterpCxRalf Jung-6/+11
2022-04-05Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardinbors-16/+25
Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized. follow up to #94411 To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union cc `@RalfJung` r? `@ghost`
2022-04-05mir-interpret now treats unions as non-immediate, even if they have scalar ↵Oli Scherer-5/+9
layout, allowing partially initializing them
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-13/+18
initialized scalars can special case them.
2022-04-03tweak some function namesRalf Jung-13/+13
2022-04-03interpret: remove MemoryExtra in favor of giving access to the MachineRalf Jung-221/+178
2022-03-31catch overflow in slice size computationRalf Jung-1/+2
2022-03-31audit check_mul uses in interpretRalf Jung-1/+7
2022-03-31interpret: make isize::MAX the limit for dynamic value sizesRalf Jung-8/+10