mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Auto merge of #122849 - clubby789:no-metadata, r=petrochenkov
Don't emit load metadata in debug mode r? `@ghost`
This commit is contained in:
commit
73476d4990
@ -20,6 +20,7 @@ use rustc_middle::ty::layout::{
|
||||
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, TyAndLayout,
|
||||
};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
use rustc_session::config::OptLevel;
|
||||
use rustc_span::Span;
|
||||
use rustc_symbol_mangling::typeid::{
|
||||
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> {
|
||||
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);
|
||||
}
|
||||
@ -667,6 +673,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 = [
|
||||
|
@ -24,9 +24,8 @@ pub unsafe fn swap_i32(x: &mut i32, y: &mut i32) {
|
||||
// CHECK-NOT: alloca
|
||||
|
||||
// CHECK: %[[TEMP:.+]] = load i32, ptr %x, align 4
|
||||
// CHECK-SAME: !noundef
|
||||
// OPT3-SAME: !noundef
|
||||
// OPT0: %[[TEMP2:.+]] = load i32, ptr %y, align 4
|
||||
// OPT0-SAME: !noundef
|
||||
// OPT0: store i32 %[[TEMP2]], ptr %x, align 4
|
||||
// OPT0-NOT: memcpy
|
||||
// OPT3-NOT: load
|
||||
@ -42,9 +41,9 @@ pub unsafe fn swap_pair(x: &mut (i32, u32), y: &mut (i32, u32)) {
|
||||
// CHECK-NOT: alloca
|
||||
|
||||
// CHECK: load i32
|
||||
// CHECK-SAME: !noundef
|
||||
// OPT3-SAME: !noundef
|
||||
// CHECK: load i32
|
||||
// CHECK-SAME: !noundef
|
||||
// OPT3-SAME: !noundef
|
||||
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x, ptr align 4 %y, i64 8, i1 false)
|
||||
// CHECK: store i32
|
||||
// CHECK: store i32
|
||||
@ -57,10 +56,10 @@ pub unsafe fn swap_str<'a>(x: &mut &'a str, y: &mut &'a str) {
|
||||
// CHECK-NOT: alloca
|
||||
|
||||
// CHECK: load ptr
|
||||
// CHECK-SAME: !nonnull
|
||||
// CHECK-SAME: !noundef
|
||||
// OPT3-SAME: !nonnull
|
||||
// OPT3-SAME: !noundef
|
||||
// CHECK: load i64
|
||||
// CHECK-SAME: !noundef
|
||||
// OPT3-SAME: !noundef
|
||||
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x, ptr align 8 %y, i64 16, i1 false)
|
||||
// CHECK: store ptr
|
||||
// CHECK: store i64
|
||||
|
@ -1,4 +1,5 @@
|
||||
//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0
|
||||
//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -O
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(generic_nonzero)]
|
||||
|
||||
|
@ -16,7 +16,7 @@ fn main() {
|
||||
// CHECK-LABEL: @_ZN20overaligned_constant4main
|
||||
// CHECK: [[full:%_.*]] = alloca %SmallStruct, align 8
|
||||
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[full]], ptr align 8 @0, i64 32, i1 false)
|
||||
// CHECK: %b.0 = load i32, ptr @0, align 4,
|
||||
// CHECK: %b.0 = load i32, ptr @0, align 4
|
||||
// CHECK: %b.1 = load i32, ptr getelementptr inbounds ({{.*}}), align 4
|
||||
let mut s = S(1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user