about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2020-11-19Rollup merge of #79193 - tmiasko:revert-78969-normalize, r=davidtwcoDylan DPC-7/+8
Revert #78969 "Normalize function type during validation" Closes #79066. Reopens #78442.
2020-11-19Rollup merge of #79117 - cjkenn:mir-fuel, r=oli-obkDylan DPC-11/+59
add optimization fuel checks to some mir passes Fixes #77402 Inserts a bunch of calls to `consider_optimizing`. Note that `consider_optimizing` is the method that actually decrements the fuel count, so the point at which it's called is when the optimization takes place, from a fuel perspective. This means that where we call it has some thought behind it: 1. We probably don't want to decrement the fuel count before other simple checks, otherwise we count an optimization as being performed even if nothing was mutated (ie. it returned early). 2. In cases like `InstCombine`, where we gather optimizations in a pass and then mutate values, we probably would rather skip the gathering pass for performance reasons rather than skip the mutations afterwards.
2020-11-19Rollup merge of #79101 - tmiasko:lower-func-type, r=jonas-schievinkDylan DPC-8/+4
Don't special case constant operands when lowering intrinsics
2020-11-19remove check from const promotioncjkenn-4/+0
2020-11-19Revert "Normalize function type during validation"Tomasz Miąsko-2/+0
This reverts commit d486bfcbff107e8a6769e00c59d02b13c664b6ee.
2020-11-19Revert "Always use param_env_reveal_all_normalized in validator"Tomasz Miąsko-7/+10
This reverts commit 99be78d135e73197e04221c139a219ea6436e72a.
2020-11-18move checks later into optimization passescjkenn-16/+17
2020-11-18move fuel checks to later points in instcombine and const_prop, add opt ↵cjkenn-19/+26
level flag to test
2020-11-17Rollup merge of #79027 - tmiasko:inline-always-live-locals, r=oli-obkMara Bos-0/+39
Limit storage duration of inlined always live locals Closes #76375.
2020-11-16add optimization fuel checks to some mir passescjkenn-3/+47
2020-11-16compiler: fold by valueBastian Kauschke-4/+4
2020-11-16Don't special case constant operands when lowering intrinsicsTomasz Miąsko-8/+4
2020-11-15Only go through the body if something can be optimizedSimon Vandel Sillesen-2/+13
2020-11-15Do not call super_rvalue if not neededSimon Vandel Sillesen-2/+2
2020-11-15Rollup merge of #79036 - cjgillot:steal, r=oli-obkJonas Schievink-1/+1
Move Steal to rustc_data_structures.
2020-11-15Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-schievinkJonas Schievink-0/+7
Validate that locals have a corresponding `LocalDecl` Fixes #73356.
2020-11-15Rollup merge of #77802 - jyn514:bootstrap-specific, r=nikomatsakisJonas Schievink-2/+1
Allow making `RUSTC_BOOTSTRAP` conditional on the crate name Motivation: This came up in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Require.20users.20to.20confirm.20they.20know.20RUSTC_.E2.80.A6.20compiler-team.23350/near/208403962) for https://github.com/rust-lang/compiler-team/issues/350. See also https://github.com/rust-lang/cargo/pull/6608#issuecomment-458546258; this implements https://github.com/rust-lang/cargo/issues/6627. The goal is for this to eventually allow prohibiting setting `RUSTC_BOOTSTRAP` in build.rs (https://github.com/rust-lang/cargo/issues/7088). ## User-facing changes - `RUSTC_BOOTSTRAP=1` still works; there is no current plan to remove this. - Things like `RUSTC_BOOTSTRAP=0` no longer activate 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. - `RUSTC_BOOTSTRAP=x` will enable nightly features only for crate `x`. - `RUSTC_BOOTSTRAP=x,y` will enable nightly features only for crates `x` and `y`. ## Implementation changes 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` I'm not sure whether this counts as T-compiler or T-lang; _technically_ RUSTC_BOOTSTRAP is an implementation detail, but it's been used so much it seems like this counts as a language change too. r? `@joshtriplett` cc `@Mark-Simulacrum` `@hsivonen`
2020-11-15Rollup merge of #78969 - tmiasko:normalize, r=davidtwcoDylan DPC-8/+7
Normalize function type during validation During inlining, the callee body is normalized and has types revealed, but some of locals corresponding to the arguments might come from the caller body which is not. As a result the caller body does not pass validation without additional normalization. Closes #78442.
2020-11-15Rollup merge of #78966 - tmiasko:inline-never, r=oli-obkDylan DPC-22/+19
Never inline C variadics, cold functions, functions with incompatible attributes ... ... and fix generator inlining. Closes #67863. Closes #78859.
2020-11-15Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tmandryDylan DPC-25/+765
Added some unit tests as requested 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 r? ```````@tmandry``````` FYI: ```````@wesleywiser``````` This is pretty much self contained, but depending on feedback and timing, I may have a chance to add a few more unit tests requested against `counters.rs`. I'm looking at those now.
2020-11-15Limit storage duration of inlined always live localsTomasz Miąsko-0/+39
2020-11-14Auto merge of #79049 - tmiasko:lower-intrinsics, r=jonas-schievinkbors-0/+110
Lower intrinsics calls: forget, size_of, unreachable, wrapping_* This allows constant propagation to evaluate `size_of` and `wrapping_*`, and unreachable propagation to propagate a call to `unreachable`. The lowering is performed as a MIR optimization, rather than during MIR building to preserve the special status of intrinsics with respect to unsafety checks and promotion. Currently enabled by default to determine the performance impact (no significant impact expected). In practice only useful when combined with inlining since intrinsics are rarely used directly (with exception of `unreachable` and `discriminant_value` used by built-in derive macros). Closes #32716.
2020-11-14Move Steal to rustc_data_structures.Camille GILLOT-1/+1
2020-11-14Lower intrinsics calls: forget, size_of, unreachable, wrapping_*Tomasz Miąsko-0/+110
This allows constant propagation to evaluate `size_of` and `wrapping_*`, and unreachable propagation to propagate a call to `unreachable`. The lowering is performed as a MIR optimization, rather than during MIR building to preserve the special status of intrinsics with respect to unsafety checks and promotion.
2020-11-13Validate that locals have a corresponding `LocalDecl`Camelid-0/+7
2020-11-13Addressed feedbackRich Kadel-11/+10
2020-11-12Added a unit test for BcbCountersRich Kadel-102/+188
Restructured the code a little, to allow getting both the mir::Body and coverage graph.
2020-11-12Always use param_env_reveal_all_normalized in validatorTomasz Miąsko-10/+7
2020-11-12Normalize function type during validationTomasz Miąsko-0/+2
During inlining, the callee body is normalized and has types revealed, but some of locals corresponding to the arguments might come from the caller body which is not. As a result the caller body does not pass validation without additional normalization.
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-7/+8
2020-11-12fix tests and formattingVishnunarayan K I-2/+10
2020-11-12add error_occured field to ConstQualifs, fix #76064Vishnunarayan K I-4/+6
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-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.