about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2020-09-22cleanup cfg after optimizationSimon Vandel Sillesen-0/+9
2020-09-22The optimization should also apply for DropAndReplaceSimon Vandel Sillesen-1/+2
2020-09-22Get LocalDefId from source instead of passing inSimon Vandel Sillesen-11/+3
2020-09-22Suggestion from reviewSimon Vandel Sillesen-1/+1
Co-authored-by: Andreas Jonson <andjo403@users.noreply.github.com>
2020-09-22MIR pass to remove unneeded drops on types not needing dropSimon Vandel Sillesen-0/+59
This is heavily dependent on MIR inlining running to actually see the drop statement
2020-09-22Fix dest prop miscompilation around referencesJonas Schievink-1/+1
2020-09-22Use correct feature gate for unsizing castsDylan MacKenzie-5/+1
2020-09-22Replace missing commentDylan MacKenzie-0/+2
2020-09-22Use the same name everywhere for `is_const_stable_const_fn`Dylan MacKenzie-2/+4
2020-09-22Update const-checker to replicate `qualify_min_const_fn`Dylan MacKenzie-73/+268
2020-09-22Add structured errors for `qualify_min_const_fn` checksDylan MacKenzie-3/+220
2020-09-22Allow errors to abort const checking when emittedDylan MacKenzie-4/+22
This is a hack for parity with `qualify_min_const_fn`, which only emitted a single error.
2020-09-22Return `true` if `check_const` emits an errorDylan MacKenzie-7/+11
2020-09-22Add const-stability helpersDylan MacKenzie-10/+45
2020-09-22Useful derives on `ops::Status`Dylan MacKenzie-0/+1
2020-09-21Rollup merge of #76888 - matthiaskrgr:clippy_single_match_2, r=Dylan-DPCecstatic-morse-11/+5
use if let instead of single match arm expressions use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match)
2020-09-21Rollup merge of #76807 - ecstatic-morse:const-checking-staged-api, r=oli-obkecstatic-morse-65/+109
Use const-checking to forbid use of unstable features in const-stable functions First step towards #76618. Currently this code isn't ever hit because `qualify_min_const_fn` runs first and catches pretty much everything. One exception is `const_precise_live_drops`, which does not use the newly added code since it runs as part of a separate pass. Also contains some unrelated refactoring, which is split into separate commits. r? @oli-obk
2020-09-21Add optimization to avoid load of addressSimon Vandel Sillesen-2/+115
2020-09-20Auto merge of #75119 - simonvandel:early-otherwise, r=oli-obkbors-0/+341
New MIR optimization pass to reduce branches on match of tuples of enums Fixes #68867 by adding a new pass that turns something like ```rust let x: Option<()>; let y: Option<()>; match (x,y) { (Some(_), Some(_)) => {0}, _ => {1} } ``` into something like ```rust let x: Option<()>; let y: Option<()>; let discriminant_x = // get discriminant of x let discriminant_y = // get discriminant of x if discriminant_x != discriminant_y {1} else {0} ``` The opt-diffs still have the old basic blocks like ``` bb3: { _8 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:21:21: 21:30 switchInt(move _8) -> [1_isize: bb7, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:21:21: 21:30 } bb4: { _9 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:22:23: 22:34 switchInt(move _9) -> [2_isize: bb8, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:22:23: 22:34 } bb5: { _10 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:23:23: 23:34 switchInt(move _10) -> [3_isize: bb9, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:23:23: 23:34 } ``` These do get removed on later passes. I'm not sure if I should include those passes in the test to make it clear?
2020-09-20Rollup merge of #76890 - matthiaskrgr:matches_simpl, r=lcnrRalf Jung-3/+2
use matches!() macro for simple if let conditions
2020-09-20enable on mir-opt-level=1 to test perfSimon Vandel Sillesen-1/+1
2020-09-20add cleanup of cfgSimon Vandel Sillesen-0/+10
2020-09-20insert storageDead for not equal tempSimon Vandel Sillesen-11/+27
2020-09-20correct commentSimon Vandel Sillesen-1/+1
2020-09-20Update src/librustc_mir/transform/early_otherwise_branch.rsSimon Vandel Sillesen-1/+1
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-09-20New MIR optimization pass to reduce branches on match of tuples of enumsSimon Vandel Sillesen-0/+315
2020-09-20use if let instead of single match arm expressions to compact code and ↵Matthias Krüger-11/+5
reduce nesting (clippy::single_match)
2020-09-20Auto merge of #76411 - RalfJung:promote-in-const-fn, r=ecstatic-morsebors-26/+35
Some promotion cleanup Based on top of both https://github.com/rust-lang/rust/pull/75502 and https://github.com/rust-lang/rust/pull/75585, this does some cleanup of the promotion code. The last 2 commits are new. * Remove the remaining cases where `const fn` is treated different from `fn`. This means no longer promoting ptr-to-int casts, raw ptr operations, and union field accesses in `const fn` -- or anywhere, for that matter. These are all unstable in const-context so this should not break any stable code. Fixes https://github.com/rust-lang/rust/issues/75586. * ~~Promote references to statics even outside statics (i.e., in functions) for consistency.~~ * Promote `&mut []` everywhere, not just in non-`const` functions, for consistency. * Explain why we do not promote deref's of statics outside statics. ~~(This is the only remaining direct user of `const_kind`.)~~ This can only land once the other two PRs land; I am mostly putting this up already because I couldn't wait ;) and to get some feedback from `@rust-lang/wg-const-eval` .
2020-09-20Auto merge of #72632 - jonas-schievink:dest-prop, r=oli-obkbors-0/+1065
Implement a generic Destination Propagation optimization on MIR This takes the work that was originally started by `@eddyb` in https://github.com/rust-lang/rust/pull/47954, and then explored by me in https://github.com/rust-lang/rust/pull/71003, and implements it in a general (ie. not limited to acyclic CFGs) and dataflow-driven way (so that no additional infrastructure in rustc is needed). The pass is configured to run at `mir-opt-level=2` and higher only. To enable it by default, some followup work on it is still needed: * Performance needs to be evaluated. I did some light optimization work and tested against `tuple-stress`, which caused trouble in my last attempt, but didn't go much in depth here. * We can also enable the pass only at `opt-level=2` and higher, if it is too slow to run in debug mode, but fine when optimizations run anyways. * Debuginfo needs to be fixed after locals are merged. I did not look into what is required for this. * Live ranges of locals (aka `StorageLive` and `StorageDead`) are currently deleted. We either need to decide that this is fine, or if not, merge the variable's live ranges (or remove these statements entirely – https://github.com/rust-lang/rust/issues/68622). Some benchmarks of the pass were done in https://github.com/rust-lang/rust/pull/72635.
2020-09-19Add assertion for len of vecsSimon Vandel Sillesen-3/+4
2020-09-19fix some commentsRalf Jung-6/+7
2020-09-19never promote non-const operations; revert STATIC promotion changeRalf Jung-4/+14
2020-09-19fix doc commentRalf Jung-4/+4
2020-09-19cleanup promotion const_kind checksRalf Jung-30/+28
in particular allow a few more promotions for consistency when they were already allowed in other contexts
2020-09-19Fix #76803Simon Vandel Sillesen-23/+33
Check that the variant index matches the target value from the SwitchInt we came from
2020-09-19Rollup merge of #75502 - ecstatic-morse:implicit-promotion-in-const-fn, ↵Ralf Jung-1/+8
r=RalfJung Use implicit (not explicit) rules for promotability by default in `const fn` For crater run. See https://github.com/rust-lang/const-eval/pull/54#discussion_r469995552. cc #75586
2020-09-18Clarify FIXMEJonas Schievink-2/+3
2020-09-18Return `Place` by valueJonas Schievink-2/+2
2020-09-18Move inner items outsideJonas Schievink-144/+144
2020-09-18Fix rebase falloutJonas Schievink-5/+6
2020-09-18Limit block countJonas Schievink-0/+14
2020-09-18Fix rebase falloutJonas Schievink-7/+13
2020-09-18Properly inherit conflicts when merging localsJonas Schievink-53/+60
2020-09-18More loggingJonas Schievink-21/+59
2020-09-18Record intra-statement/terminator conflictsJonas Schievink-22/+206
Some MIR statements and terminators have an (undocumented...) invariant that some of their input and outputs must not overlap. This records conflicts between locals used in these positions.
2020-09-18perf: bail out when there's >500 candidate localsJonas Schievink-6/+24
2020-09-18perf: only calculate conflicts for candidatesJonas Schievink-12/+39
2020-09-18perf: walk liveness backwards in Conflicts::buildJonas Schievink-24/+39
2020-09-18Fix dataflow assert errorsJonas Schievink-3/+17
2020-09-18Implement a destination propagation passJonas Schievink-0/+740