about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src
AgeCommit message (Collapse)AuthorLines
2024-04-20Add a non-shallow fake borrowNadrieril-1/+1
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+2
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-5/+5
It is commonly used.
2024-03-23refactor check_{lang,library}_ub: use a single intrinsic, put policy into ↵Ralf Jung-1/+1
library
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-2/+2
2024-03-22Eagerly convert some ctors to use their specialized ctorsMichael Goulet-7/+2
2024-03-20step cfgsMark Rousskov-1/+0
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-1/+1
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-9/+16
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-04Return a struct from `query intrinsic` to be able to add another field in ↵Oli Scherer-1/+1
the next commit
2024-02-24Implement asm goto in MIR and MIR loweringGary Guo-2/+4
2024-02-24Change InlineAsm to allow multiple targets insteadGary Guo-7/+12
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-2/+1
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-13Rollup merge of #120802 - oli-obk:drop_elab_ice, r=compiler-errorsMatthias Krüger-1/+4
Bail out of drop elaboration when encountering error types fixes #120788
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-2/+1
2024-02-10Remove unnecessary `min_specialization` after bootstrapZalathar-1/+1
These crates all needed specialization for `newtype_index!`, which will no longer be necessary when the current nightly eventually becomes the next bootstrap compiler.
2024-02-09Auto merge of #120843 - matthiaskrgr:rollup-med37z5, r=matthiaskrgrbors-2/+0
Rollup of 8 pull requests Successful merges: - #113671 (Make privacy visitor use types more (instead of HIR)) - #120308 (core/time: avoid divisions in Duration::new) - #120693 (Invert diagnostic lints.) - #120704 (A drive-by rewrite of `give_region_a_name()`) - #120809 (Use `transmute_unchecked` in `NonZero::new`.) - #120817 (Fix more `ty::Error` ICEs in MIR passes) - #120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - #120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-08Bail out of drop elaboration when encountering error typesOli Scherer-1/+4
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-1/+4
And in clippy
2024-02-06More comments, final tweaksMichael Goulet-0/+3
2024-02-06Teach typeck/borrowck/solvers how to deal with async closuresMichael Goulet-0/+3
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-2/+9
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-01-25Remove unused featuresclubby789-3/+1
2024-01-22Use a plain bitset for liveness analyses.Camille GILLOT-10/+17
2024-01-20Add a warning commentGeorgiy Komarov-0/+2
2024-01-20rustc_mir_dataflow: Add exports for external toolsGeorgiy Komarov-3/+3
Added back previously available exports: * Forward/Backward: used when implementing `AnalysisDomain` * Engine: used in user's code to solve the dataflow problem * SwitchIntEdgeEffects: used when implementing functions of the `Analysis` trait * graphviz: potentially useful for debugging purposes These exports are used when implementing external tools based on MIR dataflow framework. Closes #120130
2024-01-17Rollup merge of #115291 - cjgillot:dest-prop-save, r=JakobDegenMatthias Krüger-0/+157
Save liveness results for DestinationPropagation `DestinationPropagation` needs to verify that merge candidates do not conflict with each other. This is done by verifying that a local is not live when its counterpart is written to. To get the liveness information, the pass runs `MaybeLiveLocals` dataflow analysis repeatedly, once for each propagation round. This is quite costly, and the main driver for the perf impact on `ucd` and `diesel`. (See https://github.com/rust-lang/rust/pull/115105#issuecomment-1689205908) In order to mitigate this cost, this PR proposes to save the result of the analysis into a `SparseIntervalMatrix`, and mirror merges of locals into that matrix: `liveness(destination) := liveness(destination) union liveness(source)`. <details> <summary>Proof</summary> We denote by `'` all the quantities of the transformed program. Let $\varphi$ be a mapping of locals, which maps `source` to `destination`, and is identity otherwise. The exact liveness set after a statement is $out'(statement)$, and the proposed liveness set is $\varphi(out(statement))$. Consider a statement. Suppose that the output state verifies $out' \subset phi(out)$. We want to prove that $in' \subset \varphi(in)$ where $in = (out - kill) \cup gen$, and conclude by induction. We have 2 cases: either that statement is kept with locals renumbered by $\varphi$, or it is a tautological assignment and it removed. 1. If the statement is kept: the gen-set and the kill-set of $statement' = \varphi(statement)$ are $gen' = \varphi(gen)$ and $kill' = \varphi(kill)$ exactly. From soundness requirement 3, $\varphi(in)$ is disjoint from $\varphi(kill)$. This implies that $\varphi(out - kill)$ is disjoint from $\varphi(kill)$, and so $\varphi(out - kill) = \varphi(out) - \varphi(kill)$. Then $\varphi(in) = (\varphi(out) - \varphi(kill)) \cup \varphi(gen) = (\varphi(out) - kill') \cup gen'$. We can conclude that $out' \subset \varphi(out) \implies in' \subset \varphi(in)$. 2. If the statement is removed. As $\varphi(statement)$ is a tautological assignment, we know that $\varphi(gen) = \varphi(kill) = \\{ destination \\}$, while $gen' = kill' = \emptyset$. So $\varphi(in) = \varphi(out) \cup \\{ destination \\}$. Then $in' = out' \subset out \subset \varphi(in)$. By recursion, we can conclude by that $in' \subset \varphi(in)$ everywhere. </details> This approximate liveness results is only suboptimal if there are locals that fully disappear from the CFG due to an assignment cycle. These cases are quite unlikely, so we do not bother with them. This change allows to reduce the perf impact of DestinationPropagation by half on diesel and ucd (https://github.com/rust-lang/rust/pull/115105#issuecomment-1694701904). cc ````@JakobDegen````
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-3/+8
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-07Use for_each instead of fold.Camille GILLOT-2/+2
2024-01-07Fix comment.Camille GILLOT-3/+1
2024-01-07Do not recompute liveness for DestinationPropagation.Camille GILLOT-1/+65
2024-01-07Move PointIndex to mir_dataflow.Camille GILLOT-0/+95
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-3/+3
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-12/+14
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-21Don't require owned data in `MaybeStorageDead`Tomasz Miąsko-6/+6
2023-12-15NFC don't convert types to identical typesMatthias Krüger-5/+1
2023-12-10remove redundant importssurechen-2/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-08Tweak `GenKillAnalysis`.Nicholas Nethercote-19/+22
`GenKillAnalysis` has five methods that take a transfer function arg: - `statement_effect` - `before_statement_effect` - `terminator_effect` - `before_terminator_effect` - `call_return_effect` All the transfer function args have type `&mut impl GenKill<Self::Idx>`, except for `terminator_effect`, which takes the simpler `Self::Domain`. But only the first two need to be `impl GenKill`. The other three can all be `Self::Domain`, just like `Analysis`. So this commit changes the last two to take `Self::Domain`, making `GenKillAnalysis` and `Analysis` more similar. (Another idea would be to make all these methods `impl GenKill`. But that doesn't work: `MaybeInitializedPlaces::terminator_effect` requires the arg be `Self::Domain` so that `self_is_unwind_dead(place, state)` can be called on it.)
2023-12-08Remove `impl_visitable!`.Nicholas Nethercote-2/+2
It is used just once. With it removed, the relevant code is a little boilerplate-y but much easier to read, and is the same length. Overall I think it's an improvement.
2023-12-08Remove unused arguments from `ResultsVisitor::visit_block_{start,end}`.Nicholas Nethercote-34/+8
2023-11-27Deparameterize `Results` and `ResultsCursor`.Nicholas Nethercote-72/+27
They both now only ever contain a `Results<'tcx, A>`. This means `AnalysisResults` can be removed, as can many `borrow`/`borrow_mut` calls. Also `Results` no longer needs a `PhantomData` because `'tcx` is now named by `entry_sets`.
2023-11-27Remove `ResultsCloned` and `ResultsClonedCursor`.Nicholas Nethercote-26/+4
They're now unused.
2023-11-27Remove uses of `ResultsClonedCursor`.Nicholas Nethercote-14/+14
By just cloning the entire `Results` in the one place where `ResultsClonedCursor` was used. This is extra allocations but the performance effect is negligible.
2023-11-27Remove `ResultsRefCursor`.Nicholas Nethercote-29/+2
It's no longer used.
2023-11-27Remove another use of `as_results_cursor`.Nicholas Nethercote-40/+62
The new code is a little clunky, but I couldn't see how to make it better.
2023-11-27Remove `CloneAnalysis`.Nicholas Nethercote-29/+5
It's only implemented for analyses that implement `Copy`, which means it's basically a complicated synonym for `Copy`. So this commit removes it and uses `Copy` directly. (That direct use will be removed in a later commit.)
2023-11-27Remove some unused code relating to `ResultsCloned`.Nicholas Nethercote-39/+2
2023-11-27Use typedefs to clarify some impls.Nicholas Nethercote-2/+5
And insert some whitespace.