Skip to content

Commit 4863b71

Browse files
authored
Merge pull request #4101 from RalfJung/rustup
Rustup
2 parents 252e4bb + 49e310c commit 4863b71

28 files changed

+471
-646
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
214587c89d527dd0ccbe1f2150c737d3bdee67b0
1+
8a1f8039a7ded79d3d4fe97b110016d89f2b11e2

src/helpers.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
1919
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
2020
use rustc_session::config::CrateType;
2121
use rustc_span::{Span, Symbol};
22+
use rustc_target::callconv::{Conv, FnAbi};
2223

2324
use crate::*;
2425

@@ -920,13 +921,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
920921
}
921922

922923
/// Check that the ABI is what we expect.
923-
fn check_abi<'a>(&self, abi: ExternAbi, exp_abi: ExternAbi) -> InterpResult<'a, ()> {
924-
if abi != exp_abi {
924+
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
925+
if fn_abi.conv != exp_abi {
925926
throw_ub_format!(
926-
"calling a function with ABI {} using caller ABI {}",
927-
exp_abi.name(),
928-
abi.name()
929-
)
927+
"calling a function with ABI {:?} using caller ABI {:?}",
928+
exp_abi,
929+
fn_abi.conv
930+
);
930931
}
931932
interp_ok(())
932933
}
@@ -956,8 +957,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
956957

957958
fn check_abi_and_shim_symbol_clash(
958959
&mut self,
959-
abi: ExternAbi,
960-
exp_abi: ExternAbi,
960+
abi: &FnAbi<'tcx, Ty<'tcx>>,
961+
exp_abi: Conv,
961962
link_name: Symbol,
962963
) -> InterpResult<'tcx, ()> {
963964
self.check_abi(abi, exp_abi)?;
@@ -981,8 +982,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
981982

982983
fn check_shim<'a, const N: usize>(
983984
&mut self,
984-
abi: ExternAbi,
985-
exp_abi: ExternAbi,
985+
abi: &FnAbi<'tcx, Ty<'tcx>>,
986+
exp_abi: Conv,
986987
link_name: Symbol,
987988
args: &'a [OpTy<'tcx>],
988989
) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]>

src/machine.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2424
use rustc_session::config::InliningThreshold;
2525
use rustc_span::def_id::{CrateNum, DefId};
2626
use rustc_span::{Span, SpanData, Symbol};
27+
use rustc_target::callconv::FnAbi;
2728

2829
use crate::concurrency::cpu_affinity::{self, CpuAffinityMask};
2930
use crate::concurrency::data_race::{self, NaReadType, NaWriteType};
@@ -1010,7 +1011,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10101011
fn find_mir_or_eval_fn(
10111012
ecx: &mut MiriInterpCx<'tcx>,
10121013
instance: ty::Instance<'tcx>,
1013-
abi: ExternAbi,
1014+
abi: &FnAbi<'tcx, Ty<'tcx>>,
10141015
args: &[FnArg<'tcx, Provenance>],
10151016
dest: &MPlaceTy<'tcx>,
10161017
ret: Option<mir::BasicBlock>,
@@ -1037,7 +1038,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10371038
fn call_extra_fn(
10381039
ecx: &mut MiriInterpCx<'tcx>,
10391040
fn_val: DynSym,
1040-
abi: ExternAbi,
1041+
abi: &FnAbi<'tcx, Ty<'tcx>>,
10411042
args: &[FnArg<'tcx, Provenance>],
10421043
dest: &MPlaceTy<'tcx>,
10431044
ret: Option<mir::BasicBlock>,

src/shims/backtrace.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use rustc_abi::{ExternAbi, Size};
1+
use rustc_abi::Size;
22
use rustc_middle::ty::layout::LayoutOf as _;
33
use rustc_middle::ty::{self, Instance, Ty};
44
use rustc_span::{BytePos, Loc, Symbol, hygiene};
5+
use rustc_target::callconv::{Conv, FnAbi};
56

67
use crate::helpers::check_min_arg_count;
78
use crate::*;
@@ -10,13 +11,13 @@ impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
1011
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1112
fn handle_miri_backtrace_size(
1213
&mut self,
13-
abi: ExternAbi,
14+
abi: &FnAbi<'tcx, Ty<'tcx>>,
1415
link_name: Symbol,
1516
args: &[OpTy<'tcx>],
1617
dest: &MPlaceTy<'tcx>,
1718
) -> InterpResult<'tcx> {
1819
let this = self.eval_context_mut();
19-
let [flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
20+
let [flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
2021

2122
let flags = this.read_scalar(flags)?.to_u64()?;
2223
if flags != 0 {
@@ -30,7 +31,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3031

3132
fn handle_miri_get_backtrace(
3233
&mut self,
33-
abi: ExternAbi,
34+
abi: &FnAbi<'tcx, Ty<'tcx>>,
3435
link_name: Symbol,
3536
args: &[OpTy<'tcx>],
3637
dest: &MPlaceTy<'tcx>,
@@ -71,7 +72,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
7172
// storage for pointers is allocated by miri
7273
// deallocating the slice is undefined behavior with a custom global allocator
7374
0 => {
74-
let [_flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
75+
let [_flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
7576

7677
let alloc = this.allocate(array_layout, MiriMemoryKind::Rust.into())?;
7778

@@ -86,7 +87,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8687
}
8788
// storage for pointers is allocated by the caller
8889
1 => {
89-
let [_flags, buf] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
90+
let [_flags, buf] = this.check_shim(abi, Conv::Rust, link_name, args)?;
9091

9192
let buf_place = this.deref_pointer(buf)?;
9293

@@ -136,13 +137,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
136137

137138
fn handle_miri_resolve_frame(
138139
&mut self,
139-
abi: ExternAbi,
140+
abi: &FnAbi<'tcx, Ty<'tcx>>,
140141
link_name: Symbol,
141142
args: &[OpTy<'tcx>],
142143
dest: &MPlaceTy<'tcx>,
143144
) -> InterpResult<'tcx> {
144145
let this = self.eval_context_mut();
145-
let [ptr, flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
146+
let [ptr, flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
146147

147148
let flags = this.read_scalar(flags)?.to_u64()?;
148149

@@ -207,14 +208,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
207208

208209
fn handle_miri_resolve_frame_names(
209210
&mut self,
210-
abi: ExternAbi,
211+
abi: &FnAbi<'tcx, Ty<'tcx>>,
211212
link_name: Symbol,
212213
args: &[OpTy<'tcx>],
213214
) -> InterpResult<'tcx> {
214215
let this = self.eval_context_mut();
215216

216217
let [ptr, flags, name_ptr, filename_ptr] =
217-
this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
218+
this.check_shim(abi, Conv::Rust, link_name, args)?;
218219

219220
let flags = this.read_scalar(flags)?.to_u64()?;
220221
if flags != 0 {

0 commit comments

Comments
 (0)