about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2023-10-25Do not remove unused definitions inside GVN.Camille GILLOT-12/+3
2023-10-24Auto merge of #115796 - cjgillot:const-prop-rvalue, r=oli-obkbors-18/+172
Generate aggregate constants in DataflowConstProp.
2023-10-24Require target features to match exactly during inliningTomasz Miąsko-4/+2
In general it is not correct to inline a callee with a target features that are subset of the callee. Require target features to match exactly during inlining. The exact match could be potentially relaxed, but this would require identifying specific feature that are allowed to differ, those that need to match, and those that can be present in caller but not in callee. This resolves MIR part of #116573. For other concerns with respect to the previous implementation also see areInlineCompatible in LLVM.
2023-10-24Auto merge of #116300 - cjgillot:split-move, r=petrochenkovbors-95/+96
Separate move path tracking between borrowck and drop elaboration. The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration. The 2 first commits are cleanups. The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more. The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-23Auto merge of #107009 - cjgillot:jump-threading, r=pnkfelixbors-88/+864
Implement jump threading MIR opt This pass is an attempt to generalize `ConstGoto` and `SeparateConstSwitch` passes into a more complete jump threading pass. This pass is rather heavy, as it performs a truncated backwards DFS on MIR starting from each `SwitchInt` terminator. This backwards DFS remains very limited, as it only walks through `Goto` terminators. It is build to support constants and discriminants, and a propagating through a very limited set of operations. The pass successfully manages to disentangle the `Some(x?)` use case and the DFA use case. It still needs a few tests before being ready.
2023-10-21Use a ConstValue instead.Camille GILLOT-96/+159
2023-10-21Generate ValTrees in DataflowConstProp.Camille GILLOT-4/+95
2023-10-21Typo.Camille GILLOT-1/+1
2023-10-21Remove on_all_drop_children_bits.Camille GILLOT-9/+15
As drop elaboration only tracks places that need dropping, is has become equivalent to `on_all_children_bits`.
2023-10-21Do not create move paths that do not need dropping.Camille GILLOT-2/+18
2023-10-21Give collect_drop_flags and elaborate_drops closer structure.Camille GILLOT-72/+64
2023-10-21Parametrize gather_moves by filter.Camille GILLOT-2/+2
2023-10-21Do not report errors from move path builder.Camille GILLOT-15/+2
2023-10-21Rollup merge of #116974 - Zalathar:signature-spans, r=oli-obk,cjgillotMatthias Krüger-57/+41
coverage: Fix inconsistent handling of function signature spans While doing some more cleanup of `spans`, I noticed a strange inconsistency in how function signatures are handled. Normally the function signature span is treated as though it were executable as part of the start of the function, but in some cases the signature span disappears entirely from coverage, for no obvious reason. This is caused by the fact that spans created by `CoverageSpan::for_fn_sig` don't add the span to their `merged_spans` field (unlike normal statement/terminator spans). In cases where the span-processing code looks at those merged spans, it thinks the signature span is no longer visible and deletes it. Adding the signature span to `merged_spans` resolves the inconsistency. (Prior to #116409 this wouldn't have been possible, because there was no case in the old `CoverageStatement` enum representing a signature. Now that `merged_spans` is just a list of spans, that's no longer an obstacle.)
2023-10-21Expand comment on disappearing edge.Camille GILLOT-1/+1
2023-10-21Correct loop_headers logic.Camille GILLOT-2/+2
2023-10-21Reword TO application comments.Camille GILLOT-3/+4
2023-10-21Simplify static if handling.Camille GILLOT-4/+6
2023-10-21Explicit notation.Camille GILLOT-0/+4
2023-10-21Document Condition.Camille GILLOT-0/+2
2023-10-21Make polarity an enum.Camille GILLOT-11/+23
2023-10-21Document mutated_statement.Camille GILLOT-4/+15
2023-10-21Improve naming and comments.Camille GILLOT-1/+1
2023-10-21Handle more terminators.Camille GILLOT-21/+71
2023-10-21Do not thread through loop headers.Camille GILLOT-3/+42
2023-10-21Implement JumpThreading pass.Camille GILLOT-0/+640
2023-10-21Make instance an option in CostChecker.Camille GILLOT-10/+15
2023-10-21Extract cost checker from inliner.Camille GILLOT-88/+98
2023-10-21coverage: Simplify the injection of coverage statementsZalathar-143/+87
2023-10-21coverage: Simplify initial creation of coverage spansZalathar-45/+32
2023-10-21coverage: Don't create an intermediate vec for each BCB's initial spansZalathar-26/+23
2023-10-21coverage: Handle fn signature spans more consistently near `?`Zalathar-1/+1
2023-10-20s/generator/coroutine/Oli Scherer-129/+129
2023-10-20s/Generator/Coroutine/Oli Scherer-88/+88
2023-10-19Auto merge of #115214 - Urgau:rfc-3127-trim-paths, r=compiler-errorsbors-1/+4
Implement rustc part of RFC 3127 trim-paths This PR implements (or at least tries to) [RFC 3127 trim-paths](https://github.com/rust-lang/rust/issues/111540), the rustc part. That is `-Zremap-path-scope` with all of it's components/scopes. `@rustbot` label: +F-trim-paths
2023-10-19Rollup merge of #116896 - cjgillot:single-inline, r=oli-obkMatthias Krüger-13/+22
Only check in a single place if a pass is enabled. Fixes https://github.com/rust-lang/rust/issues/116294
2023-10-18Only check in a single place if a pass is enabled.Camille GILLOT-13/+22
2023-10-18coverage: Store expression data in function coverage infoZalathar-72/+19
Even though expression details are now stored in the info structure, we still need to inject `ExpressionUsed` statements into MIR, because if one is missing during codegen then we know that it was optimized out and we can remap all of its associated code regions to zero.
2023-10-18Remove unused `TyCtxt` from `remove_dead_blocks`Zalathar-9/+9
This context was only needed by code for processing coverage statements, which has been removed.
2023-10-18coverage: Store all of a function's mappings in function coverage infoZalathar-142/+17
Previously, mappings were attached to individual coverage statements in MIR. That necessitated special handling in MIR optimizations to avoid deleting those statements, since otherwise codegen would be unable to reassemble the original list of mappings. With this change, a function's list of mappings is now attached to its MIR body, and survives intact even if individual statements are deleted by optimizations.
2023-10-18coverage: Rename `Operand` to `CovTerm`Zalathar-20/+20
Later patches in this PR will use `CovTerm` to represent things that are not expression operands.
2023-10-18coverage: Store the number of counters/expressions in function coverage infoZalathar-74/+25
Coverage codegen can now allocate arrays based on the number of counters/expressions originally used by the instrumentor. The existing query that inspects coverage statements is still used for determining the number of counters passed to `llvm.instrprof.increment`. If some high-numbered counters were removed by MIR optimizations, the instrumented binary can potentially use less memory and disk space at runtime.
2023-10-18coverage: Attach an optional `FunctionCoverageInfo` to `mir::Body`Zalathar-3/+5
This allows coverage information to be attached to the function as a whole when appropriate, instead of being smuggled through coverage statements in the function's basic blocks. As an example, this patch moves the `function_source_hash` value out of individual `CoverageKind::Counter` statements and into the per-function info. When synthesizing unused functions for coverage purposes, the absence of this info is taken to indicate that a function was not eligible for coverage and should not be synthesized.
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-5/+130
2023-10-17[RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopesUrgau-1/+4
2023-10-16debug Span::ctxt() call detectionArthur Lafrance-1/+1
2023-10-16coverage: Explain why we temporarily steal `pending_dups`Zalathar-6/+20
2023-10-16coverage: Inline `span_bcb_dominates`Zalathar-14/+11
Interacting with `basic_coverage_blocks` directly makes it easier to satisfy the borrow checker when mutating `pending_dups` while reading other fields.
2023-10-16coverage: Inline `prev_starts_after_next`Zalathar-10/+5
2023-10-16coverage: Move `take_curr` and note what its callers are doingZalathar-9/+9