Skip to content

Commit fbdece4

Browse files
committed
Ensure record_layout_for_printing() is inlined.
This reduces instruction counts for the `ctfe-stress-2` benchmark by about 1%.
1 parent 02c4c28 commit fbdece4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/librustc/ty/layout.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1176,25 +1176,27 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
11761176

11771177
/// This is invoked by the `layout_raw` query to record the final
11781178
/// layout of each type.
1179-
#[inline]
1179+
#[inline(always)]
11801180
fn record_layout_for_printing(&self, layout: TyLayout<'tcx>) {
1181-
// If we are running with `-Zprint-type-sizes`, record layouts for
1182-
// dumping later. Ignore layouts that are done with non-empty
1183-
// environments or non-monomorphic layouts, as the user only wants
1184-
// to see the stuff resulting from the final codegen session.
1181+
// If we are running with `-Zprint-type-sizes`, maybe record layouts
1182+
// for dumping later.
1183+
if self.tcx.sess.opts.debugging_opts.print_type_sizes {
1184+
self.record_layout_for_printing_outlined(layout)
1185+
}
1186+
}
1187+
1188+
fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
1189+
// Ignore layouts that are done with non-empty environments or
1190+
// non-monomorphic layouts, as the user only wants to see the stuff
1191+
// resulting from the final codegen session.
11851192
if
1186-
!self.tcx.sess.opts.debugging_opts.print_type_sizes ||
11871193
layout.ty.has_param_types() ||
11881194
layout.ty.has_self_ty() ||
11891195
!self.param_env.caller_bounds.is_empty()
11901196
{
11911197
return;
11921198
}
11931199

1194-
self.record_layout_for_printing_outlined(layout)
1195-
}
1196-
1197-
fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
11981200
// (delay format until we actually need it)
11991201
let record = |kind, packed, opt_discr_size, variants| {
12001202
let type_desc = format!("{:?}", layout.ty);

0 commit comments

Comments
 (0)