diff options
| author | bors <bors@rust-lang.org> | 2022-07-02 11:24:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-02 11:24:17 +0000 |
| commit | 0075bb4fad68e64b6d1be06bf2db366c30bc75e1 (patch) | |
| tree | a5160fdc5cce917dc6bae3cb99277dab7b37e279 /compiler/rustc_middle/src | |
| parent | aedf78e56b2279cc869962feac5153b6ba7001ed (diff) | |
| parent | cbbf06b0cd39dc93033568f1e65f5363cbbdebcd (diff) | |
| download | rust-0075bb4fad68e64b6d1be06bf2db366c30bc75e1.tar.gz rust-0075bb4fad68e64b6d1be06bf2db366c30bc75e1.zip | |
Auto merge of #91743 - cjgillot:enable_mir_inlining_inline_all, r=oli-obk
Enable MIR inlining Continuation of https://github.com/rust-lang/rust/pull/82280 by `@wesleywiser.` #82280 has shown nice compile time wins could be obtained by enabling MIR inlining. Most of the issues in https://github.com/rust-lang/rust/issues/81567 are now fixed, except the interaction with polymorphization which is worked around specifically. I believe we can proceed with enabling MIR inlining in the near future (preferably just after beta branching, in case we discover new issues). Steps before merging: - [x] figure out the interaction with polymorphization; - [x] figure out how miri should deal with extern types; - [x] silence the extra arithmetic overflow warnings; - [x] remove the codegen fulfilment ICE; - [x] remove the type normalization ICEs while compiling nalgebra; - [ ] tweak the inlining threshold.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/instance.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/normalize_erasing_regions.rs | 20 |
2 files changed, 26 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index e8dd179eac1..0e10fe25c10 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -496,12 +496,12 @@ impl<'tcx> Instance<'tcx> { def_id: DefId, substs: ty::SubstsRef<'tcx>, requested_kind: ty::ClosureKind, - ) -> Instance<'tcx> { + ) -> Option<Instance<'tcx>> { let actual_kind = substs.as_closure().kind(); match needs_fn_once_adapter_shim(actual_kind, requested_kind) { Ok(true) => Instance::fn_once_adapter_instance(tcx, def_id, substs), - _ => Instance::new(def_id, substs), + _ => Some(Instance::new(def_id, substs)), } } @@ -515,7 +515,7 @@ impl<'tcx> Instance<'tcx> { tcx: TyCtxt<'tcx>, closure_did: DefId, substs: ty::SubstsRef<'tcx>, - ) -> Instance<'tcx> { + ) -> Option<Instance<'tcx>> { debug!("fn_once_adapter_shim({:?}, {:?})", closure_did, substs); let fn_once = tcx.require_lang_item(LangItem::FnOnce, None); let call_once = tcx @@ -531,12 +531,13 @@ impl<'tcx> Instance<'tcx> { let self_ty = tcx.mk_closure(closure_did, substs); let sig = substs.as_closure().sig(); - let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig); + let sig = + tcx.try_normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig).ok()?; assert_eq!(sig.inputs().len(), 1); let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()]); debug!("fn_once_adapter_shim: self_ty={:?} sig={:?}", self_ty, sig); - Instance { def, substs } + Some(Instance { def, substs }) } /// Depending on the kind of `InstanceDef`, the MIR body associated with an diff --git a/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs b/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs index 66a0a192a87..9d8a8116594 100644 --- a/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs +++ b/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs @@ -112,6 +112,26 @@ impl<'tcx> TyCtxt<'tcx> { self.normalize_erasing_regions(param_env, value) } + /// If you have a `Binder<'tcx, T>`, you can do this to strip out the + /// late-bound regions and then normalize the result, yielding up + /// a `T` (with regions erased). This is appropriate when the + /// binder is being instantiated at the call site. + /// + /// N.B., currently, higher-ranked type bounds inhibit + /// normalization. Therefore, each time we erase them in + /// codegen, we need to normalize the contents. + pub fn try_normalize_erasing_late_bound_regions<T>( + self, + param_env: ty::ParamEnv<'tcx>, + value: ty::Binder<'tcx, T>, + ) -> Result<T, NormalizationError<'tcx>> + where + T: TypeFoldable<'tcx>, + { + let value = self.erase_late_bound_regions(value); + self.try_normalize_erasing_regions(param_env, value) + } + /// Monomorphizes a type from the AST by first applying the /// in-scope substitutions and then normalizing any associated /// types. |
