@@ -20,6 +20,7 @@ use rustc_middle::ty::layout::{
2020 FnAbiError , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOfHelpers , TyAndLayout ,
2121} ;
2222use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
23+ use rustc_session:: config:: OptLevel ;
2324use rustc_span:: Span ;
2425use rustc_symbol_mangling:: typeid:: { kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions } ;
2526use rustc_target:: abi:: { self , call:: FnAbi , Align , Size , WrappingRange } ;
@@ -547,6 +548,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
547548 layout : TyAndLayout < ' tcx > ,
548549 offset : Size ,
549550 ) {
551+ if bx. cx . sess ( ) . opts . optimize == OptLevel :: No {
552+ // Don't emit metadata we're not going to use
553+ return ;
554+ }
555+
550556 if !scalar. is_uninit_valid ( ) {
551557 bx. noundef_metadata ( load) ;
552558 }
@@ -663,6 +669,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
663669 return ;
664670 }
665671
672+ if self . cx . sess ( ) . opts . optimize == OptLevel :: No {
673+ // Don't emit metadata we're not going to use
674+ return ;
675+ }
676+
666677 unsafe {
667678 let llty = self . cx . val_ty ( load) ;
668679 let v = [
0 commit comments