Rollup merge of #78844 - tmiasko:monomorphize-sizeof, r=oli-obk

Monomorphize a type argument of size-of operation during codegen

This wasn't necessary until MIR inliner started to consider drop glue as
a candidate for inlining; introducing for the first time a generic use
of size-of operation.

No test at this point since this only happens with a custom inlining
threshold.
This commit is contained in:
Dylan DPC 2020-11-09 19:07:02 +01:00 committed by GitHub
commit c150b933ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -502,6 +502,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
mir::Rvalue::NullaryOp(mir::NullOp::SizeOf, ty) => {
let ty = self.monomorphize(&ty);
assert!(bx.cx().type_is_sized(ty));
let val = bx.cx().const_usize(bx.cx().layout_of(ty).size.bytes());
let tcx = self.cx.tcx();