about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2020-07-03Rollup merge of #73949 - wesleywiser:simplify_try_fixes, r=oli-obkManish Goregaokar-26/+1293
[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.
2020-07-02Fix debuginfo so that it points to the correct localWesley Wiser-101/+55
2020-07-02[mir-opt] Prevent mis-optimization when SimplifyArmIdentity runsWesley Wiser-95/+143
If temporaries are used beyond just the temporary chain, then we can't optimize out the reads and writes.
2020-07-02Add test for simplify-try misoptimizationWesley Wiser-0/+1265
2020-06-30Bless mir-opt testsDylan MacKenzie-16/+44
2020-06-29add spans to injected coverage countersRich Kadel-6/+30
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
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-373/+475
propagation
2020-06-24Improve GeneratorLayout debug outputTyler Mandry-2/+28
2020-06-24Emit line info for generator variantsTyler Mandry-2/+2
2020-06-23Rollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiserManish Goregaokar-32/+164
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
2020-06-23The const propagator cannot trace references.Oliver Scherer-32/+164
Thus we avoid propagation of a local the moment we encounter references to it.
2020-06-22upcasting traits requires only that things become more generalNiko Matsakis-2/+2
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).
2020-06-21Auto merge of #71911 - wesleywiser:const_prop_small_cleanups, r=oli-obkbors-19/+67
[mir-opt] Small ConstProp cleanup
2020-06-19Rollup merge of #73442 - ↵Manish Goregaokar-0/+618
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.
2020-06-19Rollup merge of #73359 - jonas-schievink:do-the-shimmy, r=matthewjasperManish Goregaokar-0/+28
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
2020-06-19pretty/mir: const value enums with no variantsDavid Wood-0/+618
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>
2020-06-19Rollup merge of #73011 - richkadel:llvm-count-from-mir-pass, r=tmandryRalf Jung-0/+143
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)***
2020-06-19Rollup merge of #73130 - wesleywiser:remove_const_prop_for_indirects, r=oli-obkRalf Jung-82/+73
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
2020-06-16Ensure profiling runtime for -Zinstrument-coverageRich Kadel-38/+39
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.
2020-06-15Add EMIR_MIR_FOR_EACH_BIT_WIDTH to failing testWesley Wiser-0/+43
2020-06-15[const-prop] Remove `ConstPropMode::NoPropagation`Wesley Wiser-19/+24
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.
2020-06-15updated mir-opt test due to other recent changes to MIRRich Kadel-12/+12
2020-06-15added test, Operand::const_from_scalar, require_lang_item, & commentsRich Kadel-0/+142
Addresses feedback from @oli-obk (Thanks!)
2020-06-15Add testJonas Schievink-0/+28
2020-06-13Prefer the associated consts for pattern matching errorLzu Tao-2/+2
2020-06-12Disable the `SimplifyArmIdentity` pass on betaWesley Wiser-61/+82
This pass is buggy so I'm disabling it to fix a stable-to-beta regression. Related to #73223
2020-06-09Stop allowing `Indirect(..)` values to be propagatedWesley Wiser-82/+73
Closes #72679 Closes #72372 Closes #72285
2020-06-07rename FalseEdges -> FalseEdgeRalf Jung-31/+31
2020-06-04further bless tests.Felix S. Klock II-19/+19
2020-06-04Revert "Bless mir-opt tests"Felix S. Klock II-819/+973
This reverts commit a030c923412b0a0f7b02a585debe7bf60357370d.
2020-06-03Rollup merge of #72820 - jonas-schievink:instcombine-uninit, r=oli-obkDylan DPC-4/+17
InstCombine: Don't optimize `&mut *x` into `x` Fixes https://github.com/rust-lang/rust/issues/72797
2020-05-31InstCombine: Don't optimize `&mut *x` into `x`Jonas Schievink-4/+17
2020-05-30Make TLS accesses explicit in MIROliver Scherer-0/+53
2020-05-25Avoid `Operand::Copy` with `&mut T`Jonas Schievink-2/+2
2020-05-25Auto merge of #72520 - jonas-schievink:cleanup-userty, r=matthewjasperbors-16/+16
Clear MIR local type annotations after borrowck
2020-05-24Clear MIR local type annotations after borrowckJonas Schievink-16/+16
2020-05-23bless mir-opt testsRalf Jung-2/+2
2020-05-21Auto merge of #72205 - ecstatic-morse:nrvo, r=oli-obkbors-15/+54
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
2020-05-17Auto merge of #72135 - oli-obk:const_prop_deaggregates, r=wesleywiserbors-0/+165
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
2020-05-16Bless mir-opt tests to account for #72220Wesley Wiser-4/+2
2020-05-16Add simple NRVO testDylan MacKenzie-0/+51
2020-05-16Bless MIR tests that inline functions qualifying for NRVODylan MacKenzie-15/+3
2020-05-14[const-prop] Don't replace Rvalues that are already constantsWesley Wiser-6/+4
2020-05-14Auto merge of #72187 - RalfJung:rollup-a7a9jdi, r=RalfJungbors-75/+75
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
2020-05-12Pointer printing: do not print 0 offsetRalf Jung-75/+75
2020-05-12Add some more sanity tests and add a debug log message for itOliver Scherer-0/+89
2020-05-12Propagate locals, even if they have unpropagatable assignments somewhere.Oliver Scherer-3/+12
2020-05-12Add a repro example for not propagating constants of partially const ↵Oliver Scherer-0/+69
initialized variables
2020-05-11Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1Wesley Wiser-32/+717
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.
2020-05-11Auto merge of #71953 - oli-obk:const_prop_deaggregates, r=wesleywiserbors-0/+284
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.