Skip to content

Commit

Permalink
Don't emit load metadata in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Mar 23, 2024
1 parent a0569fa commit c512f67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use rustc_middle::ty::layout::{
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, TyAndLayout,
};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::config::OptLevel;
use rustc_span::Span;
use rustc_symbol_mangling::typeid::{kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions};
use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
Expand Down Expand Up @@ -547,6 +548,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
layout: TyAndLayout<'tcx>,
offset: Size,
) {
if bx.cx.sess().opts.optimize == OptLevel::No {
// Don't emit metadata we're not going to use
return;
}

if !scalar.is_uninit_valid() {
bx.noundef_metadata(load);
}
Expand Down Expand Up @@ -663,6 +669,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
return;
}

if self.cx.sess().opts.optimize == OptLevel::No {
// Don't emit metadata we're not going to use
return;
}

unsafe {
let llty = self.cx.val_ty(load);
let v = [
Expand Down
2 changes: 2 additions & 0 deletions tests/codegen/loads.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0
//@ ignore-debug: We don't emit load metadata in debug

#![crate_type = "lib"]
#![feature(generic_nonzero)]

Expand Down

0 comments on commit c512f67

Please sign in to comment.