@@ -20,6 +20,7 @@ use rustc_middle::ty::layout::{
20
20
FnAbiError , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOfHelpers , TyAndLayout ,
21
21
} ;
22
22
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
23
+ use rustc_session:: config:: OptLevel ;
23
24
use rustc_span:: Span ;
24
25
use rustc_symbol_mangling:: typeid:: { kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions } ;
25
26
use 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> {
547
548
layout : TyAndLayout < ' tcx > ,
548
549
offset : Size ,
549
550
) {
551
+ if bx. cx . sess ( ) . opts . optimize == OptLevel :: No {
552
+ // Don't emit metadata we're not going to use
553
+ return ;
554
+ }
555
+
550
556
if !scalar. is_uninit_valid ( ) {
551
557
bx. noundef_metadata ( load) ;
552
558
}
@@ -663,6 +669,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
663
669
return ;
664
670
}
665
671
672
+ if self . cx . sess ( ) . opts . optimize == OptLevel :: No {
673
+ // Don't emit metadata we're not going to use
674
+ return ;
675
+ }
676
+
666
677
unsafe {
667
678
let llty = self . cx . val_ty ( load) ;
668
679
let v = [
0 commit comments