summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2020-11-11Rollup merge of #78899 - tmiasko:inline-diverging, r=oli-obkJonas Schievink-76/+76
Support inlining diverging function calls The existing heuristic does penalize diverging calls to some degree, but since it never inlined them previously it might need some further modifications. Additionally introduce storage markers for all temporaries created by the inliner. The temporary introduced for destination rebrorrow, didn't use them previously.
2020-11-11Rollup merge of #78873 - tmiasko:inline-opts, r=oli-obkJonas Schievink-4/+5
Add flags customizing behaviour of MIR inlining * `-Zinline-mir-threshold` to change the default threshold. * `-Zinline-mir-hint-threshold` to change the threshold used by functions with inline hint. Having those as configurable flags makes it possible to experiment with with different inlining thresholds and substantially increase test coverage of MIR inlining when used with increased thresholds (for example, necessary to test #78844).
2020-11-10Rollup merge of #78847 - tmiasko:inline-return-place, r=matthewjasperJonas Schievink-0/+6
Assert that a return place is not used for indexing during integration The inliner integrates call destination place with callee return place by remapping the local and adding extra projections as necessary. If a call destination place contains any projections (which is already possible) and a return place is used in an indexing projection (most likely doesn't happen yet) the end result would be incorrect. Add an assertion to ensure that potential issue won't go unnoticed in the presence of more sophisticated copy propagation scheme.
2020-11-10Add flags customizing behaviour of MIR inliningTomasz Miąsko-4/+5
* `-Zinline-mir-threshold` to change the default threshold. * `-Zinline-mir-hint-threshold` to change the threshold used by functions with inline hint.
2020-11-09Support inlining diverging function callsTomasz Miąsko-76/+76
Additionally introduce storage markers for all temporaries created by the inliner. The temporary introduced for destination rebrorrow, didn't use them previously.
2020-11-09inliner: Break inlining cyclesTomasz Miąsko-106/+108
When examining candidates for inlining, reject those that are determined to be recursive either because of self-recursive calls or calls to any instances already inlined.
2020-11-09inliner: Make `inline_call` infallibleTomasz Miąsko-17/+6
The inliner does not support inlining of divering calls. Reject them early on and turn `inline_call` into an infallible operation.
2020-11-09Rollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obkDylan DPC-14/+10
inliner: Use substs_for_mir_body Changes from 68965 extended the kind of instances that are being inlined. For some of those, the `instance_mir` returns a MIR body that is already expressed in terms of the types found in substitution array, and doesn't need further substitution. Use `substs_for_mir_body` to take that into account. Resolves #78529. Resolves #78560.
2020-11-08Auto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-sebors-30/+39
Rollup of 19 pull requests Successful merges: - #76097 (Stabilize hint::spin_loop) - #76227 (Stabilize `Poll::is_ready` and `is_pending` as const) - #78065 (make concurrency helper more pleasant to read) - #78570 (Remove FIXME comment in print_type_sizes ui test suite) - #78572 (Use SOCK_CLOEXEC and accept4() on more platforms.) - #78658 (Add a tool to run `x.py` from any subdirectory) - #78706 (Fix run-make tests running when LLVM is disabled) - #78728 (Constantify `UnsafeCell::into_inner` and related) - #78775 (Bump Rustfmt and RLS) - #78788 (Correct unsigned equivalent of isize to be usize) - #78811 (Make some std::io functions `const`) - #78828 (use single char patterns for split() (clippy::single_char_pattern)) - #78841 (Small cleanup in `TypeFoldable` derive macro) - #78842 (Honor the rustfmt setting in config.toml) - #78843 (Less verbose debug logging from inlining integrator) - #78852 (Convert a bunch of intra-doc links) - #78860 (rustc_resolve: Use `#![feature(format_args_capture)]`) - #78861 (typo and formatting) - #78865 (Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-11-08Rollup merge of #78865 - Aaron1011:fix/const-item-mut-reborrow, r=varkorMara Bos-21/+30
Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref Fixes #78819 This extends the check for dereferences added in PR #77324 to cover mutable borrows, as well as direct writes. If we're operating on a dereference of a `const` item, we shouldn't be firing the lint.
2020-11-08Rollup merge of #78843 - tmiasko:inline-trace, r=wesleywiserMara Bos-5/+5
Less verbose debug logging from inlining integrator The inlining integrator produces relatively verbose and uninteresting logs. Move them from a debug log level to a trace level, so that they can be easily isolated from others.
2020-11-08Auto merge of #78410 - lcnr:revert75443, r=nikomatsakisbors-75/+24
revert #75443, update mir validator This PR reverts rust-lang#75443 to fix rust-lang#75992 and instead uses rust-lang#75419 to fix rust-lang#75313. Adapts rust-lang#75419 to correctly deal with unevaluated constants as otherwise some `feature(const_evaluatable_checked)` tests would ICE. Note that rust-lang#72793 was also fixed by rust-lang#75443, but as that issue only concerns `feature(type_alias_impl_trait)` I deleted that test case for now and would reopen that issue. rust-lang#75443 may have also allowed some other code to now successfully compile which would make this revert a breaking change after 2 stable versions, but I hope that this is a purely theoretical concern. See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/generator.20upvars/near/214617274 for more reasoning about this. r? `@nikomatsakis` `@eddyb` `@RalfJung`
2020-11-07Use a semicolon instead of a dash in lint noteAaron Hill-1/+1
2020-11-07Don't fire `CONST_ITEM_MUTATION` lint when borrowing a derefAaron Hill-21/+30
Fixes #78819 This extends the check for dereferences added in PR #77324 to cover mutable borrows, as well as direct writes. If we're operating on a dereference of a `const` item, we shouldn't be firing the lint.
2020-11-07Less verbose debug logging from inlining integratorTomasz Miąsko-5/+5
The inlining integrator produces relatively verbose and uninteresting logs. Move them from a debug log level to a trace level, so that they can be easily isolated from others.
2020-11-07use single char patterns for split() (clippy::single_char_pattern)Matthias Krüger-4/+4
2020-11-07Assert that a return place is not used for indexing during integrationTomasz Miąsko-0/+6
The inliner integrates call destination place with callee return place by remapping the local and adding extra projections as necessary. If a call destination place contains any projections (which is already possible) and a return place is used in an indexing projection (most likely doesn't happen yet) the end result would be incorrect. Add an assertion to ensure that potential issue won't go unnoticed in the presence of more sophisticated copy propagation scheme.
2020-11-06improve fixmeBastian Kauschke-3/+6
2020-11-07Rollup merge of #78798 - ankushduacodes:fixing-typo, r=jonas-schievinkYuki Okushi-1/+1
Fixing Spelling Typos Fixing #78787
2020-11-07Rollup merge of #78771 - tmiasko:inline-consts, r=oli-obkYuki Okushi-8/+10
inliner: Copy unevaluated constants only after successful inlining Inliner copies the unevaluated constants from the callee body to the caller at the point where decision to inline is yet to be made. The constants will be unnecessary if inlining were to fail. Organize the code moving items from callee to the caller together in one place to avoid the issue.
2020-11-06Auto merge of #78267 - richkadel:llvm-coverage-counters-2.0.3r1, r=tmandrybors-1274/+3630
Working expression optimization, and some improvements to branch-level source coverage This replaces PR #78040 after reorganizing the original commits (by request) into a more logical sequence of major changes. Most of the work is in the MIR `transform/coverage/` directory (originally, `transform/instrument_coverage.rs`). Note this PR includes some significant additional debugging capabilities, to help myself and any future developer working on coverage improvements or issues. In particular, there's a new Graphviz (.dot file) output for the coverage graph (the `BasicCoverageBlock` control flow graph) that provides ways to get some very good insight into the relationships between the MIR, the coverage graph BCBs, coverage spans, and counters. (There are also some cool debugging options, available via environment variable, to alter how some data in the graph appears.) And the code for this Graphviz view is actually generic... it can be used by any implementation of the Rust `Graph` traits. Finally (for now), I also now output information from `llvm-cov` that shows the actual counters and spans it found in the coverage map, and their counts (from the `--debug` flag). I found this to be enormously helpful in debugging some coverage issues, so I kept it in the test results as well for additional context. `@tmandry` `@wesleywiser` r? `@tmandry` Here's an example of the new coverage graph: * Within each `BasicCoverageBlock` (BCB), you can see each `CoverageSpan` and its contributing statements (MIR `Statement`s and/or `Terminator`s) * Each `CoverageSpan` has a `Counter` or and `Expression`, and `Expression`s show their Add/Subtract operation with nested operations. (This can be changed to show the Counter and Expression IDs instead, or in addition to, the BCB.) * The terminators of all MIR `BasicBlock`s in the BCB, including one final `Terminator` * If an "edge counter" is required (because we need to count an edge between blocks, in some cases) the edge's Counter or Expression is shown next to its label. (Not shown in the example below.) (FYI, Edge Counters are converted into a new MIR `BasicBlock` with `Goto`) <img width="1116" alt="Screen Shot 2020-10-17 at 12 23 29 AM" src="https://user-images.githubusercontent.com/3827298/96331095-616cb480-100f-11eb-8212-60f2d433e2d8.png"> r? `@tmandry` FYI: `@wesleywiser`
2020-11-06Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27bors-1/+1
Add non_autolinks lint Part of #77501. r? `@jyn514`
2020-11-06Fixing Spelling Typosankushduacodes-1/+1
2020-11-05Responded to all feedback as of 2020-10-30Rich Kadel-206/+356
2020-11-05Addressed all feedback to dateRich Kadel-14/+23
2020-11-05Injecting expressions in place of counters where helpfulRich Kadel-47/+1431
Implementing the Graph traits for the BasicCoverageBlock graph. optimized replacement of counters with expressions plus new BCB graphviz * Avoid adding coverage to unreachable blocks. * Special case for Goto at the end of the body. Make it non-reportable. Improved debugging and formatting options (from env) Don't automatically add counters to BCBs without CoverageSpans. They may still get counters but only if there are dependencies from other BCBs that have spans, I think. Make CodeRegions optional for Counters too. It is possible to inject counters (`llvm.instrprof.increment` intrinsic calls without corresponding code regions in the coverage map. An expression can still uses these counter values. Refactored instrument_coverage.rs -> instrument_coverage/mod.rs, and then broke up the mod into multiple files. Compiling with coverage, with the expression optimization, works on the json5format crate and its dependencies. Refactored debug features from mod.rs to debug.rs
2020-11-05Adds coverage graphvizRich Kadel-10/+434
2020-11-05Implemented CoverageGraph of BasicCoverageBlocksRich Kadel-199/+347
2020-11-05Splitting transform/instrument_coverage.rs into transform/coverage/...Rich Kadel-730/+766
2020-11-05Rust coverage before splitting instrument_coverage.rsRich Kadel-320/+525
2020-11-06inliner: Use substs_for_mir_bodyTomasz Miąsko-14/+10
Changes from 68965 extended the kind of instances that are being inlined. For some of those, the `instance_mir` returns a MIR body that is already expressed in terms of the types found in substitution array, and doesn't need further substitution. Use `substs_for_mir_body` to take that into account.
2020-11-05Fix even more URLsGuillaume Gomez-1/+1
2020-11-05Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514Mara Bos-1/+1
fix a couple of clippy warnings: filter_next manual_strip redundant_static_lifetimes single_char_pattern unnecessary_cast unused_unit op_ref redundant_closure useless_conversion
2020-11-05inliner: Copy unevaluated constants only after successful inliningTomasz Miąsko-8/+10
Inliner copies the unevaluated constants from the callee body to the caller at the point where decision to inline is yet to be made. The constants will be unnecessary if inlining were to fail. Organize the code moving items from callee to the caller together in one place to avoid the issue.
2020-11-04`u128` truncation and sign extension are not just interpreter relatedoli-5/+4
2020-11-04fix a couple of clippy warnings:Matthias Krüger-1/+1
filter_next manual_strip redundant_static_lifetimes single_char_pattern unnecessary_cast unused_unit op_ref redundant_closure useless_conversion
2020-11-04s/Scalar::Raw/Scalar::Intoli-1/+1
2020-11-04Split the "raw integer bytes" part out of `Scalar`Oliver Scherer-7/+12
2020-11-03Auto merge of #78711 - m-ou-se:rollup-pxqnny7, r=m-ou-sebors-18/+36
Rollup of 7 pull requests Successful merges: - #77950 (Add support for SHA256 source file hashing) - #78624 (Sync rustc_codegen_cranelift) - #78626 (Improve errors about #[deprecated] attribute) - #78659 (Corrected suggestion for generic parameters in `function_item_references` lint) - #78687 (Suggest library/std when running all stage 0 tests) - #78699 (Show more error information in lldb_batchmode) - #78709 (Fix panic in bootstrap for non-workspace path dependencies.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-11-03Rollup merge of #78659 - ayrtonm:fn-ref-lint-fix, r=oli-obkMara Bos-18/+36
Corrected suggestion for generic parameters in `function_item_references` lint This commit handles functions with generic type parameters like you pointed out as well as const generics. Also this is probably a minor thing, but the type alias you used in the example doesn't show up so the suggestion right now would be `size_of::<[u8; 16]> as fn() ->`. This is because the lint checker works with MIR instead of HIR. I don't think we can get the alias at that point, but let me know if I'm wrong and there's a way to fix this. Also I put you as the reviewer, but I'm not sure if you want to review it or if it makes more sense to ask one of the original reviewers of this lint. closes #78571
2020-11-03Auto merge of #76931 - oli-obk:const_prop_inline_lint_madness, r=wesleywiserbors-0/+13
Properly handle lint spans after MIR inlining The first commit shows what happens when we apply mir inlining and then cause lints on the inlined MIR. The second commit fixes that. r? `@wesleywiser`
2020-11-03Auto merge of #78597 - RalfJung:raw-retag, r=oli-obkbors-6/+20
Retagging: do not retag 'raw reborrows' When doing `&raw const (*raw_ptr).field`, we do not want any retagging; the original provenance should be fully preserved. Fixes https://github.com/rust-lang/miri/issues/1608 Test added by https://github.com/rust-lang/miri/pull/1614 Not sure whom to ask for review on this... `@oli-obk` can you have a look? Or maybe highfive makes a good choice.^^
2020-11-02revert #75443 update mir validatorBastian Kauschke-75/+21
2020-11-01Corrected suggestion for generic parameters in `function_item_references` lintAyrton-18/+36
This lint was incorrectly suggesting casting a function to a pointer without specifying generic type parameters or const generics. This would cause a compiler error since the missing parameters couldn't be inferred. This commit fixed the suggestion and added a few tests with generics.
2020-11-02inliner: Remove redundant loopTomasz Miąsko-77/+60
No functional changes intended.
2020-10-31Assert that locals have storage when usedTomasz Miąsko-12/+21
The validator in visit_local asserts that local has a stroage when used, but visit_local is never called so validation is ineffective. Use super_statement and super_terminator to ensure that locals are visited.
2020-10-31Retagging: do not retag 'raw reborrows'Ralf Jung-6/+20
2020-10-29Link to pass docs from NRVO module docsCamelid-0/+2
2020-10-30validator: Extend aliasing check to a call terminatorTomasz Miąsko-5/+40
2020-10-28Rollup merge of #78351 - RalfJung:validity-unsafe-cell, r=oli-obkDylan DPC-7/+7
Move "mutable thing in const" check from interning to validity This moves the check for mutable things (such as `UnsafeCell` or `&mut`) in a`const` from interning to validity. That means we can give more targeted error messages (pointing out *where* the problem lies), and we can simplify interning a bit. Also fix the interning mode used for promoteds in statics. r? @oli-obk