@@ -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 , Instance , Ty , TyCtxt } ;
23
+ use rustc_session:: config:: OptLevel ;
23
24
use rustc_span:: Span ;
24
25
use rustc_symbol_mangling:: typeid:: {
25
26
kcfi_typeid_for_fnabi, kcfi_typeid_for_instance, typeid_for_fnabi, typeid_for_instance,
@@ -551,6 +552,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
551
552
layout : TyAndLayout < ' tcx > ,
552
553
offset : Size ,
553
554
) {
555
+ if bx. cx . sess ( ) . opts . optimize == OptLevel :: No {
556
+ // Don't emit metadata we're not going to use
557
+ return ;
558
+ }
559
+
554
560
if !scalar. is_uninit_valid ( ) {
555
561
bx. noundef_metadata ( load) ;
556
562
}
@@ -667,6 +673,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
667
673
return ;
668
674
}
669
675
676
+ if self . cx . sess ( ) . opts . optimize == OptLevel :: No {
677
+ // Don't emit metadata we're not going to use
678
+ return ;
679
+ }
680
+
670
681
unsafe {
671
682
let llty = self . cx . val_ty ( load) ;
672
683
let v = [
0 commit comments