Skip to content

Commit cf3864a

Browse files
committed
Restrict the spilling of scalable types to the problematic ones.
Rather than not spilling any scalable SIMD types for debug info, we only avoid spilling the ones that are going to cause a problem. Currently the only ones known to cause a problem are the internal svbool types for AArch64.
1 parent 949b1a8 commit cf3864a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,23 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
365365
if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
366366
return;
367367
}
368-
// FIXME: Don't spill scalable simd, this works for most of them however,
369-
// some intermediate types can't be spilled e.g. `<vscale x 4 x i1>`
370-
if operand.layout.ty.is_scalable_simd() {
371-
return;
368+
369+
// LLVM doesn't handle stores on some of the internal SVE types that we are required
370+
// to use. Spilling to the stack here to create debug info for them will cause
371+
// errors during instruction selection. The types that can't be spilled are an
372+
// internal implementation detail to the intrinsic, the user should never see these
373+
// types, and therefore shouldn't need any debug info for them.
374+
if operand.layout.ty.is_scalable_simd() && bx.sess().target.arch == "aarch64" {
375+
if let ty::Adt(adt, args) = &operand.layout.ty.kind() {
376+
if let Some(f0) = adt.non_enum_variant().fields.get(FieldIdx::from_u32(0)) {
377+
let f0_ty = f0.ty(bx.tcx(), args);
378+
if let ty::Slice(e_ty) = f0_ty.kind() {
379+
if e_ty.is_bool() && adt.repr().scalable != Some(16) {
380+
return;
381+
}
382+
}
383+
}
384+
}
372385
}
373386

374387
Self::spill_operand_to_stack(*operand, name, bx)

0 commit comments

Comments
 (0)