| Age | Commit message (Collapse) | Author | Lines |
|
[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass
This does not yet attempt re-enabling the pass, but it does resolve a number of issues with the pass.
r? @oli-obk
I believe this closes #73223.
|
|
|
|
If temporaries are used beyond just the temporary chain, then we can't
optimize out the reads and writes.
|
|
|
|
|
|
added regions with counter expressions and counters.
Added codegen_llvm/coverageinfo mod for upcoming coverage map
Move coverage region collection to CodegenCx finalization
Moved from `query coverageinfo` (renamed from `query coverage_data`),
as discussed in the PR at:
https://github.com/rust-lang/rust/pull/73684#issuecomment-649882503
Address merge conflict in MIR instrument_coverage test
The MIR test output format changed for int types.
moved debug messages out of block.rs
This makes the block.rs calls to add coverage mapping data to the
CodegenCx much more concise and readable.
move coverage intrinsic handling into llvm impl
I realized that having half of the coverage intrinsic handling in
`rustc_codegen_ssa` and half in `rustc_codegen_llvm` meant that any
non-llvm backend would be bound to the same decisions about how the
coverage-related MIR terminators should be handled.
To fix this, I moved the non-codegen portion of coverage intrinsic
handling into its own trait, and implemented it in `rustc_codegen_llvm`
alongside `codegen_intrinsic_call`.
I also added the (required?) stubs for the new intrinsics to
`IntrepretCx::emulate_intrinsic()`, to ensure calls to this function do
not fail if called with these new but known intrinsics.
address PR Feedback on 28 June 2020 2:48pm PDT
|
|
propagation
|
|
|
|
|
|
The const propagator cannot trace references.
Thus we avoid propagation of a local the moment we encounter references to it.
fixes #73609
cc @RalfJung
r? @wesleywiser
|
|
Thus we avoid propagation of a local the moment we encounter references to it.
|
|
Revert the code that states that upcasting traits requires full
equality and change to require that the source type is a subtype of
the target type, as one would expect. As the comment states, this was
an old bug that we didn't want to fix yet as it interacted poorly with
the old leak-check. This fixes the old-lub-glb-object test, which was
previously reporting too many errors (i.e., in the previous commit).
|
|
[mir-opt] Small ConstProp cleanup
|
|
davidtwco:issue-72181-pretty-print-const-val-enum-no-variants, r=oli-obk
pretty/mir: const value enums with no variants
Fixes #72181.
This PR modifies the pretty printer and const eval in the MIR so that `destructure_const` (used in `pretty_print_const_value`) can handle enums with no variants (or types containing enums with no variants).
I'm not convinced that this is the correct approach, folks more familiar with `destructure_const` would be able to say - happy to adjust the PR. Looking through `destructure_const` and the functions that it invokes, it didn't seem like it was written to handle zero-variant-enums - I assume that case is handled earlier in some way so `destructure_const` doesn't need to under normal circumstances. It didn't seem like it would be straightforward to make `destructure_const` handle this case in a first-class-feeling way (e.g. adding a `Variants::None` variant), so this PR makes some minimal changes to avoid ICEs.
|
|
shim.rs: avoid creating `Call` terminators calling `Self`
Also contains some cleanup and doc comment additions so I could make sense of the code.
Fixes https://github.com/rust-lang/rust/issues/73109
Closes https://github.com/rust-lang/rust/pull/73175
r? @matthewjasper
|
|
This commit modifies the pretty printer and const eval in the MIR so
that `destructure_const` (used in `pretty_print_const_value`) can handle
enums with no variants (or types containing enums with no variants).
Signed-off-by: David Wood <david@davidtw.co>
|
|
first stage of implementing LLVM code coverage
This PR replaces #70680 (WIP toward LLVM Code Coverage for Rust) since I am re-implementing the Rust LLVM code coverage feature in a different part of the compiler (in MIR pass(es) vs AST).
This PR updates rustc with `-Zinstrument-coverage` option that injects the llvm intrinsic `instrprof.increment()` for code generation.
This initial version only injects counters at the top of each function, and does not yet implement the required coverage map.
Upcoming PRs will add the coverage map, and add more counters and/or counter expressions for each conditional code branch.
Rust compiler MCP https://github.com/rust-lang/compiler-team/issues/278
Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
***[I put together some development notes here, under a separate branch.](https://github.com/richkadel/rust/blob/cfa0b21d34ee64e4ebee226101bd2ef0c6757865/src/test/codegen/coverage-experiments/README-THIS-IS-TEMPORARY.md)***
|
|
Remove const prop for indirects
This was only used by one mir-opt test and since it causes buggy behavior under `-Zmir-opt-level=2`, it seems like we should remove it.
This was split out from #71946.
Closes #72679
Closes #72372
Closes #72285
|
|
If config.toml `profiler = false`, the test/mir-opt/instrument_coverage
test is ignored. Otherwise, this patch ensures the profiler_runtime is
loaded when -Zinstrument-coverage is enabled. Confirmed that this works
for MacOS.
|
|
|
|
This mode is unnecessary because it's always ok to evaluate the
right-hand side of assignments even if the left-hand side should not
have reads propagated.
|
|
|
|
Addresses feedback from @oli-obk (Thanks!)
|
|
|
|
|
|
This pass is buggy so I'm disabling it to fix a stable-to-beta
regression.
Related to #73223
|
|
Closes #72679
Closes #72372
Closes #72285
|
|
|
|
|
|
This reverts commit a030c923412b0a0f7b02a585debe7bf60357370d.
|
|
InstCombine: Don't optimize `&mut *x` into `x`
Fixes https://github.com/rust-lang/rust/issues/72797
|
|
|
|
|
|
|
|
Clear MIR local type annotations after borrowck
|
|
|
|
|
|
Dumb NRVO
This is a very simple version of an NRVO pass, which scans backwards from the `return` terminator to see if there is an an assignment like `_0 = _1`. If a basic block with two or more predecessors is encountered during this scan without first seeing an assignment to the return place, we bail out. This avoids running a full "reaching definitions" dataflow analysis.
I wanted to see how much `rustc` would benefit from even a very limited version of this optimization. We should be able to use this as a point of comparison for more advanced versions that are based on live ranges.
r? @ghost
|
|
Propagate locals, even if they have unpropagatable assignments somewhere
Second try for https://github.com/rust-lang/rust/pull/71946#discussion_r422967292
r? @wesleywiser
cc @rust-lang/wg-mir-opt @RalfJung
|
|
|
|
|
|
|
|
|
|
Rollup of 12 pull requests
Successful merges:
- #71525 (`prefix` should not be mutable.)
- #71741 (Pointer printing: do not print 0 offset)
- #71870 (Be slightly more precise about any::type_name()'s guarantees.)
- #71909 (Document From trait for Option implementations)
- #71964 (Fix bootstrap failing on win32)
- #72137 (Clean up E0581 explanation)
- #72138 (Add doc comment for `rustc_middle::mir::mono::Linkage`)
- #72150 (Remove UnnormalizedProjection)
- #72151 (Update books)
- #72163 (docs: remove comment referencing non-existent method)
- #72169 (Clean up E0582 explanation)
- #72183 (Fix Arc::decr_strong_count doc test)
Failed merges:
r? @ghost
|
|
|
|
|
|
|
|
initialized variables
|
|
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
|
|
Const prop aggregates even if partially or fully modified
r? @wesleywiser
cc @rust-lang/wg-mir-opt I'm moderately scared of this change, but I'm confident in having reviewed all the cases.
|