about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2023-09-29Remove deleted docs + better link together MIR traversing docsMaybe Waffle-2/+37
2023-09-28Use `and_then` instead of while let chain to clarify `iter` scopeMaybe Waffle-1/+1
2023-09-28Remove unnecessary `&mut/ref mut` pairMaybe Waffle-1/+1
2023-09-28Don't resolve basic block data in `Postorder`Maybe Waffle-7/+6
The only usage immediately throws out the data, so.
2023-09-28`(&mut iter)` -> `iter.by_ref()`Maybe Waffle-1/+1
2023-09-28Simplify `Postorder::next`Maybe Waffle-6/+4
2023-09-28Remove `ReversePostorder` altogetherMaybe Waffle-58/+0
It was not used anywhere, instead we directly reverse postorder.
2023-09-28Remove outdated commentMaybe Waffle-2/+1
There is no `reset` anymore
2023-09-28Add a mir validation check to prevent OpaqueCast after analysis passes finishOli Scherer-0/+1
2023-09-28Rollup merge of #116211 - matthiaskrgr:clippy3, r=compiler-errorsMatthias Krüger-2/+2
more clippy complextity fixes redundant_guards, useless_format, clone_on_copy
2023-09-27fix clippy::{redundant_guards, useless_format}Matthias Krüger-2/+2
2023-09-27Auto merge of #109597 - cjgillot:gvn, r=oli-obkbors-1/+1
Implement a global value numbering MIR optimization The aim of this pass is to avoid repeated computations by reusing past assignments. It is based on an analysis of SSA locals, in order to perform a restricted form of common subexpression elimination. By opportunity, this pass allows for some simplifications by combining assignments. For instance, this pass could be able to see through projections of aggregates to directly reuse the aggregate field (not in this PR). We handle references by assigning a different "provenance" index to each `Ref`/`AddressOf` rvalue. This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we consider all the derefs of an immutable reference to a freeze type to give the same value: ```rust _a = *_b // _b is &Freeze _c = *_b // replaced by _c = _a ```
2023-09-24Remove span from BrAnon.Camille GILLOT-2/+1
2023-09-24Add global value numbering pass.Camille GILLOT-1/+1
2023-09-23Auto merge of #116052 - oli-obk:ceci_nest_pas_une_query, r=WaffleLapkinbors-1/+1
Add a way to decouple the implementation and the declaration of a TyCtxt method. properly addresses https://github.com/rust-lang/rust/pull/115819 accepted MCP: https://github.com/rust-lang/compiler-team/issues/395
2023-09-22Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obkbors-3/+3
adjust how closure/generator types are printed I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-1/+1
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-3/+3
2023-09-21Auto merge of #114399 - Zalathar:no-renumber, r=jackh726bors-10/+0
coverage: Don't bother renumbering expressions on the Rust side The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest. This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways. --- Now that we have tests for coverage mappings (#114843), I've been able to verify that this PR doesn't make the coverage mappings worse, thanks to an explicit simplification step.
2023-09-21Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obkGuillaume Gomez-134/+124
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-21coverage: Don't bother renumbering expressions on the Rust sideZalathar-10/+0
The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest. This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways.
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-123/+118
2023-09-20Auto merge of #115870 - RalfJung:const-value-slice, r=oli-obkbors-9/+18
adjust ConstValue::Slice to work for arbitrary slice types valtrees have already been assuming that this works; this PR makes it a reality. Also further restrict `ConstValue::Slice` to what it is actually used for; this even shrinks `ConstValue` from 32 to 24 bytes which is a nice win. :) The alternative to this approach is to make `ConstValue::Slice` work really only for `&str`/`&[u8]` literals, and never return it in `op_to_const`. That would make `op_to_const` very clean. We could then even remove the `meta` field; the length would always be `data.inner().len()`. We could *almost* just use a `Symbol` instead of a `ConstAllocation`, but we have to support byte strings and there doesn't seem to be an interned representation of them (or rather, `ConstAllocation` *is* their interned representation). In this world, valtrees of slice reference types would then become noticeably more expensive to turn into a `ConstValue` -- but does that matter? Specifically for `&str`/`&[u8]` we could still use the optimized representation if we wanted. If byte strings were already interned somewhere I'd gravitate towards the alternative, but the way things stand, we need a `ConstAllocation` case anyway to support byte strings, and then we might as well support arbitrary slices. (Or we say that byte strings don't get an optimized representation at all. Such a performance cliff between `str` and byte strings is probably unexpected, though due to the lack of interning for byte strings I think there might already be a performance cliff there.)
2023-09-20Auto merge of #115827 - eduardosm:miri-sse-reduce-code-dup, r=RalfJungbors-4/+18
miri: reduce code duplication in some SSE/SSE2 intrinsics Reduces code duplication in the Miri implementation of some SSE and SSE2 using generics and rustc_const_eval helper functions. There are also some other minor changes. r? `@RalfJung`
2023-09-20the Const::eval_bits methods don't need to be given the TyRalf Jung-11/+6
2023-09-19adjust constValue::Slice to work for arbitrary slice typesRalf Jung-9/+18
2023-09-19comment on the difference between mir::ConstantKind::Unevaluated and ↵Ralf Jung-0/+5
mir::ConstantKind::Ty(ty::ConstKind::Unevaluated)
2023-09-19move ConstValue into mirRalf Jung-169/+169
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-19organize mir pretty.rs and move more things into it; move statement-related ↵Ralf Jung-1371/+1393
things out of mir/mod.rs
2023-09-19use pretty_print_const_value from MIR constant 'extra' printingRalf Jung-127/+133
2023-09-19move some MIR const pretty-printing into pretty.rsRalf Jung-177/+161
2023-09-19more MIR const types to separate fileRalf Jung-409/+422
2023-09-18Auto merge of #115748 - RalfJung:post-mono, r=oli-obkbors-19/+93
move required_consts check to general post-mono-check function This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants. Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized. I didn't expect this to change diagnostics, but it's just cycle errors that change. r? `@oli-obk`
2023-09-18Remove more unused `Lift` impls.Nicholas Nethercote-4/+4
2023-09-18Remove unused `Lift` derives.Nicholas Nethercote-4/+4
I found these by commenting out all `Lift` derives and then adding back the ones that were necessary to successfully compile.
2023-09-16miri: reduce code duplication in SSE/SSE2 bin_op_* functionsEduardo Sánchez Muñoz-4/+8
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-17/+41
also share the code that emits the actual error
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-10/+60
2023-09-14Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obkbors-17/+17
consistently pass ty::Const through valtrees Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obkbors-3/+5
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-14fix clippy (and MIR printing) handling of ConstValue::Indirect slicesRalf Jung-26/+62
2023-09-14don't force all slice-typed ConstValue to be ConstValue::SliceRalf Jung-18/+7
2023-09-14treat host effect params as erased generics in codegenDeadbeef-3/+5
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-14found another place where we can eval() a const, and go through valtreesRalf Jung-1/+5
2023-09-14always evaluate ConstantKind::Ty through valtreesRalf Jung-16/+12
2023-09-14make it more clear which functions create fresh AllocIdRalf Jung-7/+8
2023-09-14cleanup op_to_const a bit; rename ConstValue::ByRef → IndirectRalf Jung-9/+15
2023-09-14use AllocId instead of Allocation in ConstValue::ByRefRalf Jung-11/+16
2023-09-13rustc_middle: add `Scalar::from_i8` and `Scalar::from_i16` and use them in MiriEduardo Sánchez Muñoz-0/+10
2023-09-13Rollup merge of #115736 - Zoxc:time-cleanup, r=wesleywiserMatthias Krüger-0/+37
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.