Commit Graph

318 Commits

Author SHA1 Message Date
Jakob Degen ae7d6facda Relax restrictions for copy operands 2022-04-22 16:45:15 -04:00
Dylan DPC 72cb094611 Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obk
Miri/interpreter debugging tweaks

Some changes I made to make debugging Miri with trace logging less terrible.

r? ``@oli-obk``
2022-04-20 18:26:02 +02:00
Dylan DPC 9d9d5910af Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obk
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-19 22:57:43 +02:00
Ralf Jung 55f0977a6b remove an unnecessary use of loc_place.ptr.into_pointer_or_addr 2022-04-18 12:47:38 -04:00
Ralf Jung c83241a7f9 avoid an unnecessary call to Pointer::into_parts, and caution against into_pointer_or_addr 2022-04-18 12:30:17 -04:00
Ralf Jung 3236092503 add method to get absolute address of a pointer (useful only for Miri) 2022-04-18 12:30:17 -04:00
Ralf Jung c9e568f72e avoid pairing up AllocId and PointerTag, which is redundant 2022-04-18 10:14:06 -04:00
Ralf Jung 54ab357a5b ptr_get_alloc_id: don't return an actual Pointer 2022-04-17 22:27:14 -04:00
Ralf Jung f3bdcfb8b0 downgrade really verbose logging to trace 2022-04-17 20:52:33 -04:00
Ralf Jung 989e7479d9 interpret: more debug logging for read_scalar and write_scalar 2022-04-17 20:52:30 -04:00
Ralf Jung 3ec1febbf5 add caution to some comments 2022-04-17 19:32:13 -04:00
Ralf Jung 85ee04c44a when writing uninit to an allocation, also clear relocations like other writes do 2022-04-17 19:16:54 -04:00
Dylan DPC 1dc672a766 Rollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obk
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-16 19:42:03 +02:00
Dylan DPC ab7fb29878 Rollup merge of #96050 - oli-obk:deaggregator_cleanup, r=RalfJung
Remove some now-dead code that was only relevant before deaggregation.

The code was broken anyway, if the deaggregator is disabled, it would have ICEd on any non-enum Adt

r? ```@RalfJung```
2022-04-16 07:12:47 +02:00
b-naber d8205cd3fe handle arrays and slices uniformly in valtree creation 2022-04-14 22:01:40 +02:00
Oli Scherer 48029aba2c Remove some now-dead code that was only relevant before deaggregation.
The code was broken anyway, if the deaggregator is disabled, it would have ICE on any non-enum Adt
2022-04-14 13:31:21 +00:00
Jakob Degen d5f3863204 Consider lifetimes when comparing types for equality in MIR validator 2022-04-13 05:51:08 -04:00
b-naber 4b126b805b use len on mplace instead of reading immediate, remove dead code 2022-04-12 16:08:59 +02:00
Jakob Degen 8732bf5db3 Remove rule that place loads may not happen with variant index set 2022-04-11 15:56:04 -04:00
Jakob Degen 411ae6f5ad Address various comments and change some details around place to value conversions 2022-04-11 15:22:32 -04:00
Jakob Degen f2d7908ff7 Adjust MIR validator to check a few more things for terminators 2022-04-11 15:22:32 -04:00
Jakob Degen 9ac5e986ed Extend the MIR validator to check many more things around rvalues. 2022-04-11 15:18:54 -04:00
Jakob Degen 2f4a7a0742 Adjust computation of place types to detect more invalid places 2022-04-11 15:18:53 -04:00
Jakob Degen 9b6b1a625b Add new Deinit statement kind 2022-04-11 08:55:03 -04:00
Camille GILLOT db03a2deb0 Avoid accessing HIR from MIR queries. 2022-04-10 13:08:36 +02:00
b-naber 8a5273bc99 use deref on ImmTy 2022-04-08 17:13:45 +02:00
b-naber 82217a6587 create leafs for slices 2022-04-08 15:45:14 +02:00
Ralf Jung 38004b72bc interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal 2022-04-07 16:24:48 -04:00
bors b6ab1fae73 Auto merge of #95707 - RalfJung:initialized, r=oli-obk
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-06 14:07:27 +00:00
Dylan DPC acdba55b53 Rollup merge of #95693 - RalfJung:more-context, r=oli-obk
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-06 03:39:08 +02:00
Ralf Jung d214b38755 interp/validity: enforce Scalar::Initialized 2022-04-05 19:46:51 -04:00
Ralf Jung fcdfc3e1c1 interp: pass TyCtxt to Machine methods that do not take InterpCx 2022-04-05 13:31:51 -04:00
bors f262ca12aa Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardin
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-05 16:46:13 +00:00
Oli Scherer 09b291f0b2 mir-interpret now treats unions as non-immediate, even if they have scalar layout, allowing partially initializing them 2022-04-05 13:18:22 +00:00
Oli Scherer d32ce37a17 Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
Ralf Jung 84a343d1b5 tweak some function names 2022-04-03 15:31:25 -04:00
Ralf Jung f0ec783bf9 interpret: remove MemoryExtra in favor of giving access to the Machine 2022-04-03 15:28:34 -04:00
bors eb82facb16 Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obk
Encode even more metadata through tables instead of EntryKind

This should move us closer to getting rid of `EntryKind`.
2022-04-01 21:16:41 +00:00
Camille GILLOT 15b2d1a97c Merge impl_constness and is_const_fn_raw. 2022-03-31 18:33:46 +02:00
Ralf Jung a417911c16 catch overflow in slice size computation 2022-03-31 08:57:45 -04:00
Ralf Jung 53c540a666 audit check_mul uses in interpret 2022-03-31 08:57:45 -04:00
Ralf Jung a421cbbead interpret: make isize::MAX the limit for dynamic value sizes 2022-03-31 08:57:45 -04:00
bors a40c595695 Auto merge of #95436 - cjgillot:static-mut, r=oli-obk
Remember mutability in `DefKind::Static`.

This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.
2022-03-30 22:09:56 +00:00
bors 05142a7e44 Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #95294 (Document Linux kernel handoff in std::io::copy and std::fs::copy)
 - #95443 (Clarify how `src/tools/x` searches for python)
 - #95452 (fix since field version for termination stabilization)
 - #95460 (Spellchecking compiler code)
 - #95461 (Spellchecking some comments)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-30 07:45:42 +00:00
Yuri Astrakhan 7e8201ae0a Spellchecking some comments
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 01:39:38 -04:00
Camille GILLOT 21a554caf6 Remember mutability in DefKind::Static.
This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.
2022-03-29 18:50:52 +02:00
b-naber fcc4d8ce98 include refs in valtree creation 2022-03-29 11:41:01 +02:00
Oli Scherer 4cfaf9a931 Normalize all projections in mir validation again 2022-03-28 16:30:16 +00:00
Oli Scherer 264cd05b16 Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit 6499c5e7fc, reversing
changes made to 78450d2d60.
2022-03-28 16:27:14 +00:00
Ralf Jung 3bbcf64fb3 interpret: with enforce_number_validity, ensure integers are truly Scalar::Int (i.e., no pointers) 2022-03-26 14:35:36 -04:00