about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2020-08-05Auto merge of #75037 - richkadel:llvm-coverage-map-gen-5.2, r=wesleywiserbors-33/+61
Completes support for coverage in external crates Follow-up to #74959 : The prior PR corrected for errors encountered when trying to generate the coverage map on source code inlined from external crates (including macros and generics) by avoiding adding external DefIds to the coverage map. This made it possible to generate a coverage report including external crates, but the external crate coverage was incomplete (did not include coverage for the DefIds that were eliminated. The root issue was that the coverage map was converting Span locations to source file and locations, using the SourceMap for the current crate, and this would not work for spans from external crates (compliled with a different SourceMap). The solution was to convert the Spans to filename and location during MIR generation instead, so precompiled external crates would already have the correct source code locations embedded in their MIR, when imported into another crate. @wesleywiser FYI r? @tmandry
2020-08-04Completes support for coverage in external cratesRich Kadel-33/+61
The prior PR corrected for errors encountered when trying to generate the coverage map on source code inlined from external crates (including macros and generics) by avoiding adding external DefIds to the coverage map. This made it possible to generate a coverage report including external crates, but the external crate coverage was incomplete (did not include coverage for the DefIds that were eliminated. The root issue was that the coverage map was converting Span locations to source file and locations, using the SourceMap for the current crate, and this would not work for spans from external crates (compliled with a different SourceMap). The solution was to convert the Spans to filename and location during MIR generation instead, so precompiled external crates would already have the correct source code locations embedded in their MIR, when imported into another crate.
2020-08-04Forbid non-derefable types explicitly in unsizing castsYuki Okushi-1/+9
2020-08-03Auto merge of #75076 - tmiasko:simplify-goto, r=oli-obkbors-3/+1
Fix change detection in CfgSimplifier::collapse_goto_chain Check that the old target is different from the new collapsed one, before concluding that anything changed. Fixes #75074 Fixes #75051
2020-08-03Remove redundant assignment from CfgSimplifierTomasz Miąsko-2/+0
2020-08-03Fix change detection in CfgSimplifier::collapse_goto_chainTomasz Miąsko-1/+1
Check that the old target is different from the new collapsed one, before concluding that anything changed.
2020-08-02fix typosliuzhenyu-1/+1
2020-08-01Rollup merge of #74983 - oli-obk:mir_opt_goto_chain, r=ecstatic-morseManish Goregaokar-26/+43
Replace a recursive algorithm with an iterative one and a stack. fixes #74931
2020-08-01Replace a recursive algorithm with an iterative one and a stack.Oliver Scherer-26/+43
2020-08-01Auto merge of #74945 - dingxiangfei2009:promote-static-ref-deref, r=oli-obkbors-2/+40
[mir] Special treatment for dereferencing a borrow to a static definition Fix #70584. As suggested by @oli-obk in this [comment](https://github.com/rust-lang/rust/issues/70584#issuecomment-626009260), one can chase the definition of the local variable being de-referenced and check if it is a true static variable. If that is the case, `validate_place` will admit the promotion. This is my first time to contribute to `rustc`, and I have two questions. 1. A generalization to some extent is applied to decide if the promotion is possible in the static context. In case that there are more projection operations preceding the de-referencing, `validate_place` recursively decent into inner projection operations. I have put thoughts into its correctness but I am not totally sure about it. 2. I have a hard time to find a good place for the test case. This patch has to do with MIR, but this test case would look out of place compared to other tests in `src/test/ui/mir` or `src/test/ui/borrowck` because it does not generate errors while others do. It is tentatively placed in `src/test/ui/statics` for now. Thank you for any comments and suggestions!
2020-07-31Auto merge of #65989 - Aaron1011:fix/normalize-param-env, r=nikomatsakisbors-4/+4
Normalize all opaque types when converting ParamEnv to Reveal::All When we normalize a type using a ParamEnv with a reveal mode of RevealMode::All, we will normalize opaque types to their underlying types (e.g. `type MyOpaque = impl Foo` -> `StructThatImplsFoo`). However, the ParamEnv may still have predicates referring to the un-normalized opaque type (e.g. `<T as MyTrait<MyOpaque>>`). This can cause trait projection to fail, since a type containing normalized opaque types will not match up with the un-normalized type in the `ParamEnv`. To fix this, we now explicitly normalize all opaque types in caller_bounds of a `ParamEnv` when changing its mode to `RevealMode::All`. This ensures that all predicatse will refer to the underlying types of any opaque types involved, allowing them to be matched up properly during projection. To reflect the fact that normalization is occuring, `ParamEnv::with_reveal_all` is renamed to `ParamEnv::with_reveal_all_normalized` Fixes #65918
2020-07-31rustfmtDing Xiang Fei-1/+3
2020-07-31Remove a trailing spaceDing Xiang Fei-1/+1
2020-07-31Add comments to explain the test case and the special treatmentDing Xiang Fei-1/+13
2020-07-30Special treatment for dereferencing a borrow to a static definitionDing Xiang Fei-2/+26
2020-07-29Auto merge of #74733 - richkadel:llvm-coverage-map-gen-5, r=tmandrybors-94/+124
Fixed coverage map issues; better aligned with LLVM APIs Found some problems with the coverage map encoding when testing with more than one counter per function. While debugging, I realized some better ways to structure the Rust implementation of the coverage mapping generator. I refactored somewhat, resulting in less code overall, expanded coverage of LLVM Coverage Map capabilities, and much closer alignment with LLVM data structures, APIs, and naming. This should be easier to follow and easier to maintain. r? @tmandry Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-29Stop propagating to locals that were marks as unpropagatable.Oliver Scherer-5/+11
We used to erase these values immediately after propagation, but some things slipped through and it caused us to still initialize huge locals.
2020-07-29Check whether locals are too large instead of whether accesses into them are ↵Oliver Scherer-56/+60
too large
2020-07-28Refactor MIR coverage instrumentationRich Kadel-88/+118
Lays a better foundation for injecting more counters in each function.
2020-07-27Auto merge of #73503 - lcnr:forall-predicate-what-and-why-2, r=nikomatsakisbors-12/+12
convert higher ranked `Predicate`s to `PredicateKind::ForAll` implements step 2 of https://github.com/rust-lang/compiler-team/issues/285 r? @nikomatsakis
2020-07-27introduce PredicateAtomBastian Kauschke-12/+11
2020-07-27this might be unqualified, but at least it's now quantifiedBastian Kauschke-1/+1
2020-07-27split ignore_qualifiersBastian Kauschke-1/+1
2020-07-27reviewBastian Kauschke-1/+0
2020-07-27`PredicateKint` -> `PredicateKind`, the beginning of the endBastian Kauschke-2/+4
2020-07-27Auto merge of #74775 - RalfJung:miri-alloc-ids, r=oli-obkbors-1/+1
Miri: replace canonical_alloc_id mechanism by extern_static_alloc_id We only have to call `extern_static_alloc_id` when a `Pointer` is "imported" from the `tcx` to the machine, not on each access. Also drop the old hook for TLS handling, it is not needed any more. The Miri side of this is at https://github.com/rust-lang/miri/pull/1489. Fixes https://github.com/rust-lang/rust/issues/71194 r? @oli-obk
2020-07-27rename eval_const_to_op -> const_to_opRalf Jung-1/+1
2020-07-25Fixed coverage map issues; better aligned with LLVM APIsRich Kadel-8/+8
Found some problems with the coverage map encoding when testing with more than one counter per function. While debugging, I realized some better ways to structure the Rust implementation of the coverage mapping generator. I refactored somewhat, resulting in less code overall, expanded coverage of LLVM Coverage Map capabilities, and much closer alignment with LLVM data structures, APIs, and naming. This should be easier to follow and easier to maintain.
2020-07-24Auto merge of #74507 - lcnr:const-prop-into-op, r=oli-obkbors-62/+50
add `visit_operand` to const prop r? @oli-obk
2020-07-24Rollup merge of #74491 - xldenis:constant-binop-opt, r=oli-obkManish Goregaokar-21/+85
Optimize away BitAnd and BitOr when possible This PR lets `const_prop` optimize away `a | true == true` , `a & false == false` and `a * 0 = 0`. While I was writing this I've realized that constant propagation misses a lot of opportunities. For example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2a4b45e772f214210a36749b27223bb0 Constant propagation doesn't seem to... propagate constants, additionally the way constant propagation is currently setup makes it tricky to add cases like `a | false == a`. I tried to organize `eval_rvalue_with_identities` to make the pattern of the optimizations easier to see but it still obscurs what should be a simple peephole optmization. cc @oli-obk
2020-07-23slightly adapt const propBastian Kauschke-7/+7
2020-07-22note LLVM in fixmeBastian Kauschke-1/+1
2020-07-22Optimize away BitAnd and BitOr when possibleXavier Denis-21/+85
2020-07-22const prop into operandsBastian Kauschke-62/+50
2020-07-22Fix rebase falloutAaron Hill-1/+1
2020-07-22Normalize opaque types when converting `ParamEnv` to `Reveal::All`Aaron Hill-3/+3
Fixes #65918
2020-07-21fetch -> lookupBastian Kauschke-4/+4
2020-07-21`try_update` -> `try_upgrade`Bastian Kauschke-3/+3
2020-07-21remove some const arg in ty dep path boilerplateBastian Kauschke-39/+26
2020-07-20trait_sel: only test predicates w/ no substsDavid Wood-1/+1
This commit modifies the `substitute_normalize_and_test_predicates` query, renaming it to `impossible_predicates` and only checking predicates which do not require substs. By making this change, polymorphization doesn't have to explicitly support vtables. Signed-off-by: David Wood <david@davidtw.co>
2020-07-19Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandrybors-56/+204
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 #74169 - ecstatic-morse:dataflow-unreachable, r=pnkfelixManish Goregaokar-3/+1
Stop processing unreachable blocks when solving dataflow ...instead we `debug_assert` that the user is not checking the dataflow state for an unreachable block. This resolves a FIXME in the dataflow engine. The old behavior was an artifact of the previous dataflow framework. Things should run a tiny bit faster now, but I suspect not enough to show up in benchmarks. AFAIK, only the generator transform runs dataflow on MIR with unreachable basic blocks. This PR also adds some utility methods to `mir::traversal`. r? @pnkfelix
2020-07-17Generating the coverage mapRich Kadel-56/+204
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-16Rollup merge of #74357 - nnethercote:symbol-related-improvements, r=oli-obkManish Goregaokar-82/+30
Some `Symbol` related improvements These commits make things nicer and avoid some `Symbol::as_str()` calls. r? @oli-obk
2020-07-17Add `UnsafetyViolationDetails`.Nicholas Nethercote-82/+30
This replaces the need for the `description` and `details` symbols in `UnsafetyViolation`, which are static. As a result some `Symbol::as_str()` calls are no longer necessary, which is nice.
2020-07-16Rollup merge of #74221 - oli-obk:const_prop_ice, r=wesleywiserManish Goregaokar-5/+21
Don't panic if the lhs of a div by zero is not statically known Fixes #73993 for real this time r? @wesleywiser
2020-07-15Don't panic if the lhs of a div by zero is not statically knownOliver Scherer-5/+21
2020-07-15unsafety_check_result_for_const_argBastian Kauschke-3/+3
2020-07-15WithOptConstParam::dummy -> WithOptConstParam::unknownBastian Kauschke-7/+7
2020-07-15improve namingBastian Kauschke-37/+48