about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2020-07-29Move mir-opt tests to toplevelXavier Denis-235/+10
2020-07-29add crate name to mir dumpsXavier Denis-156/+156
2020-07-27mv std libs to library/mark-856/+856
2020-07-24Auto merge of #74507 - lcnr:const-prop-into-op, r=oli-obkbors-27/+211
add `visit_operand` to const prop r? @oli-obk
2020-07-24Rollup merge of #74715 - oli-obk:mir_pass_diff, r=wesleywiserManish Goregaokar-483/+314
Add a system for creating diffs across multiple mir optimizations. r? @wesleywiser
2020-07-24Add a system for creating diffs across multiple mir optimizations.Oliver Scherer-483/+314
2020-07-22Optimize away BitAnd and BitOr when possibleXavier Denis-0/+98
2020-07-22const prop into operandsBastian Kauschke-27/+211
2020-07-19Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandrybors-22/+34
Generating the coverage map @tmandry @wesleywiser rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example commands to generate a coverage report: ```shell $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main ``` ![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png) r? @wesleywiser Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-17Rollup merge of #74411 - jonas-schievink:unbreak-mir, r=matthewjasperManish Goregaokar-7/+0
Don't assign `()` to `!` MIR locals Implements the fix described in https://github.com/rust-lang/rust/issues/73860#issuecomment-651731893. Fixes https://github.com/rust-lang/rust/issues/73860 r? @matthewjasper
2020-07-17Generating the coverage mapRich Kadel-22/+34
rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example: $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main 1| 1|pub fn will_be_called() { 2| 1| println!("called"); 3| 1|} 4| | 5| 0|pub fn will_not_be_called() { 6| 0| println!("should not have been called"); 7| 0|} 8| | 9| 1|fn main() { 10| 1| let less = 1; 11| 1| let more = 100; 12| 1| 13| 1| if less < more { 14| 1| will_be_called(); 15| 1| } else { 16| 1| will_not_be_called(); 17| 1| } 18| 1|}
2020-07-17Make fmt::Arguments::as_str() return a 'static str.Mara Bos-264/+252
2020-07-16Don't assign `()` to `!` MIR localsJonas Schievink-7/+0
2020-07-15improve namingBastian Kauschke-48/+48
2020-07-15mir opt cross compileBastian Kauschke-12/+12
2020-07-15mir opt diffBastian Kauschke-36/+36
2020-07-08Correctly mark the ending span of a match armAyaz Hafiz-86/+86
Closes #74050 r? @matthewjasper
2020-07-05Auto merge of #73879 - ecstatic-morse:discr-switch-uninit, r=oli-obkbors-16/+44
Handle inactive enum variants in `MaybeUninitializedPlaces` Resolves the first part of #69715. This is the equivalent of #68528 but for `MaybeUninitializedPlaces`. Because we now notify drop elaboration that inactive enum variants might be uninitialized, some drops get marked as ["open" that were previously "static"](https://github.com/rust-lang/rust/blob/e0e5d82e1677c82d209b214bbfc2cc5705c2336a/src/librustc_mir/transform/elaborate_drops.rs#L191). Unlike in #69715, this isn't strictly better: An "open" drop expands to more MIR than a simple call to the drop shim. However, because drop elaboration considers each field of an "open" drop separately, it can sometimes eliminate unnecessary drops of moved-from or unit-like enum variants. This is the case for `Option::unwrap`, which is reflected in the `mir-opt` test. cc @eddyb r? @oli-obk
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