Rollup merge of #144665 - scottmcm:restore-sroa-simd-check, r=compiler-errors

Re-block SRoA on SIMD types

Fixes rust-lang/rust#144621
This commit is contained in:
Stuart Cook
2025-07-31 18:52:10 +10:00
committed by GitHub
3 changed files with 55 additions and 1 deletions

View File

@@ -72,8 +72,12 @@ fn escaping_locals<'tcx>(
return true;
}
if let ty::Adt(def, _args) = ty.kind()
&& tcx.is_lang_item(def.did(), LangItem::DynMetadata)
&& (def.repr().simd() || tcx.is_lang_item(def.did(), LangItem::DynMetadata))
{
// Exclude #[repr(simd)] types so that they are not de-optimized into an array
// (MCP#838 banned projections into SIMD types, but if the value is unused
// this pass sees "all the uses are of the fields" and expands it.)
// codegen wants to see the `DynMetadata<T>`,
// not the inner reference-to-opaque-type.
return true;