about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2020-11-26Remove ForeignMod struct.Camille GILLOT-1/+1
2020-11-26Store ForeignItem in a side table.Camille GILLOT-0/+2
2020-11-25Fixup compiler docsCamelid-12/+12
The sublist was being rendered as a code block because it was indented 4 spaces.
2020-11-23Rollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obkJonas Schievink-4/+36
Allow using generic trait methods in `const fn` Next step for https://github.com/rust-lang/rust/issues/67792, this now also allows code like the following: ```rust struct S; impl const PartialEq for S { fn eq(&self, _: &S) -> bool { true } } const fn equals_self<T: PartialEq>(t: &T) -> bool { *t == *t } pub const EQ: bool = equals_self(&S); ``` This works by threading const-ness of trait predicates through trait selection, in particular through `ParamCandidate`, and exposing it in the resulting `ImplSource`. Since this change makes two bounds `T: Trait` and `T: ?const Trait` that only differ in their const-ness be treated like different bounds, candidate winnowing has been changed to drop the `?const` candidate in favor of the const candidate, to avoid ambiguities when both a const and a non-const bound is present.
2020-11-23Rollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievinkJonas Schievink-7/+1
MIR visitor: Don't treat debuginfo field access as a use of the struct Fixes #77454. r? `@jonas-schievink`
2020-11-22Add comment and remove obsolete special caseCamelid-7/+1
2020-11-22refactor unsafety checking of placesRalf Jung-75/+84
2020-11-22const fn: allow use of trait impls from boundsJonas Schievink-4/+36
2020-11-21Rollup merge of #79272 - tmiasko:array-clone, r=jonas-schievinkDylan DPC-6/+13
Support building clone shims for arrays with generic size Fixes #79269.
2020-11-21List all variants of TyKindNgo Iok Ui-1/+20
2020-11-21Support building clone shims for arrays with generic sizeTomasz Miąsko-6/+13
2020-11-20Exhaustively match in variant count instrinsicNgo Iok Ui-7/+10
2020-11-20improve formattingRalf Jung-4/+8
2020-11-20adjust union access unsafety check logic to take into account Deref and the ↵Ralf Jung-15/+20
actual type of the assignment
2020-11-20consider assignments of union field of ManuallyDrop type safeRalf Jung-25/+28
2020-11-20Auto merge of #79192 - tmiasko:naked-noinline, r=oli-obkbors-0/+5
Never inline naked functions The `#[naked]` attribute disabled prologue / epilogue emission for the function and it is responsibility of a developer to provide them. The compiler is no position to inline such functions correctly. Disable inlining of naked functions at LLVM and MIR level. Closes #60919.
2020-11-20Never inline naked functionsTomasz Miąsko-0/+5
The `#[naked]` attribute disabled prologue / epilogue emission for the function and it is responsibility of a developer to provide them. The compiler is no position to inline such functions correctly. Disable inlining of naked functions at LLVM and MIR level.
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-17Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obkbors-7/+11
Introduce `TypeVisitor::BreakTy` Implements MCP rust-lang/compiler-team#383. r? `@ghost` cc `@lcnr` `@oli-obk` ~~Blocked on FCP in rust-lang/compiler-team#383.~~
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-17Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakisbors-13/+14
RFC-2229: Implement Precise Capture Analysis ### This PR introduces - Feature gate for RFC-2229 (incomplete) `capture_disjoint_field` - Rustc Attribute to print out the capture analysis `rustc_capture_analysis` - Precise capture analysis ### Description of the analysis 1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat) 2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout. 3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list. Check rust-lang/project-rfc-2229#9 for more detailed examples. 4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing. ### Known issues - Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression. ### Testing We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762 ### Thanks This has been slowly in the works for a while now. I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us. Closes rust-lang/project-rfc-2229#7 Closes rust-lang/project-rfc-2229#9 Closes rust-lang/project-rfc-2229#6 Closes rust-lang/project-rfc-2229#19 r? `@nikomatsakis`
2020-11-16add optimization fuel checks to some mir passescjkenn-3/+47
2020-11-16compiler: fold by valueBastian Kauschke-44/+44
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-14Set the default `BreakTy` to `!`LeSeulArtichaut-0/+4
2020-11-14Introduce `TypeVisitor::BreakTy`LeSeulArtichaut-7/+7
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.