about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2023-11-27Print list of missing target features when calling a function with target ↵Eduardo Sánchez Muñoz-53/+101
features outside an unsafe block
2023-11-27Remove uses of `ResultsClonedCursor`.Nicholas Nethercote-3/+3
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 one use of `as_results_cursor`.Nicholas Nethercote-4/+4
It's currently used because `requires_storage_results` is used in two locations: once with a cursor, and once later on without a cursor. The non-consuming `as_results_cursor` is used for the first location. But we can instead use the consuming `into_results_cursor` and then use `into_results` to extract the `Results` from the finished-with cursor for use at the second location.
2023-11-26Rollup merge of #118311 - bvanjoi:merge_coroutinue_into_closure, r=petrochenkovGuillaume Gomez-4/+3
merge `DefKind::Coroutine` into `Defkind::Closure` Related to #118188 We no longer need to be concerned about the precise type whether it's `DefKind::Closure` or `DefKind::Coroutine`. Furthermore, thanks for the great work done by `@petrochenkov` on investigating https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Why.20does.20it.20hang.20when.20querying.20.EF.BB.BF.60opt_def_kind.60.3F r? `@petrochenkov`
2023-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-4/+3
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-2/+2
cleanup
2023-11-25Rollup merge of #118158 - nnethercote:reduce-fluent-boilerplate, ↵Michael Goulet-4/+1
r=compiler-errors Reduce fluent boilerplate Best reviewed one commit at a time. r? `@davidtwco`
2023-11-25Rollup merge of #117651 - Zalathar:fold-sums, r=cjgillotMichael Goulet-205/+170
coverage: Simplify building coverage expressions based on sums This is a combination of some interlinked changes to the code that creates coverage counters/expressions for nodes and edges in the coverage graph: - Some preparatory cleanups in `MakeBcbCounters::make_branch_counters` - Use `BcbCounter` (instead of `CovTerm`) when building coverage expressions - This makes it easier to introduce a fold for building sums - Simplify the creation of coverage expressions based on sums, by having `Iterator::fold` do much of the work - Get rid of the awkward `BcbBranch` enum, and replace it with graph edges represented as `(from_bcb, to_bcb)` - This further simplifies the body of the fold
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-3/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-25Auto merge of #118075 - tmiasko:validate-critical-call-edges, r=cjgillotbors-2/+3
Validate there are no critical call edges in optimized MIR
2023-11-25Auto merge of #118203 - nnethercote:rustc_mir_dataflow, r=cjgillotbors-45/+26
Minor `rustc_mir_dataflow` cleanups r? `@cjgillot`
2023-11-25coverage: Assert that bcb0 starts with bb0 and has no in-edgesZalathar-0/+13
This explains why we don't have to worry about bcb0 having multiple in-edges.
2023-11-25coverage: Eliminate `BcbBranch`Zalathar-104/+69
`BcbBranch` represented an out-edge of a coverage graph node, but would silently refer to a node instead in cases where that node only had one in-edge. Instead we now refer to a graph edge as a `(from_bcb, to_bcb)` pair, or sometimes as just one of those nodes when the other node is implied by the surrounding context. The case of sole in-edges is handled by special code added directly to `get_or_make_edge_counter_operand`.
2023-11-25coverage: Extract `CoverageGraph::bcb_has_multiple_in_edges`Zalathar-9/+16
This was previously a helper method in `MakeBcbCounters`, but putting it in the graph lets us call it from `BcbBranch`, and gives us a more fine-grained borrow.
2023-11-25coverage: Simplify building coverage expressions based on sumsZalathar-71/+54
In some cases we need to prepare a coverage expression that is the sum of an arbitrary number of other terms. This patch simplifies the code paths that build those sums. This causes some churn in the mappings, because the previous code was building its sums in a somewhat idiosyncratic order.
2023-11-25coverage: Use `BcbCounter` to build coverage expressionsZalathar-19/+16
This means that we no longer have to manage the distinction between `BcbCounter` and `CovTerm` when preparing expressions.
2023-11-25coverage: Push down creation of a visited node's counterZalathar-6/+7
Now that this code path unconditionally calls `make_branch_counters`, we might as well make that method responsible for creating the node's counter as well, since it needs the resulting term anyway.
2023-11-25coverage: Push down and inline `bcb_needs_branch_counters`Zalathar-9/+10
This lets us avoid creating two copies of the node's branch list.
2023-11-25coverage: Rename parameter `branching_bcb` to `from_bcb`Zalathar-9/+7
2023-11-23Fix fn_sig_for_fn_abi and the coroutine transform for generatorsbjorn3-1/+31
There were three issues previously: * The self argument was pinned, despite Iterator::next taking an unpinned mutable reference. * A resume argument was passed, despite Iterator::next not having one. * The return value was CoroutineState<Item, ()> rather than Option<Item> While these things just so happened to work with the LLVM backend, cg_clif does much stricter checks when trying to assign a value to a place. In addition it can't handle the mismatch between the amount of arguments specified by the FnAbi and the FnSig.
2023-11-24Remove unused arguments from `on_all_children_bits`.Nicholas Nethercote-34/+17
`on_all_children_bits` has two arguments that are unused: `tcx` and `body`. This was not detected by the compiler because it's a recursive function. This commit removes them, and removes lots of other arguments and fields that are no longer necessary.
2023-11-23Remove an unneeded local variable.Nicholas Nethercote-11/+9
`body` is already a `&Body`.
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22Split critical call edges just before code generationTomasz Miąsko-1/+1
2023-11-22Split critical call edges in coroutine drop shimTomasz Miąsko-1/+2
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-53/+45
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-20Auto merge of #117783 - tmiasko:inline-ret, r=cjgillotbors-134/+163
Fix insertion of statements to be executed along return edge in inlining Inlining creates additional statements to be executed along the return edge: an assignment to the destination, storage end for temporaries. Previously those statements where inserted directly into a call target, but this is incorrect when the target has other predecessors. Avoid the issue by creating a new dedicated block for those statements. When the block happens to be redundant it will be removed by CFG simplification that follows inlining. Fixes #117355
2023-11-20Fix insertion of statements to be executed along return edge in inliningTomasz Miąsko-14/+44
Inlining creates additional statements to be executed along the return edge: an assignment to the destination, storage end for temporaries. Previously those statements where inserted directly into a call target, but this is incorrect when the target has other predecessors. Avoid the issue by creating a new dedicated block for those statements. When the block happens to be redundant it will be removed by CFG simplification that follows inlining. Fixes #117355
2023-11-19Auto merge of #116828 - compiler-errors:nightlyify-rustc_type_ir, r=jackh726bors-1/+1
Begin to abstract `rustc_type_ir` for rust-analyzer This adds the "nightly" feature which is used by the compiler, and falls back to more simple implementations when that is not active. r? `@lcnr` or `@jackh726`
2023-11-19Use let else to reduce indentationTomasz Miąsko-124/+123
2023-11-18Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkovbors-32/+0
Remove option_payload_ptr; redundant to offset_of The `option_payload_ptr` intrinsic is no longer required as `offset_of` supports traversing enums (#114208). This PR removes it in order to dogfood offset_of (as suggested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790907626). However, it will not build until those changes reach beta (which I think is within the next 8 days?) so I've opened it as a draft.
2023-11-18Begin nightly-ifying rustc_type_irMichael Goulet-1/+1
2023-11-17rename bound region instantiationlcnr-4/+4
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-16Remove option_payload_ptr; redundant to offset_ofGeorge Bateman-32/+0
2023-11-15Re-format code with new rustfmtMark Rousskov-12/+28
2023-11-14Fix def-use check for call terminatorsTomasz Miąsko-22/+33
2023-11-14Auto merge of #117801 - tmiasko:remove-zsts-fuel, r=cjgillotbors-6/+5
Remove incorrect transformation from RemoveZsts Partial removal of storage statements for a local is incorrect, so a decision to optimize cannot be make independently for each statement. Avoid the issue by performing the transformation completely or not at all.
2023-11-12coverage: Avoid creating malformed macro name spansZalathar-0/+6
This method is trying to detect macro invocations, so that it can split a span into two parts just after the `!` of the invocation. Under some circumstances (probably involving nested macros), it gets confused and produces a span that is larger than the original span, and possibly extends outside its enclosing function and even into an adjacent file. In extreme cases, that can result in malformed coverage mappings that cause `llvm-cov` to fail. For now, we at least want to detect these egregious cases and avoid them, so that coverage reports can still be produced.
2023-11-11Remove incorrect transformation from RemoveZstsTomasz Miąsko-6/+5
Partial removal of storage statements for a local is incorrect, so a decision to optimize cannot be make independently for each statement. Avoid the issue by performing the transformation completely or not at all.
2023-11-09Auto merge of #117712 - lcnr:expand-coroutine, r=jackh726bors-9/+16
generator layout: ignore fake borrows fixes #117059 We emit fake shallow borrows in case the scrutinee place uses a `Deref` and there is a match guard. This is necessary to prevent the match guard from mutating the scrutinee: https://github.com/rust-lang/rust/blob/fab1054e1742790c22ccc92a625736d658363677/compiler/rustc_mir_build/src/build/matches/mod.rs#L1250-L1265 These fake borrows end up impacting the generator witness computation in `mir_generator_witnesses`, which causes the issue in #117059. This PR now completely ignores fake borrows during this computation. This is sound as thse are always removed after analysis and the actual computation of the generator layout happens afterwards. Only the second commit impacts behavior, and could be backported by itself. r? types
2023-11-08rename `BorrowKind::Shallow` to `Fake`lcnr-8/+15
also adds some comments
2023-11-08generator layout: ignore fake borrowslcnr-1/+1
2023-11-07Add -Zcross-crate-inline-threshold=yesBen Kimock-2/+8
2023-11-05Make the randomize feature of rustc_abi additivehkalbasi-2/+2
2023-11-04Auto merge of #113343 - saethlin:looser-alignment, r=RalfJungbors-51/+54
Update the alignment checks to match rust-lang/reference#1387 Previously, we had a special case to not check `Rvalue::AddressOf` in this pass because we weren't quite sure if pointers needed to be aligned in the Place passed to it: https://github.com/rust-lang/rust/pull/112026 Since https://github.com/rust-lang/reference/pull/1387 merged, this PR updates this pass to match. The behavior of the check is nearly unchanged, except we also avoid inserting a check for creating references. Most of the changes in this PR are cleanup and new tests.
2023-11-04Check alignment of pointers only when read/written throughBen Kimock-51/+54
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-6/+6
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-11-01Auto merge of #113970 - cjgillot:assume-all-the-things, r=nikicbors-146/+183
Replace switch to unreachable by assume statements `UnreachablePropagation` currently keeps some switch terminators alive in order to ensure codegen can infer the inequalities on the discriminants. This PR proposes to encode those inequalities as `Assume` statements. This allows to simplify MIR further by removing some useless terminators.
2023-10-31Update based on wesleywiser reviewGeorge Bateman-3/+3