|
1 | | -use rustc_abi::{FIRST_VARIANT, FieldIdx}; |
| 1 | +use rustc_abi::FieldIdx; |
2 | 2 | use rustc_data_structures::flat_map_in_place::FlatMapInPlace; |
3 | 3 | use rustc_hir::LangItem; |
4 | 4 | use rustc_index::IndexVec; |
@@ -32,7 +32,7 @@ impl<'tcx> crate::MirPass<'tcx> for ScalarReplacementOfAggregates { |
32 | 32 | let typing_env = body.typing_env(tcx); |
33 | 33 | loop { |
34 | 34 | debug!(?excluded); |
35 | | - let escaping = escaping_locals(tcx, typing_env, &excluded, body); |
| 35 | + let escaping = escaping_locals(tcx, &excluded, body); |
36 | 36 | debug!(?escaping); |
37 | 37 | let replacements = compute_flattening(tcx, typing_env, body, escaping); |
38 | 38 | debug!(?replacements); |
@@ -64,39 +64,19 @@ impl<'tcx> crate::MirPass<'tcx> for ScalarReplacementOfAggregates { |
64 | 64 | /// client code. |
65 | 65 | fn escaping_locals<'tcx>( |
66 | 66 | tcx: TyCtxt<'tcx>, |
67 | | - typing_env: ty::TypingEnv<'tcx>, |
68 | 67 | excluded: &DenseBitSet<Local>, |
69 | 68 | body: &Body<'tcx>, |
70 | 69 | ) -> DenseBitSet<Local> { |
71 | 70 | let is_excluded_ty = |ty: Ty<'tcx>| { |
72 | 71 | if ty.is_union() || ty.is_enum() { |
73 | 72 | return true; |
74 | 73 | } |
75 | | - if let ty::Adt(def, _args) = ty.kind() { |
76 | | - if def.repr().simd() { |
77 | | - // Exclude #[repr(simd)] types so that they are not de-optimized into an array |
78 | | - return true; |
79 | | - } |
80 | | - if tcx.is_lang_item(def.did(), LangItem::DynMetadata) { |
81 | | - // codegen wants to see the `DynMetadata<T>`, |
82 | | - // not the inner reference-to-opaque-type. |
83 | | - return true; |
84 | | - } |
85 | | - // We already excluded unions and enums, so this ADT must have one variant |
86 | | - let variant = def.variant(FIRST_VARIANT); |
87 | | - if variant.fields.len() > 1 { |
88 | | - // If this has more than one field, it cannot be a wrapper that only provides a |
89 | | - // niche, so we do not want to automatically exclude it. |
90 | | - return false; |
91 | | - } |
92 | | - let Ok(layout) = tcx.layout_of(typing_env.as_query_input(ty)) else { |
93 | | - // We can't get the layout |
94 | | - return true; |
95 | | - }; |
96 | | - if layout.layout.largest_niche().is_some() { |
97 | | - // This type has a niche |
98 | | - return true; |
99 | | - } |
| 74 | + if let ty::Adt(def, _args) = ty.kind() |
| 75 | + && tcx.is_lang_item(def.did(), LangItem::DynMetadata) |
| 76 | + { |
| 77 | + // codegen wants to see the `DynMetadata<T>`, |
| 78 | + // not the inner reference-to-opaque-type. |
| 79 | + return true; |
100 | 80 | } |
101 | 81 | // Default for non-ADTs |
102 | 82 | false |
|
0 commit comments