about summary refs log tree commit diff
path: root/src/librustc_mir/transform/mod.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-578/+0
2020-08-29New pass to optimize `if`conditions on integrals to switches on the integerSimon Vandel Sillesen-0/+2
Fixes #75144
2020-08-20Auto merge of #75562 - oli-obk:const_prop_no_aggregates, r=wesleywiserbors-23/+51
Check that we don't use `Rvalue::Aggregate` after the deaggregator fixes #75481 r? @wesleywiser cc @RalfJung (modified the validator)
2020-08-18Address review commentsOliver Scherer-2/+2
2020-08-18mir building: fix some commentsRalf Jung-1/+2
2020-08-18Validate the MIR of all optimizations in the mir-opt directoryOliver Scherer-21/+49
2020-08-13Update w/ comments from olikadmin-1/+1
This also updates a check to ensure that this is only applied to bools
2020-08-13Update to actually use transformkadmin-0/+1
2020-08-13First iteration of simplify match brancheskadmin-0/+1
2020-08-11move Deaggregate pass to post_borrowck_cleanupRalf Jung-8/+3
2020-07-28Refactor MIR coverage instrumentationRich Kadel-9/+13
Lays a better foundation for injecting more counters in each function.
2020-07-25Fixed coverage map issues; better aligned with LLVM APIsRich Kadel-2/+2
Found some problems with the coverage map encoding when testing with more than one counter per function. While debugging, I realized some better ways to structure the Rust implementation of the coverage mapping generator. I refactored somewhat, resulting in less code overall, expanded coverage of LLVM Coverage Map capabilities, and much closer alignment with LLVM data structures, APIs, and naming. This should be easier to follow and easier to maintain.
2020-07-21fetch -> lookupBastian Kauschke-3/+3
2020-07-21`try_update` -> `try_upgrade`Bastian Kauschke-3/+3
2020-07-21remove some const arg in ty dep path boilerplateBastian Kauschke-32/+21
2020-07-15unsafety_check_result_for_const_argBastian Kauschke-1/+1
2020-07-15WithOptConstParam::dummy -> WithOptConstParam::unknownBastian Kauschke-6/+6
2020-07-15improve namingBastian Kauschke-31/+39
2020-07-15update promoted_mirBastian Kauschke-8/+4
2020-07-15update const arg queriesBastian Kauschke-24/+24
2020-07-15const generics work!Bastian Kauschke-31/+89
2020-07-15continue mir pipelineBastian Kauschke-9/+16
2020-07-15optimized_mirBastian Kauschke-7/+30
2020-07-15InstanceDef::ItemBastian Kauschke-6/+6
2020-07-09Rollup merge of #74070 - eddyb:forall-tcx-providers, r=nikomatsakisManish Goregaokar-1/+1
Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>. In order to work around normalization-under-HRTB (for `provide!` in `rustc_metadata`), we ended up with this: ```rust struct Providers<'tcx> { type_of: fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>, // ... } ``` But what I initially wanted to do, IIRC, was this: ```rust struct Providers { type_of: for<'tcx> fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>, // ... } ``` This PR moves to the latter, for the simple reason that only the latter allows keeping a `Providers` value, or a subset of its `fn` pointer fields, around in a `static` or `thread_local!`, which can be really useful for custom drivers that override queries. (@jyn514 and I came across a concrete usecase of that in `rustdoc`) The `provide!` macro in `rustc_metadata` is fixed by making the query key/value types available as type aliases under `ty::query::query_{keys,values}`, not just associated types (this is the first commit). r? @nikomatsakis
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-1/+1
2020-07-04ConstCx to LocalDefIdBastian Kauschke-2/+3
2020-06-22moves coverage data computation from pass to queryRich Kadel-7/+2
2020-06-22implemented query for coverage dataRich Kadel-1/+7
This commit adds a query that allows the CoverageData to be pulled from a call on tcx, avoiding the need to change the `codegen_intrinsic_call()` signature (no need to pass in the FunctionCx or any additional arguments. The commit does not change where/when the CoverageData is computed. It's still done in the `pass`, and saved in the MIR `Body`. See discussion (in progress) here: https://github.com/rust-lang/rust/pull/73488#discussion_r443825646
2020-06-15moved instrument_coverage pass, optimized scalar, added FIXMERich Kadel-4/+4
2020-06-15moved to post_borrowck_cleanup & used MirPatchRich Kadel-2/+4
2020-06-15[WIP] injects llvm intrinsic instrprof.increment for coverage reportsRich Kadel-0/+3
This initial version only injects counters at the top of each function. Rust Coverage will require injecting additional counters at each conditional code branch.
2020-06-13Add MIR phase and query for drop elaborationDylan MacKenzie-9/+40
2020-05-26Rollup merge of #72270 - RalfJung:lint-ref-to-packed, r=oli-obkDylan DPC-1/+5
add a lint against references to packed fields Creating a reference to an insufficiently aligned packed field is UB and should be disallowed, both inside and outside of `unsafe` blocks. However, currently there is no stable alternative (https://github.com/rust-lang/rust/issues/64490) so all we do right now is have a future incompatibility warning when doing this outside `unsafe` (https://github.com/rust-lang/rust/issues/46043). This adds an allow-by-default lint. @retep998 suggested this can help early adopters avoid issues. It also means we can then do a crater run where this is deny-by-default as suggested by @joshtriplett. I guess the main thing to bikeshed is the lint name. I am not particularly happy with "packed_references" as it sounds like the packed field has reference type. I chose this because it is similar to "safe_packed_borrows". What about "reference_to_packed" or "unaligned_reference" or so?
2020-05-25Always validate MIR after optimizingJonas Schievink-0/+5
2020-05-25Add a small MIR validation passJonas Schievink-1/+13
2020-05-25add a lint against references to packed fieldsRalf Jung-1/+5
2020-05-16Dumb NRVODylan MacKenzie-0/+2
2020-05-11Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1Wesley Wiser-2/+2
I also added test cases to make sure the optimization can fire on all of these cases: ```rust fn case_1(o: Option<u8>) -> Option<u8> { match o { Some(u) => Some(u), None => None, } } fn case2(r: Result<u8, i32>) -> Result<u8, i32> { match r { Ok(u) => Ok(u), Err(i) => Err(i), } } fn case3(r: Result<u8, i32>) -> Result<u8, i32> { let u = r?; Ok(u) } ``` Without MIR inlining, this still does not completely optimize away the `?` operator because the `Try::into_result()`, `From::from()` and `Try::from_error()` calls still exist. This does move us a bit closer to that goal though because: - We can now run the pass on mir-opt-level=1 - We no longer depend on the copy propagation pass running which is unlikely to stabilize anytime soon.
2020-05-09Rollup merge of #71555 - cjgillot:nameless, r=matthewjasperRalf Jung-3/+2
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-3/+2
2020-05-07Use `hir::ConstContext` instead of local enumsDylan MacKenzie-1/+1
2020-04-28Use the query system to allocate.Camille GILLOT-7/+7
2020-04-28Introduce ArenaStorage.Camille GILLOT-2/+2
2020-04-27Accept `LocalDefId` as key for `mir_validated` querymarmeladema-8/+12
2020-04-27Accept `LocalDefId` as key for `mir_borrowck` querymarmeladema-2/+2
2020-04-27Return a `FxHashSet<LocalDefId>` from `mir_keys` querymarmeladema-7/+8
2020-04-27Use `LocalDefId` in `mir_built` querymarmeladema-3/+7
2020-04-27Use `LocalDefId` in `unsafety_check_result` querymarmeladema-1/+1
2020-04-27Auto merge of #70073 - wesleywiser:mir_opt_level_0, r=oli-obkbors-48/+79
Don't run various MIR optimizations at mir-opt-level=0 Add missing checks for mir-opt-level to non-essential MIR passes. I verified that this can still bootstrap even with these passes disabled. r? @oli-obk cc @RalfJung