Commit Graph

1233 Commits

Author SHA1 Message Date
bors
5ae769f06b Auto merge of #116144 - lcnr:subst-less, r=oli-obk
subst -> instantiate

continues #110793, there are still quite a few uses of `subst` and `substitute`, but changing them all in the same PR was a bit too much, so I've stopped here for now.
2023-09-26 21:32:44 +00:00
lcnr
3c52a3e280 subst -> instantiate 2023-09-26 09:37:55 +02:00
Camille GILLOT
1092849967 Use Vec::retain in remove_dead_blocks. 2023-09-25 17:08:40 +00:00
Camille GILLOT
286502c9ed Enable drop_tracking_mir by default. 2023-09-23 13:34:09 +00:00
Camille GILLOT
9450b75986 Do not construct def_path_str for MustNotSuspend. 2023-09-23 13:14:57 +00:00
bors
0fd7ce99b0 Auto merge of #116010 - RalfJung:more-typed-immediates, r=oli-obk
interpret: more consistently use ImmTy in operators and casts

The diff in src/tools/miri/src/shims/x86/sse2.rs should hopefully suffice to explain why this is nicer. :)
2023-09-21 14:02:55 +00:00
Guillaume Gomez
208f6ed95c
Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const

Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.

Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.

However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...

``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
Oli Scherer
9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Ralf Jung
c94410c145 rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
Ralf Jung
0eff07b748 try to avoid some layout_of calls 2023-09-21 07:26:16 +02:00
Ralf Jung
da08a3f40c interpret: more consistently use ImmTy in operators and casts 2023-09-20 21:57:54 +02:00
Zalathar
e015f5a370 coverage: Remove vestigial counter/expression debug labels 2023-09-20 17:24:10 +10:00
Zalathar
bbd347409f coverage: Remove vestigial format_counter methods 2023-09-20 17:24:10 +10:00
Zalathar
3d66513fe4 coverage: Remove debug code from the instrumentor 2023-09-20 17:24:10 +10:00
Ralf Jung
a2374e65aa the Const::eval_bits methods don't need to be given the Ty 2023-09-20 07:27:21 +02:00
Ralf Jung
5a0a1ff0cd move ConstValue into mir
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-19 11:11:02 +02:00
Matthias Krüger
3cf5a6beaa
Rollup merge of #115930 - Zalathar:spans-bug, r=compiler-errors
coverage: Fix an unstable-sort inconsistency in coverage spans

This code was calling `sort_unstable_by`, but failed to impose a total order on the initial spans. That resulted in unpredictable handling of closure spans, producing inconsistencies in the coverage maps and in user-visible coverage reports.

This PR fixes the problem by always sorting closure spans before otherwise-identical non-closure spans, and also switches to a stable sort in case the ordering is still not total.

---

In addition to the fix itself, this PR also contains a cleanup to the comparison function that I was working on when I discovered the bug.
2023-09-19 01:29:42 +02:00
Zalathar
01b67f4b26 coverage: Simplify sorting of coverage spans extracted from MIR
Switching to `Ordering::then_with` makes control-flow less complicated, and
there is no need to use `partial_cmp` here.
2023-09-18 23:15:25 +10:00
Zalathar
4690f97099 coverage: Fix an unstable-sort inconsistency in coverage spans
This code was calling `sort_unstable_by`, but failed to impose a total order on
the initial spans. That resulted in unpredictable handling of closure spans,
producing inconsistencies in the coverage maps and in user-visible coverage
reports.

This patch fixes the problem by always sorting closure spans before
otherwise-identical non-closure spans, and also switches to a stable sort in
case the ordering is still not total.
2023-09-18 21:28:56 +10:00
Matthias Krüger
c101c5fa50
Rollup merge of #115908 - cjgillot:lint-noclone, r=oli-obk
Do not clone MIR for const-prop lint.

Addresses https://github.com/rust-lang/rust/pull/115797#issuecomment-1721250533
2023-09-18 13:02:20 +02:00
Camille GILLOT
5d18a0edb4 Do not clone MIR for const-prop lint. 2023-09-17 09:00:51 +00:00
Zalathar
91e0b46f76 coverage: Replace an unnecessary map with a set
This hashmap's values were never used.
2023-09-16 12:07:35 +10:00
Zalathar
3b5b1aa2a5 coverage: Simplify internal representation of debug types 2023-09-16 12:07:35 +10:00
Zalathar
d0d1187ebb coverage: Update log module names in debug docs 2023-09-16 12:07:35 +10:00
Zalathar
d79cd17199 coverage: Arrange imports in rustc_mir_transform::coverage::debug 2023-09-16 12:07:35 +10:00
bors
5e71913156 Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obk
treat host effect params as erased in codegen

This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.

r? `@oli-obk`
2023-09-14 13:42:30 +00:00
Deadbeef
a0a801cd38 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Ralf Jung
430c386821 make it more clear which functions create fresh AllocId 2023-09-14 07:27:31 +02:00
Ralf Jung
0f8908da27 cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect 2023-09-14 07:27:30 +02:00
Ralf Jung
551f481ffb use AllocId instead of Allocation in ConstValue::ByRef 2023-09-14 07:26:24 +02:00
bors
eb2446a57e Auto merge of #115820 - matthiaskrgr:rollup-kyglvpu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #115736 (Remove `verbose_generic_activity_with_arg`)
 - #115771 (cleanup leftovers of const_err lint)
 - #115798 (add helper method for finding the one non-1-ZST field)
 - #115812 (Merge settings.css into rustdoc.css)
 - #115815 (fix: return early when has tainted in mir pass)
 - #115816 (Disabled socketpair for Vita)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-13 18:19:15 +00:00
Matthias Krüger
48d89a8759
Rollup merge of #115815 - bvanjoi:fix-115809, r=oli-obk
fix: return early when has tainted in mir pass

Fixes https://github.com/rust-lang/rust/issues/115809

As in #115643, `run_pass` is skipped if the body has tainted errors.

r? `@oli-obk`
2023-09-13 18:37:43 +02:00
Matthias Krüger
5dc37c1966
Rollup merge of #115736 - Zoxc:time-cleanup, r=wesleywiser
Remove `verbose_generic_activity_with_arg`

This removes `verbose_generic_activity_with_arg` and changes users to `generic_activity_with_arg`. This keeps the output of `-Z time` readable while these repeated events are still available with the self profiling mechanism.
2023-09-13 18:37:41 +02:00
bors
5adddad28c Auto merge of #115797 - cjgillot:const-prop-noclone, r=oli-obk
Do not clone the Body for ConstProp

~Based on https://github.com/rust-lang/rust/pull/115748 for the `POST_MONO_CHECKS` flag.~
2023-09-13 16:30:07 +00:00
bohan
7c53e87d55 fix: skip opt if body has tainted error 2023-09-13 23:07:39 +08:00
John Kåre Alsaker
9624c30965 Generate MIR pass names for profiling on the fly and pass the body DefId as argument 2023-09-13 13:41:19 +02:00
Ralf Jung
11a4a24d8e make the set of methods between our two Const types more consistent 2023-09-13 07:29:34 +02:00
Ralf Jung
6e4779ab17 make the eval() functions on our const types return the resulting value 2023-09-13 07:29:34 +02:00
Camille GILLOT
d0cba3df97 Do not fetch type to check generator. 2023-09-12 20:17:55 +00:00
Camille GILLOT
108decec53 Do not clone body for ConstProp. 2023-09-12 20:17:55 +00:00
Camille GILLOT
32fe00ae85 Reuse CollectAndPatch for normal ConstProp. 2023-09-12 20:17:55 +00:00
Camille GILLOT
8a3a0dd64e Store a ConstantKind in CollectAndPatch. 2023-09-12 20:17:55 +00:00
Camille GILLOT
054ed8e7eb Introduce Machine::POST_MONO_CHECKS. 2023-09-12 20:17:52 +00:00
Camille GILLOT
bcfe1a4bf2 Remove cur_span hook. 2023-09-11 16:29:42 +00:00
Camille GILLOT
24adf07e5f Reuse throw_machine_stop_str! macro. 2023-09-11 16:29:41 +00:00
Camille GILLOT
d278ce126c Return ImmTy in discriminant_for_variant. 2023-09-11 16:29:41 +00:00
Camille GILLOT
1d6a32c920 Interpret Immediate::Uninit as Bottom. 2023-09-11 16:29:41 +00:00
Camille GILLOT
b851e554dd Support CopyForDeref. 2023-09-11 16:29:41 +00:00
Camille GILLOT
82f0468009 Handle reading statics. 2023-09-11 16:29:41 +00:00
Camille GILLOT
6ad6b4381c Support non-scalar constants. 2023-09-11 16:29:41 +00:00