about summary refs log tree commit diff
path: root/src/librustc_mir
AgeCommit message (Collapse)AuthorLines
2020-08-05Auto merge of #75155 - davidtwco:polymorphization-incr-comp-optimisations, ↵bors-10/+29
r=lcnr polymorphization: various improvements This PR includes a handful of polymorphisation-related changes: - @Mark-Simulacrum's suggestions [from this comment](https://github.com/rust-lang/rust/pull/74633#issuecomment-668684433): - Use a `FiniteBitSet<u32>` over a `FiniteBitSet<u64>` as most functions won't have 64 generic parameters. - Don't encode polymorphisation results in metadata when every parameter is used (in this case, just invoking polymorphisation will probably be quicker). - @lcnr's suggestion [from this comment](https://github.com/rust-lang/rust/pull/74717#discussion_r463690015). - Add an debug assertion in `ensure_monomorphic_enough` to make sure that polymorphisation did what we expect. r? @lcnr
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-05Rollup merge of #75149 - felixonmars:patch-1, r=wesleywiserYuki Okushi-1/+1
Correct a typo in interpret/memory.rs
2020-08-04mir: add debug assertion to check polymorphizationDavid Wood-2/+14
This commit adds some debug assertions to `ensure_monomorphic_enough` which checks that unused generic parameters have been replaced with a parameter. Signed-off-by: David Wood <david@davidtw.co>
2020-08-04metadata: skip empty polymorphization bitsetDavid Wood-0/+7
This commit skips encoding empty polymorphization results - while polymorphization is disabled, this should be every polymorphization result; but when polymorphization is re-enabled, this would help with non-generic functions and those which do use all their parameters (most functions). Signed-off-by: David Wood <david@davidtw.co>
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-04mir: use `FiniteBitSet<u32>` in polymorphizationDavid Wood-8/+8
This commit changes polymorphization to return a `FiniteBitSet<u32>` rather than a `FiniteBitSet<u64>` because most functions do not use anywhere near sixty-four generic parameters so keeping a `u64` around is unnecessary in most cases. Signed-off-by: David Wood <david@davidtw.co>
2020-08-04Correct a typo in interpret/memory.rsFelix Yan-1/+1
2020-08-04Forbid non-derefable types explicitly in unsizing castsYuki Okushi-1/+9
2020-08-04rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`Vadim Petrochenkov-3/+3
For consistency with `Attribute::has_name` which doesn't mark the attribute as used either. Replace all uses of `check_name` with `has_name` outside of rustc
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-01Auto merge of #74726 - oli-obk:tracing, r=Mark-Simulacrumbors-3/+2
Move from `log` to `tracing` The only visible change is that we now get timestamps in our logs: ``` Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: skipping replace of Rvalue::Use(const () because it is already a const Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: propagated into _2 Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: visit_constant: const () ``` This PR was explicitly designed to be as low-impact as possible. We can now move to using the name `tracing` insteads of `log` on a crate-by-crate basis and use any of the other tracing features where desirable. As far as I can tell this will allow tools to seamlessly keep working (since they are using `rustc_driver::init_log...`). This is the first half of step 1 of the accepted `tracing` MCP (https://github.com/rust-lang/compiler-team/issues/331)
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-08-01Auto merge of #74717 - ↵bors-20/+91
davidtwco:issue-74636-polymorphized-closures-inherited-params, r=oli-obk mir: add `used_generic_parameters_needs_subst` Fixes #74636. This PR adds a `used_generic_parameters_needs_subst` helper function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. This is used in the MIR interpreter to make the check for some pointer casts and for reflection intrinsics more precise. I've opened this as a draft PR because this might not be the approach we want to fix this issue and we have to decide what to do about the reflection case. r? @eddyb cc @lcnr @wesleywiser
2020-08-01Rollup merge of #74984 - RalfJung:miri-unwind-top, r=oli-obkYuki Okushi-0/+4
Miri: fix ICE when unwinding past topmost stack frame Fixes https://github.com/rust-lang/miri/issues/1389
2020-07-31Move from `log` to `tracing`Oliver Scherer-3/+2
2020-07-31Miri: fix ICE when unwinding past topmost stack frameRalf Jung-0/+4
2020-07-31Auto merge of #65989 - Aaron1011:fix/normalize-param-env, r=nikomatsakisbors-5/+5
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-31interp: needs_subst -> ensure_monomorphic_enoughDavid Wood-20/+91
This commit adds a `ensure_monomorphic_enough` utility function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. `ensure_monomorphic_enough` is then used throughout interpret where `needs_subst` checks previously existed (in particular, for some pointer casts and for reflection intrinsics more precise). Signed-off-by: David Wood <david@davidtw.co>
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-30Auto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obkbors-0/+15
Make `mem::size_of_val` and `mem::align_of_val` unstably const Implements #46571 but does not stabilize it. I wanted this while working on something today. The only reason not to immediately stabilize are concerns around [custom DSTs](https://github.com/rust-lang/rust/issues/46571#issuecomment-387669352). That proposal has made zero progress in the last two years and const eval is rich enough to support pretty much any user-defined `len` function as long as nightly features are allowed (`raw_ptr_deref`). Currently, this raises a `const_err` lint when passed an `extern type`. r? @oli-obk cc @rust-lang/wg-const-eval
2020-07-30Auto merge of #74876 - oli-obk:lumberjack_disable, r=RalfJungbors-132/+178
Replace all uses of `log::log_enabled` with `Debug` printers cc @RalfJung this touches a bunch of logging in the miri engine. There are some visual changes, mainly that in several cases we stop prepending lines with the module path and just have a newline.
2020-07-29Make `{align,size}_of_val` `const`Dylan MacKenzie-0/+15
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-29Move mir-opt tests to toplevelXavier Denis-2/+9
2020-07-29add crate name to mir dumpsXavier Denis-1/+2
2020-07-28Refactor MIR coverage instrumentationRich Kadel-88/+118
Lays a better foundation for injecting more counters in each function.
2020-07-28Replace write-to-vec hack by introducing a display renderer for allocationsOliver Scherer-26/+32
2020-07-28Replace all uses of `log::log_enabled` with `Debug` printersOliver Scherer-113/+153
2020-07-27Auto merge of #73503 - lcnr:forall-predicate-what-and-why-2, r=nikomatsakisbors-43/+38
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-27cleanupBastian Kauschke-8/+7
2020-07-27introduce PredicateAtomBastian Kauschke-18/+17
2020-07-27this might be unqualified, but at least it's now quantifiedBastian Kauschke-2/+2
2020-07-27split ignore_qualifiersBastian Kauschke-3/+3
2020-07-27reviewBastian Kauschke-1/+0
2020-07-27`PredicateKint` -> `PredicateKind`, the beginning of the endBastian Kauschke-11/+13
2020-07-27progressBastian Kauschke-13/+9
2020-07-27convert trivial predicatesBastian Kauschke-7/+7
2020-07-27Auto merge of #74775 - RalfJung:miri-alloc-ids, r=oli-obkbors-116/+100
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-12/+8