Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f1ffb8d

Browse files
author
The Miri Cronjob Bot
committedMay 23, 2024
Merge from rustc
2 parents 807a0f8 + 9696835 commit f1ffb8d

File tree

166 files changed

+1889
-1806
lines changed

Some content is hidden

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

166 files changed

+1889
-1806
lines changed
 

Diff for: ‎compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::common::IntPredicate;
77
use crate::traits::*;
88
use crate::MemFlags;
99

10-
use rustc_hir as hir;
1110
use rustc_middle::mir;
1211
use rustc_middle::ty::cast::{CastTy, IntTy};
1312
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
@@ -896,9 +895,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
896895
| mir::BinOp::Le
897896
| mir::BinOp::Ge => {
898897
if is_float {
899-
bx.fcmp(base::bin_op_to_fcmp_predicate(op.to_hir_binop()), lhs, rhs)
898+
bx.fcmp(base::bin_op_to_fcmp_predicate(op), lhs, rhs)
900899
} else {
901-
bx.icmp(base::bin_op_to_icmp_predicate(op.to_hir_binop(), is_signed), lhs, rhs)
900+
bx.icmp(base::bin_op_to_icmp_predicate(op, is_signed), lhs, rhs)
902901
}
903902
}
904903
mir::BinOp::Cmp => {
@@ -912,16 +911,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
912911
// `PartialOrd`, so only use it in debug for now. Once LLVM can handle it
913912
// better (see <https://github.com/llvm/llvm-project/issues/73417>), it'll
914913
// be worth trying it in optimized builds as well.
915-
let is_gt = bx.icmp(pred(hir::BinOpKind::Gt), lhs, rhs);
914+
let is_gt = bx.icmp(pred(mir::BinOp::Gt), lhs, rhs);
916915
let gtext = bx.zext(is_gt, bx.type_i8());
917-
let is_lt = bx.icmp(pred(hir::BinOpKind::Lt), lhs, rhs);
916+
let is_lt = bx.icmp(pred(mir::BinOp::Lt), lhs, rhs);
918917
let ltext = bx.zext(is_lt, bx.type_i8());
919918
bx.unchecked_ssub(gtext, ltext)
920919
} else {
921920
// These operations are those expected by `tests/codegen/integer-cmp.rs`,
922921
// from <https://github.com/rust-lang/rust/pull/63767>.
923-
let is_lt = bx.icmp(pred(hir::BinOpKind::Lt), lhs, rhs);
924-
let is_ne = bx.icmp(pred(hir::BinOpKind::Ne), lhs, rhs);
922+
let is_lt = bx.icmp(pred(mir::BinOp::Lt), lhs, rhs);
923+
let is_ne = bx.icmp(pred(mir::BinOp::Ne), lhs, rhs);
925924
let ge = bx.select(
926925
is_ne,
927926
bx.cx().const_i8(Ordering::Greater as i8),

Diff for: ‎compiler/rustc_const_eval/src/const_eval/machine.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ use rustc_target::spec::abi::Abi as CallAbi;
2525
use crate::errors::{LongRunning, LongRunningWarn};
2626
use crate::fluent_generated as fluent;
2727
use crate::interpret::{
28-
self, compile_time_machine, err_ub, throw_exhaust, throw_inval, throw_ub_custom,
28+
self, compile_time_machine, err_ub, throw_exhaust, throw_inval, throw_ub_custom, throw_unsup,
2929
throw_unsup_format, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, FnVal, Frame,
30-
ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
30+
GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
3131
};
3232

3333
use super::error::*;
@@ -759,11 +759,21 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
759759
ecx: &InterpCx<'mir, 'tcx, Self>,
760760
alloc_id: AllocId,
761761
) -> InterpResult<'tcx> {
762+
// Check if this is the currently evaluated static.
762763
if Some(alloc_id) == ecx.machine.static_root_ids.map(|(id, _)| id) {
763-
Err(ConstEvalErrKind::RecursiveStatic.into())
764-
} else {
765-
Ok(())
764+
return Err(ConstEvalErrKind::RecursiveStatic.into());
766765
}
766+
// If this is another static, make sure we fire off the query to detect cycles.
767+
// But only do that when checks for static recursion are enabled.
768+
if ecx.machine.static_root_ids.is_some() {
769+
if let Some(GlobalAlloc::Static(def_id)) = ecx.tcx.try_get_global_alloc(alloc_id) {
770+
if ecx.tcx.is_foreign_item(def_id) {
771+
throw_unsup!(ExternStatic(def_id));
772+
}
773+
ecx.ctfe_query(|tcx| tcx.eval_static_initializer(def_id))?;
774+
}
775+
}
776+
Ok(())
767777
}
768778
}
769779

Diff for: ‎compiler/rustc_const_eval/src/interpret/intrinsics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
255255
name = intrinsic_name,
256256
);
257257
}
258+
// This will always return 0.
258259
(a, b)
259260
}
260261
(Err(_), _) | (_, Err(_)) => {
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.