diff options
| author | kennytm <kennytm@gmail.com> | 2019-03-02 14:55:15 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2019-03-02 22:58:29 +0800 |
| commit | 8bdd948b31881d890ec0de5abbff3aba4ec09f71 (patch) | |
| tree | 5c64b04a6a7d91eeb46fe6da2f9ebf61da0ec98c | |
| parent | 4aebce5758eec173351784b88678cb85eeafeb36 (diff) | |
| parent | fbdece47c84aa1161b01c86457ee193dd434387d (diff) | |
| download | rust-8bdd948b31881d890ec0de5abbff3aba4ec09f71.tar.gz rust-8bdd948b31881d890ec0de5abbff3aba4ec09f71.zip | |
Rollup merge of #58802 - nnethercote:inline-record_layout, r=oli-obk
Ensure `record_layout_for_printing()` is inlined. This reduces instruction counts for the `ctfe-stress-2` benchmark by about 1%. r? @oli-obk
| -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); |
