about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2021-03-17remove unnecessary and ineffective cachingErik Desjardins-22/+9
2021-03-18Rollup merge of #83080 - tmiasko:inline-coverage, r=wesleywiserDylan DPC-18/+32
Make source-based code coverage compatible with MIR inlining When codegenning code coverage use the instance that coverage data was originally generated for, to ensure basic level of compatibility with MIR inlining. Fixes #83061
2021-03-16move to separate pass, cache layoutsErik Desjardins-26/+52
2021-03-16Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasperbors-73/+91
Implement (but don't use) valtree and refactor in preparation of use This PR does not cause any functional change. It refactors various things that are needed to make valtrees possible. This refactoring got big enough that I decided I'd want it reviewed as a PR instead of trying to make one huge PR with all the changes. cc `@rust-lang/wg-const-eval` on the following commits: * 2027184 implement valtree * eeecea9 fallible Scalar -> ScalarInt * 042f663 ScalarInt convenience methods cc `@eddyb` on ef04a6d cc `@rust-lang/wg-mir-opt` for cf1700c (`mir::Constant` can now represent either a `ConstValue` or a `ty::Const`, and it is totally possible to have two different representations for the same value)
2021-03-15remove assignments to ZST placesErik Desjardins-1/+26
2021-03-15revert changes from #83118 to mark zst return place as unusedErik Desjardins-52/+27
2021-03-15Make source-based code coverage compatible with MIR inliningTomasz Miąsko-18/+32
When codegenning code coverage use the instance that coverage data was originally generated for, to ensure basic level of compatibility with MIR inlining.
2021-03-15s/ConstantSource/ConstantKind/Oli Scherer-6/+6
2021-03-14remove unnecessary conditionErik Desjardins-3/+1
`_local` isn't visited in `_local = <rhs>` statements in the situation we care about
2021-03-13Move ZST check inside UsedLocalsSimon Vandel Sillesen-50/+53
2021-03-13Extend SimplifyLocals to remove ZST writesSimon Vandel Sillesen-3/+27
2021-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-73/+91
2021-03-10Rename Option::get_or_insert_defaultCameron Steffen-1/+2
2021-03-10Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtriplettYuki Okushi-4/+1
Add Option::get_or_default Tracking issue: #82901 The original issue is #55042, which was closed, but for an invalid reason (see discussion there). Opening this to reconsider (I hope that's okay). It seems like the only gap for `Option` being "entry-like". I ran into a need for this method where I had a `Vec<Option<MyData>>` and wanted to do `vec[n].get_or_default().my_data_method()`. Using an `Option` as an inner component of a data structure is probably where the need for this will normally arise.
2021-03-10Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, ↵Yuki Okushi-3/+2
r=nikomatsakis Stabilize `unsafe_op_in_unsafe_fn` lint This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896. Tracking issue: #71668 r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung``` # Stabilization report This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`. ## Summary Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside. The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block. For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level. For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md) ### Example ```rust // An `unsafe fn` for demonstration purposes. // Calling this is an unsafe operation. unsafe fn unsf() {} // #[allow(unsafe_op_in_unsafe_fn)] by default, // the behavior of `unsafe fn` is unchanged unsafe fn allowed() { // Here, no `unsafe` block is needed to // perform unsafe operations... unsf(); // ...and any `unsafe` block is considered // unused and is warned on by the compiler. unsafe { unsf(); } } #[warn(unsafe_op_in_unsafe_fn)] unsafe fn warned() { // Removing this `unsafe` block will // cause the compiler to emit a warning. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } #[deny(unsafe_op_in_unsafe_fn)] unsafe fn denied() { // Removing this `unsafe` block will // cause a compilation error. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } ```
2021-03-09Clean up todoskadmin-1/+43
Also add some span_bugs where it is unreachable
2021-03-09Switch to changing cp_non_overlap in tformkadmin-2/+23
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09Update craneliftkadmin-1272/+0
2021-03-09Update interpret stepkadmin-0/+2
2021-03-09Update match brancheskadmin-0/+1277
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
2021-03-08Use Option::get_or_defaultCameron Steffen-4/+1
2021-03-08Rollup merge of #82684 - tmiasko:dest-prop, r=jonas-schievinkDylan DPC-0/+5
Disable destination propagation on all mir-opt-levels The new `// compile-flags: -Zunsound-mir-opts` are inserted without an extra newline to avoid introducing a large mir-opt diff.
2021-03-08Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelixbors-17/+22
Test the effect of shrinking the size of Rvalue by 16 bytes r? `@ghost`
2021-03-06Disable destination propagation on all mir-opt-levelsTomasz Miąsko-0/+5
2021-03-05Bump one missing mir_opt_levelSantiago Pastorino-1/+1
2021-03-05Bump all mir_opt_level 2 to 3Santiago Pastorino-7/+7
2021-03-05Bump all mir_opt_level 3 to 4Santiago Pastorino-7/+7
2021-03-05For better consistency change mir_opt_level <= 1 to < 2Santiago Pastorino-2/+2
2021-03-05Extract mir_opt_level to a method and use Option to be able to know if the ↵Santiago Pastorino-13/+13
value is provided or not
2021-03-05Shrink the size of Rvalue by 16 bytesOli Scherer-17/+22
2021-03-04Auto merge of #81114 - bugadani:generator, r=estebankbors-10/+11
Box generator-related Body fields Might save some memory on functions that aren't generators.
2021-03-02Rollup merge of #82376 - tmiasko:inline-options, r=oli-obkYuki Okushi-17/+22
Add option to enable MIR inlining independently of mir-opt-level Add `-Zinline-mir` option that enables MIR inlining independently of the current MIR opt level. The primary use-case is enabling MIR inlining on the default MIR opt level. Turn inlining thresholds into optional values to make it possible to configure different defaults depending on the current mir-opt-level (although thresholds are yet to be used in such a manner).
2021-03-02Rollup merge of #80734 - abonander:ab/issue-66693, r=oli-obkGuillaume Gomez-2/+22
check that first arg to `panic!()` in const is `&str` closes #66693 ~~TODO: regression test~~ cc `@RalfJung` for error message wording
2021-03-01check that first arg to `panic!()` in const is `&str`Austin Bonander-2/+22
2021-03-01Box generator-related Body fieldsDániel Buga-10/+11
2021-02-28Remove storage markers if they won't be used during code generationTomasz Miąsko-0/+27
The storage markers constitute a substantial portion of all MIR statements. At the same time, for builds without any optimizations, the storage markers have no further use during and after MIR optimization phase. If storage markers are not necessary for code generation, remove them.
2021-02-27Use optional values for inlining thresholdsTomasz Miąsko-2/+2
Turn inlining threshold into optional values to make it possible to configure different defaults depending on the current mir-opt-level.
2021-02-27Add option enabling MIR inlining independently of mir-opt-levelTomasz Miąsko-15/+20
2021-02-27Rollup merge of #82482 - tmiasko:small-cycles, r=varkorDylan DPC-7/+4
Use small hash set in `mir_inliner_callees` Use small hash set in `mir_inliner_callees` to avoid temporary allocation when possible and quadratic behaviour for large number of callees.
2021-02-26Rollup merge of #82491 - tmiasko:i, r=lcnrGuillaume Gomez-124/+146
Consider inexpensive inlining criteria first Refactor inlining decisions so that inexpensive criteria are considered first: 1. Based on code generation attributes. 2. Based on MIR availability (examines call graph). 3. Based on MIR body.
2021-02-25Auto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obkbors-2/+2
all InterpError allocate now, so adjust alloc-error-check Cc https://github.com/rust-lang/rust/pull/82116#discussion_r578310770 r? `@oli-obk`
2021-02-24Auto merge of #82159 - BoxyUwU:uwu, r=varkorbors-3/+3
Use correct param_env in conservative_is_privately_uninhabited cc `@lcnr` r? `@varkor` since this is your FIXME that was removed ^^
2021-02-24Auto merge of #80475 - simonvandel:fix-77355, r=oli-obkbors-18/+145
New mir-opt pass to simplify gotos with const values (reopening #77486) Reopening PR #77486 Fixes #77355 This pass optimizes the following sequence ```rust bb2: { _2 = const true; goto -> bb3; } bb3: { switchInt(_2) -> [false: bb4, otherwise: bb5]; } ``` into ```rust bb2: { _2 = const true; goto -> bb5; } ```
2021-02-24Use small hash set in `mir_inliner_callees`Tomasz Miąsko-7/+4
Use small hash set in `mir_inliner_callees` to avoid temporary allocation when possible and quadratic behaviour for large number of callees.
2021-02-24Consider inexpensive inlining criteria firstTomasz Miąsko-124/+146
Refactor inlining decisions so that inexpensive criteria are considered first: 1. Based on code generation attributes. 2. Based on MIR availability (examines call graph). 3. Based on MIR body.
2021-02-23yeetEllen-3/+3
2021-02-23Rollup merge of #82091 - henryboisdequin:use-place-ref-more, r=RalfJungDylan DPC-13/+13
use PlaceRef abstractions more consistently Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715) Associated issue: #80647 r? ```@RalfJung```
2021-02-22New mir-opt pass to simplify gotos with const valuesSimon Vandel Sillesen-18/+145
Fixes #77355
2021-02-22Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obkbors-3/+207
MIR-OPT: Pass to deduplicate blocks This pass finds basic blocks that are completely equal, and replaces all uses with just one of them. ```bash $ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log ... $ cat log | wc -l 23875 ```
2021-02-21New pass to deduplicate blocksSimon Vandel Sillesen-1/+196