Skip to content

Commit 1bdeb98

Browse files
committed
Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2 parents 52b5ccb + e8ade24 commit 1bdeb98

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/type_of.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
213213
// NOTE: we cannot remove this match like in the LLVM codegen because the call
214214
// to fn_ptr_backend_type handle the on-stack attribute.
215215
// TODO(antoyo): find a less hackish way to hande the on-stack attribute.
216-
ty::FnPtr(sig) => {
217-
cx.fn_ptr_backend_type(cx.fn_abi_of_fn_ptr(sig, ty::List::empty()))
218-
}
216+
ty::FnPtr(sig_tys, hdr) => cx
217+
.fn_ptr_backend_type(cx.fn_abi_of_fn_ptr(sig_tys.with(hdr), ty::List::empty())),
219218
_ => self.scalar_gcc_type_at(cx, scalar, Size::ZERO),
220219
};
221220
cx.scalar_types.borrow_mut().insert(self.ty, ty);

0 commit comments

Comments
 (0)