Skip to content

Commit dcf0916

Browse files
committed
Replace Rvalue::NullaryOp by a variant in mir::ConstValue.
1 parent d65ccdd commit dcf0916

File tree

53 files changed

+210
-336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+210
-336
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,10 +1559,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
15591559
self.consume_operand(location, (operand2, span), state);
15601560
}
15611561

1562-
Rvalue::NullaryOp(_op) => {
1563-
// nullary ops take no dynamic input; no borrowck effect.
1564-
}
1565-
15661562
Rvalue::Aggregate(aggregate_kind, operands) => {
15671563
// We need to report back the list of mutable upvars that were
15681564
// moved into the closure and subsequently used by the closure,

compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
314314
self.consume_operand(location, operand2);
315315
}
316316

317-
Rvalue::NullaryOp(_op) => {}
318-
319317
Rvalue::Aggregate(_, operands) => {
320318
for operand in operands {
321319
self.consume_operand(location, operand);

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10461046
}
10471047
}
10481048

1049-
&Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {}
1050-
10511049
Rvalue::ShallowInitBox(_operand, ty) => {
10521050
let trait_ref =
10531051
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, span), [*ty]);
@@ -2201,7 +2199,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22012199
| Rvalue::Cast(..)
22022200
| Rvalue::ShallowInitBox(..)
22032201
| Rvalue::BinaryOp(..)
2204-
| Rvalue::NullaryOp(..)
22052202
| Rvalue::CopyForDeref(..)
22062203
| Rvalue::UnaryOp(..)
22072204
| Rvalue::Discriminant(..)

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
1010
use rustc_index::IndexVec;
1111
use rustc_middle::ty::TypeVisitableExt;
1212
use rustc_middle::ty::adjustment::PointerCoercion;
13-
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv};
13+
use rustc_middle::ty::layout::FnAbiOf;
1414
use rustc_middle::ty::print::with_no_trimmed_paths;
1515
use rustc_session::config::OutputFilenames;
1616
use rustc_span::Symbol;
@@ -853,17 +853,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
853853
fx.bcx.ins().nop();
854854
}
855855
}
856-
Rvalue::NullaryOp(ref null_op) => {
857-
assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env()));
858-
let val = match null_op {
859-
NullOp::RuntimeChecks(kind) => kind.value(fx.tcx.sess),
860-
};
861-
let val = CValue::by_val(
862-
fx.bcx.ins().iconst(types::I8, i64::from(val)),
863-
fx.layout_of(fx.tcx.types.bool),
864-
);
865-
lval.write_cvalue(fx, val);
866-
}
867856
Rvalue::Aggregate(ref kind, ref operands)
868857
if matches!(**kind, AggregateKind::RawPtr(..)) =>
869858
{

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ 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+
}
218223
ConstValue::Indirect { alloc_id, offset } => CValue::by_ref(
219224
Pointer::new(pointer_for_allocation(fx, alloc_id))
220225
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
165165
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
166166
OperandValue::Immediate(llval)
167167
}
168+
mir::ConstValue::RuntimeChecks(checks) => {
169+
let BackendRepr::Scalar(scalar) = layout.backend_repr else {
170+
bug!("from_const: invalid ByVal layout: {:#?}", layout);
171+
};
172+
let x = Scalar::from_bool(checks.value(bx.tcx().sess));
173+
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
174+
OperandValue::Immediate(llval)
175+
}
168176
ConstValue::ZeroSized => return OperandRef::zero_sized(layout),
169177
ConstValue::Slice { alloc_id, meta } => {
170178
let BackendRepr::ScalarPair(a_scalar, _) = layout.backend_repr else {

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -613,21 +613,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
613613
}
614614
}
615615

616-
mir::Rvalue::NullaryOp(ref null_op) => {
617-
let val = match null_op {
618-
mir::NullOp::RuntimeChecks(kind) => {
619-
let val = kind.value(bx.tcx().sess);
620-
bx.cx().const_bool(val)
621-
}
622-
};
623-
let tcx = self.cx.tcx();
624-
OperandRef {
625-
val: OperandValue::Immediate(val),
626-
layout: self.cx.layout_of(null_op.ty(tcx)),
627-
move_annotation: None,
628-
}
629-
}
630-
631616
mir::Rvalue::ThreadLocalRef(def_id) => {
632617
assert!(bx.cx().tcx().is_static(def_id));
633618
let layout = bx.layout_of(bx.cx().tcx().static_ptr_ty(def_id, bx.typing_env()));

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
645645

646646
Rvalue::Cast(_, _, _) => {}
647647

648-
Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {}
649648
Rvalue::ShallowInitBox(_, _) => {}
650649

651650
Rvalue::UnaryOp(op, operand) => {

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ where
230230
F: FnMut(Local) -> bool,
231231
{
232232
match rvalue {
233-
Rvalue::ThreadLocalRef(_) | Rvalue::NullaryOp(..) => {
234-
Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx))
235-
}
233+
Rvalue::ThreadLocalRef(_) => Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)),
236234

237235
Rvalue::Discriminant(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),
238236

compiler/rustc_const_eval/src/check_consts/resolver.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ where
198198
| mir::Rvalue::ThreadLocalRef(..)
199199
| mir::Rvalue::Repeat(..)
200200
| mir::Rvalue::BinaryOp(..)
201-
| mir::Rvalue::NullaryOp(..)
202201
| mir::Rvalue::UnaryOp(..)
203202
| mir::Rvalue::Discriminant(..)
204203
| mir::Rvalue::Aggregate(..)

0 commit comments

Comments
 (0)