diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-02-28 19:10:43 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-02-28 19:10:43 +1100 |
| commit | fbdece47c84aa1161b01c86457ee193dd434387d (patch) | |
| tree | 8f9fc357ae937e4f488adbaabab7426be1b58f3d | |
| parent | 02c4c28920ddfdb43e68a363b7fe59ac4c92399c (diff) | |
| download | rust-fbdece47c84aa1161b01c86457ee193dd434387d.tar.gz rust-fbdece47c84aa1161b01c86457ee193dd434387d.zip | |
Ensure `record_layout_for_printing()` is inlined.
This reduces instruction counts for the `ctfe-stress-2` benchmark by about 1%.
| -rw-r--r-- | src/librustc/ty/layout.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 6c507c0015d..7d2b21b9aec 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1176,14 +1176,20 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { /// This is invoked by the `layout_raw` query to record the final /// layout of each type. - #[inline] + #[inline(always)] fn record_layout_for_printing(&self, layout: TyLayout<'tcx>) { - // If we are running with `-Zprint-type-sizes`, record layouts for - // dumping later. Ignore layouts that are done with non-empty - // environments or non-monomorphic layouts, as the user only wants - // to see the stuff resulting from the final codegen session. + // If we are running with `-Zprint-type-sizes`, maybe record layouts + // for dumping later. + if self.tcx.sess.opts.debugging_opts.print_type_sizes { + self.record_layout_for_printing_outlined(layout) + } + } + + fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) { + // Ignore layouts that are done with non-empty environments or + // non-monomorphic layouts, as the user only wants to see the stuff + // resulting from the final codegen session. if - !self.tcx.sess.opts.debugging_opts.print_type_sizes || layout.ty.has_param_types() || layout.ty.has_self_ty() || !self.param_env.caller_bounds.is_empty() @@ -1191,10 +1197,6 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { return; } - self.record_layout_for_printing_outlined(layout) - } - - fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) { // (delay format until we actually need it) let record = |kind, packed, opt_discr_size, variants| { let type_desc = format!("{:?}", layout.ty); |
