about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2020-11-12Never inline C variadic functionsTomasz Miąsko-0/+5
2020-11-12Fix generator inlining by checking for rust-call abi and spread argTomasz Miąsko-12/+14
2020-11-12Remove check for impossible conditionTomasz Miąsko-6/+0
The callee body is already transformed; the condition is always false.
2020-11-12Never inline cold functionsTomasz Miąsko-2/+2
The information about cold attribute is lost during inlining, Avoid the issue by never inlining cold functions.
2020-11-12Never inline when `no_sanitize` attributes differTomasz Miąsko-5/+1
The inliner looks if a sanitizer is enabled before considering `no_sanitize` attribute as possible source of incompatibility. The MIR inlining could happen in a crate with sanitizer disabled, but code generation in a crate with sanitizer enabled, thus the attribute would be incorrectly ignored. To avoid the issue never inline functions with different `no_sanitize` attributes.
2020-11-12review commentsVishnunarayan K I-10/+10
2020-11-12check mir exists before validation; fix testsVishnunarayan K I-0/+7
2020-11-12fix tests and formattingVishnunarayan K I-3/+11
2020-11-12add error_occured field to ConstQualifs, fix #76064Vishnunarayan K I-4/+11
2020-11-12add different color for cleanup nodes in dark modeVishnunarayan K I-1/+2
2020-11-11Overcome Sync issues with non-parallel compilerRich Kadel-9/+10
Per Mark's recommendation at: https://github.com/rust-lang/rust/pull/78963#issuecomment-725790071
2020-11-11Added some unit tests as requestedRich Kadel-22/+676
As discussed in PR #78267, for example: * https://github.com/rust-lang/rust/pull/78267#discussion_r515404722 * https://github.com/rust-lang/rust/pull/78267#discussion_r515405958
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-10Changed unwrap_or to unwrap_or_else in some places.Nicholas-Baron-1/+1
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
2020-11-10Initial work for doing minimum capture analysis for RFC-2229Aman Arora-13/+14
Co-authored-by: Chris Pardy <chrispardy36@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-11-10Rollup merge of #78887 - camelid:dataflow-state-decl, r=jonas-schievinkJonas Schievink-1/+8
Add comments to explain memory usage optimization Add explanatory comments so that people understand that it's just an optimization and doesn't affect behavior.
2020-11-10Rollup merge of #78875 - petrochenkov:cleantarg, r=Mark-SimulacrumJonas Schievink-1/+1
rustc_target: Further cleanup use of target options Follow up to https://github.com/rust-lang/rust/pull/77729. Implements items 2 and 4 from the list in https://github.com/rust-lang/rust/pull/77729#issue-500228243. The first commit collapses uses of `target.options.foo` into `target.foo`. The second commit renames some target options to avoid tautology: `target.target_endian` -> `target.endian` `target.target_c_int_width` -> `target.c_int_width` `target.target_os` -> `target.os` `target.target_env` -> `target.env` `target.target_vendor` -> `target.vendor` `target.target_family` -> `target.os_family` `target.target_mcount` -> `target.mcount` r? `@Mark-Simulacrum`
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-09Add comments to explain memory usage optimizationCamelid-1/+8
2020-11-10formattingVishnunarayan K I-1/+1
2020-11-09Rollup merge of #78580 - tmiasko:inline-loop, r=oli-obkDylan DPC-123/+114
inliner: Break inlining cycles Keep track of all instances inlined so far. When examining a new call sites from an inlined body, skip those where callee had been inlined already to avoid potential inlining cycles. Fixes #78573.
2020-11-09Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-SimulacrumDylan DPC-43/+161
Improve lifetime name annotations for closures & async functions * Don't refer to async functions as "generators" in error output * Where possible, emit annotations pointing exactly at the `&` in the return type of closures (when they have explicit return types) and async functions, like we do for arguments. Addresses #74072, but I wouldn't call that *closed* until annotations are identical for async and non-async functions. * Emit a better annotation when the lifetime doesn't appear in the full name type, which currently happens for opaque types like `impl Future`. Addresses #74497, but further improves could probably be made (why *doesn't* it appear in the type as `impl Future + '1`?) This is included in the same PR because the changes to `give_name_if_anonymous_region_appears_in_output` would introduce ICE otherwise (it would return `None` in cases where it didn't previously, which then gets `unwrap`ped)
2020-11-09update gsgdtVishnunarayan K I-6/+5
2020-11-09write to a String instead to reduce churnVishnunarayan K I-14/+21
2020-11-09make MIR graphviz generation use gsgdtVishnunarayan K I-147/+96
gsgdt [https://crates.io/crates/gsgdt] is a crate which provides an interface for stringly typed graphs. It also provides generation of graphviz dot format from said graph.
2020-11-09use RegionNameHighlight for async fn and closure returnsSNCPlay42-34/+118
2020-11-09Rollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obkDylan DPC-24/+16
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-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-08Collapse all uses of `target.options.foo` into `target.foo`Vadim Petrochenkov-1/+1
with an eye on merging `TargetOptions` into `Target`. `TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-08Auto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-sebors-31/+40
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-07Allow making `RUSTC_BOOTSTRAP` conditional on the crate nameJoshua Nelson-2/+1
The main change is that `UnstableOptions::from_environment` now requires an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how. Other major changes: - Added `Session::is_nightly_build()`, which uses the `crate_name` of the session - Added `nightly_options::match_is_nightly_build`, a convenience method for looking up `--crate-name` from CLI arguments. `Session::is_nightly_build()`should be preferred where possible, since it will take into account `#![crate_name]` (I think). - Added `unstable_features` to `rustdoc::RenderOptions` There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no longer active nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway. - Add tests Check against `Cheat`, not whether nightly features are allowed. Nightly features are always allowed on the nightly channel. - Only call `is_nightly_build()` once within a function - Use booleans consistently for rustc_incremental Sessions can't be passed through threads, so `read_file` couldn't take a session. To be consistent, also take a boolean in `write_file_header`.
2020-11-07use single char patterns for split() (clippy::single_char_pattern)Matthias Krüger-5/+5
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-1275/+3819
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-2/+2
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