Commit Graph

1488 Commits

Author SHA1 Message Date
bors e013f9e0ca Auto merge of #96815 - SparrowLii:promote_const, r=oli-obk
optimize `promote_consts` by caching the results of `validate_local`

From the FIXME in the impl of `promote_consts`. Early return the `validate_local` should save some compile time.

`qualif_local` is similar to this, but requires futher changing because there are different types of qualif checks. If this PR is effective, I will do it as well.
2022-05-09 11:49:09 +00:00
SparrowLii b890037af3 use Result<(),()> instead of Validity enum 2022-05-09 17:13:30 +08:00
SparrowLii cb7f116c04 optimize promote_consts by cache the validate check 2022-05-07 21:02:25 +08:00
Jakob Degen c4168fdb50 Check that field projections have the correct type 2022-05-06 16:43:09 -04:00
pierwill f1f0734718 Fix inaccurate function name in rustc_const_eval docs 2022-05-06 14:52:42 -05:00
Jakob Degen 5289bbece3 Expand validator to be more precise on checked binary ops 2022-05-06 15:40:32 -04:00
Matthias Krüger 68048199c9 Rollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obk
interpret/validity: debug-check ScalarPair layout information

This would have caught https://github.com/rust-lang/rust/issues/96158.
I ran the Miri test suite and it still passes.

r? `@oli-obk`
2022-05-05 15:43:07 +02:00
Ralf Jung e47d6c7a6b give it a scary name 2022-05-05 09:55:38 +02:00
Ralf Jung 5b20da8180 interpret: debug-check ScalarPair layout information 2022-05-04 22:52:02 +02:00
Josh Triplett 0fc5c524f5 Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
Vadim Petrochenkov 5b5964f569 rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03:00
bors 9a98c63b30 Auto merge of #96500 - SparrowLii:rpo, r=tmiasko
Reduce duplication of RPO calculation of mir

Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow.
This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
2022-04-30 05:06:47 +00:00
SparrowLii 7149bbcdc5 Eliminate duplication of RPO calculation for mir
add `postorder_cache` to mir Body

add `ReversePostorderCache` struct

correct struct name and comments
2022-04-30 03:42:57 +08:00
bors b2c2a32870 Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obk
Implement Valtree to ConstValue conversion

Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction.

r? `@oli-obk`

cc `@RalfJung`
2022-04-28 13:18:22 +00:00
b-naber ef5f07256c combine all unsized types and add another recursive call to process nested unsized types correctly 2022-04-27 16:58:16 +02:00
b-naber bfefb4d74c account for custom DSTs in valtree -> constvalue conversion 2022-04-26 18:40:15 +02:00
b-naber f7eae4e580 include valtree creation and valtree -> constvalue conversion in debug assertions check 2022-04-24 10:59:21 +02:00
Jakob Degen ae7d6facda Relax restrictions for copy operands 2022-04-22 16:45:15 -04:00
b-naber bc698c73e9 deduplicate a lot of code 2022-04-21 23:11:06 +02:00
b-naber 28af967bb9 implement (as of now still unused) query for valtree -> constvalue conversion 2022-04-21 16:37:24 +02:00
b-naber 1157dc7167 implement valtree -> constvalue conversion 2022-04-21 15:53:26 +02: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