Skip to content

Commit a1308b2

Browse files
committed
Don't emit load metadata in debug mode
1 parent 4a52e9c commit a1308b2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_middle::ty::layout::{
2020
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, TyAndLayout,
2121
};
2222
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
23+
use rustc_session::config::OptLevel;
2324
use rustc_span::Span;
2425
use rustc_symbol_mangling::typeid::{
2526
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> {
551552
layout: TyAndLayout<'tcx>,
552553
offset: Size,
553554
) {
555+
if bx.cx.sess().opts.optimize == OptLevel::No {
556+
// Don't emit metadata we're not going to use
557+
return;
558+
}
559+
554560
if !scalar.is_uninit_valid() {
555561
bx.noundef_metadata(load);
556562
}
@@ -667,6 +673,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
667673
return;
668674
}
669675

676+
if self.cx.sess().opts.optimize == OptLevel::No {
677+
// Don't emit metadata we're not going to use
678+
return;
679+
}
680+
670681
unsafe {
671682
let llty = self.cx.val_ty(load);
672683
let v = [

tests/codegen/loads.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0
1+
//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -O
2+
23
#![crate_type = "lib"]
34
#![feature(generic_nonzero)]
45

0 commit comments

Comments
 (0)