Skip to content

Commit a3676bd

Browse files
committed
Introduce Operand::RuntimeChecks.
1 parent a0de5ae commit a3676bd

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/base.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions;
88
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
99
use rustc_data_structures::profiling::SelfProfilerRef;
1010
use rustc_index::IndexVec;
11-
use rustc_middle::ty::TypeVisitableExt;
1211
use rustc_middle::ty::adjustment::PointerCoercion;
1312
use rustc_middle::ty::layout::FnAbiOf;
1413
use rustc_middle::ty::print::with_no_trimmed_paths;
14+
use rustc_middle::ty::{ScalarInt, TypeVisitableExt};
1515
use rustc_session::config::OutputFilenames;
1616
use rustc_span::Symbol;
1717

@@ -1039,6 +1039,12 @@ pub(crate) fn codegen_operand<'tcx>(
10391039
cplace.to_cvalue(fx)
10401040
}
10411041
Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_),
1042+
Operand::RuntimeChecks(checks) => {
1043+
let int = checks.value(fx.tcx.sess);
1044+
let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap();
1045+
let layout = fx.layout_of(fx.tcx.types.bool);
1046+
return CValue::const_val(fx, layout, int);
1047+
}
10421048
}
10431049
}
10441050

src/constant.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ pub(crate) fn codegen_const_value<'tcx>(
215215
CValue::by_val(val, layout)
216216
}
217217
},
218-
ConstValue::RuntimeChecks(checks) => {
219-
let int = checks.value(fx.tcx.sess);
220-
let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap();
221-
return CValue::const_val(fx, layout, int);
222-
}
223218
ConstValue::Indirect { alloc_id, offset } => CValue::by_ref(
224219
Pointer::new(pointer_for_allocation(fx, alloc_id))
225220
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),
@@ -545,6 +540,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
545540
operand: &Operand<'tcx>,
546541
) -> Option<ScalarInt> {
547542
match operand {
543+
Operand::RuntimeChecks(checks) => {
544+
let int = checks.value(fx.tcx.sess);
545+
ScalarInt::try_from_uint(int, Size::from_bits(1))
546+
}
548547
Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(),
549548
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored
550549
// inside a temporary before being passed to the intrinsic requiring the const argument.

0 commit comments

Comments
 (0)