about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
AgeCommit message (Collapse)AuthorLines
2024-10-31coverage: Make `CoverageSuccessors` a structZalathar-44/+27
2024-10-31Mark `simplify_aggregate_to_copy` mir-opt as unsound许杰友 Jieyou Xu (Joe)-1/+3
Co-authored-by: DianQK <dianqk@dianqk.net>
2024-10-31Reduce some visibilities.Nicholas Nethercote-3/+3
2024-10-31Remove `ValueAnalysis` and `ValueAnalysisWrapper`.Nicholas Nethercote-59/+274
They represent a lot of abstraction and indirection, but they're only used for `ConstAnalysis`, and apparently won't be used for any other analyses in the future. This commit inlines and removes them, which makes `ConstAnalysis` easier to read and understand.
2024-10-30Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errorsJubilee-19/+22
Rename `rustc_abi::Abi` to `BackendRepr` Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights. Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2024-10-30Rollup merge of #132338 - nnethercote:rm-Engine, r=nnethercoteMatthias Krüger-32/+14
Remove `Engine` It's just unnecessary plumbing. Removing it results in less code, and simpler code. r? ``@cjgillot``
2024-10-30Remove `Analysis::into_engine`.Nicholas Nethercote-32/+14
This is a standard pattern: ``` MyAnalysis.into_engine(tcx, body).iterate_to_fixpoint() ``` `into_engine` and `iterate_to_fixpoint` are always called in pairs, but sometimes with a builder-style `pass_name` call between them. But a builder-style interface is overkill here. This has been bugging me a for a while. This commit: - Merges `Engine::new` and `Engine::iterate_to_fixpoint`. This removes the need for `Engine` to have fields, leaving it as a trivial type that the next commit will remove. - Renames `Analysis::into_engine` as `Analysis::iterate_to_fixpoint`, gives it an extra argument for the optional pass name, and makes it call `Engine::iterate_to_fixpoint` instead of `Engine::new`. This turns the pattern from above into this: ``` MyAnalysis.iterate_to_fixpoint(tcx, body, None) ``` which is shorter at every call site, and there's less plumbing required to support it.
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-19/+22
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
2024-10-29TypingMode :thinking:lcnr-4/+8
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-2/+3
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-27Auto merge of #132091 - Zalathar:graph-loops, r=saethlinbors-63/+85
coverage: Don't rely on the custom traversal to find enclosing loops This opens up the possibility of modifying or removing the custom graph traversal used in coverage counter creation, without losing access to the heuristics that care about a node's enclosing loops. Actually changing the traversal is left for future work, because this PR on its own doesn't change the emitted coverage mappings at all.
2024-10-26Rollup merge of #132168 - fee1-dead-contrib:fxclean, r=compiler-errorsMatthias Krüger-6/+1
Effects cleanup - removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers r? compiler-errors
2024-10-26Effects cleanupDeadbeef-6/+1
- removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-10-26coverage: Don't rely on the custom traversal to find enclosing loopsZalathar-63/+85
2024-10-25tcx.is_const_fn doesn't work the way it is described, remove itRalf Jung-1/+1
Then we can rename the _raw functions to drop their suffix, and instead explicitly use is_stable_const_fn for the few cases where that is really what you want.
2024-10-23fix a couple clippy:complexitysMatthias Krüger-2/+2
double_parens filter_map_identity needless_question_mark redundant_guards
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-2/+2
2024-10-22Rollup merge of #132022 - Zalathar:dominator-order, r=tmiaskoMatthias Krüger-2/+23
Move `cmp_in_dominator_order` out of graph dominator computation Dominator-order information is only needed for coverage graphs, and is easy enough to collect by just traversing the graph again. This avoids wasted work when computing graph dominators for any other purpose.
2024-10-22Move `cmp_in_dominator_order` out of graph dominator computationZalathar-2/+23
Dominator-order information is only needed for coverage graphs, and is easy enough to collect by just traversing the graph again. This avoids wasted work when computing graph dominators for any other purpose.
2024-10-22Rollup merge of #131918 - Zalathar:counters, r=nnethercoteMatthias Krüger-117/+107
coverage: Make counter creation handle node/edge counters more uniformly Similar to #130380, this is another round of small improvements informed by my ongoing attempts to overhaul coverage counter creation. One of the big benefits is getting rid of the awkward special-case that would sometimes attach an edge counter to a node instead. That was needed by the code that chooses which out-edge should be given a counter expression, but we can avoid that by making the corresponding check a little smarter. I've also renamed several things to be simpler and more consistent, which should help with future changes.
2024-10-21Auto merge of #130950 - compiler-errors:yeet-eval, r=BoxyUwUbors-8/+7
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of https://github.com/rust-lang/rust/issues/130704
2024-10-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-8/+7
2024-10-19coverage: Streamline several names of things in counter creationZalathar-85/+69
2024-10-19coverage: Make counter creation handle nodes/edges more uniformlyZalathar-48/+54
2024-10-19interpret errors: add map_err_kind, rename InterpError -> InterpErrorKindRalf Jung-1/+1
2024-10-18Rollup merge of #131802 - compiler-errors:fnonce-coverage, r=Zalathar许杰友 Jieyou Xu (Joe)-0/+6
Dont ICE when computing coverage of synthetic async closure body I'm not totally certain if this is *right*, but at least it doesn't ICE. The issue is that we end up generating two MIR bodies for each async closure, since the `FnOnce` and `Fn`/`FnMut` implementations have different borrowing behavior of their captured variables. They should ideally both contribute to the coverage, since those MIR bodies are (*to the user*) the same code and should have no behavioral differences. This PR at least suppresses the ICEs, and then I guess worst case we can fix this the right way later. r? Zalathar or re-roll Fixes #131190
2024-10-18Dont ICE when computing coverage of synthetic async closure bodyMichael Goulet-0/+6
2024-10-17Auto merge of #129582 - nbdd0121:unwind, r=nnethercotebors-6/+19
Make destructors on `extern "C"` frames to be executed This would make the example in #123231 print "Noisy Drop". I didn't mark this as fixing the issue because the behaviour is yet to be spec'ed. Tracking: - https://github.com/rust-lang/rust/issues/74990
2024-10-16Rollup merge of #130989 - compiler-errors:unsize-opaque, r=estebankMatthias Krüger-0/+11
Don't check unsize goal in MIR validation when opaques remain Similarly to `mir_assign_valid_types`, let's just skip when there are opaques. Fixes #130921.
2024-10-15Don't check unsize goal in MIR validation when opaques remainMichael Goulet-0/+11
2024-10-14Remove `ResultsCursor::contains`.Nicholas Nethercote-2/+2
It's hardly worth it, and it needs to be removed so that `GenKillAnalysis` can be removed.
2024-10-08coverage. Warn about too many test vectorszhuyunxing-1/+17
2024-10-08coverage. Adapt to mcdc mapping formats introduced by llvm 19zhuyunxing-115/+274
2024-10-07Rollup merge of #131325 - Zalathar:tweak-counters, r=jieyouxuStuart Cook-25/+28
coverage: Multiple small tweaks to counter creation I've been experimenting with some larger changes to how coverage counters are assigned to parts of the control-flow graph, and while none of that is ready yet, along the way I've repeatedly found myself wanting these smaller tweaks as a base. There are no changes to compiler output.
2024-10-07Auto merge of #131068 - RalfJung:immediate-offset-sanity-check, r=nnethercotebors-7/+23
Don't use Immediate::offset to transmute pointers to integers This applies the relatively new `assert_matches_abi` check in the `offset` operation on immediates, which makes sure that if offsets are used to alter the layout (which is possible because the field layout is arbitrarily picked by the caller), this is not done in a way that breaks the invariant of the `Immediate` type. This leads to ICEs in a GVN mir-opt test, so the second commit fixes GVN. Fixes https://github.com/rust-lang/rust/issues/131064.
2024-10-06coverage: Store `bcb_needs_counter` in a field as a bitsetZalathar-8/+14
This makes it possible for other parts of counter-assignment to check whether a node is guaranteed to end up with some kind of counter. Switching from `impl Fn` to a concrete `&BitSet` just avoids the hassle of trying to store a closure in a struct field, and currently there's no foreseeable need for this information to not be a bitset.
2024-10-06coverage: Have MakeBcbCounters own its CoverageCountersZalathar-13/+14
2024-10-06coverage: Make `BcbCounter` module-privateZalathar-10/+6
2024-10-06Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebankbors-0/+91
Add a Lint for Pointer to Integer Transmutes in Consts Fixes #87525 This PR adds a MirLint for pointer to integer transmutes in const functions and associated consts. The implementation closely follows this comment: https://github.com/rust-lang/rust/pull/85769#issuecomment-880969112. More details about the implementation can be found in the comments. Note: This could break some sound code as mentioned by RalfJung in https://github.com/rust-lang/rust/pull/85769#issuecomment-886491680: > ... technically const-code could transmute/cast an int to a ptr and then transmute it back and that would be correct -- so the lint will deny some sound code. Does not seem terribly likely though. References: 1. https://doc.rust-lang.org/std/mem/fn.transmute.html 2. https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
2024-10-05fix GVN trying to transmute pointers to integersRalf Jung-7/+23
2024-10-05Add a Lint for Pointer to Integer Transmutes in ConstsVeera-0/+91
2024-10-05Compute array length from type for unconditional panic.Camille GILLOT-7/+9
2024-10-04Rollup merge of #131202 - Urgau:wide-ptrs-compiler, r=jieyouxuGuillaume Gomez-3/+3
Use wide pointers consistenly across the compiler This PR replace every use of "fat pointer" for the more recent "wide pointer" terminology. Since some time T-lang as preferred the "wide pointer" terminology, as can be seen on [the last RFCs](https://github.com/search?q=repo%3Arust-lang%2Frfcs+%22wide+pointer%22&type=code), on some [lints](https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#ambiguous-wide-pointer-comparisons), but also in [the reference](https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html?highlight=wide%20pointer#pointer-to-pointer-cast). Currently we have a [mix of both](https://github.com/search?q=repo%3Arust-lang%2Frust+%22wide+pointer%22&type=code) (including in error messages), which isn't great, but with this PR no more. r? `@jieyouxu` (feel free to re-roll)
2024-10-04Use wide pointers consistenly across the compilerUrgau-3/+3
2024-10-04Auto merge of #131201 - compiler-errors:unop-not, r=cjgillotbors-0/+8
Disable jump threading `UnOp::Not` for non-bool Fix #131195, where jumpthreading was optimizing `!a == b` into `a != b` for non-bool, where this is definitely not true.
2024-10-03Disable jump threading UnOp::Not for non-boolMichael Goulet-0/+8
2024-10-03Avoid ICE in coverage builds with bad `#[coverage(..)]` attributesZalathar-1/+2
This code can sometimes witness malformed coverage attributes in builds that are going to fail, so use `span_delayed_bug` to avoid an inappropriate ICE in that case.
2024-10-01make InterpResult a dedicated type to avoid accidentally discarding the errorRalf Jung-152/+127
2024-09-30panic when an interpreter error gets unintentionally discardedRalf Jung-111/+153
2024-09-29Rollup merge of #130990 - RalfJung:mir-const-normalize, r=compiler-errorsMatthias Krüger-3/+1
try to get rid of mir::Const::normalize It was easy to make this compile, let's see if anything breaks... r? `@compiler-errors`