Skip to content

Commit 55eaabd

Browse files
committed
Change a few ExternAbi to COnv
1 parent dd44fe1 commit 55eaabd

File tree

3 files changed

+132
-117
lines changed

3 files changed

+132
-117
lines changed

src/tools/miri/src/helpers.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -920,26 +920,39 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
920920
}
921921

922922
/// Check that the ABI is what we expect.
923-
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: ExternAbi) -> InterpResult<'a, ()> {
924-
let call_conv;
923+
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
924+
let caller_abi_name;
925+
let callee_abi_name;
925926
match fn_abi.conv {
926927
Conv::C => {
927-
// TODO: unwind what?
928-
call_conv = ExternAbi::C { unwind: false};
928+
caller_abi_name = "C";
929929
},
930930
Conv::Rust => {
931-
call_conv = ExternAbi::Rust;
931+
caller_abi_name = "Rust";
932932
},
933933
_=> {
934934
// TODO: What is a better way of doing this?
935-
panic!("Unsupported calling convention");
935+
panic!("Unsupported caller ABI");
936936
}
937937
};
938-
if call_conv != exp_abi {
938+
match exp_abi {
939+
Conv::C => {
940+
callee_abi_name = "C";
941+
},
942+
Conv::Rust => {
943+
callee_abi_name = "Rust";
944+
},
945+
_=> {
946+
// TODO: What is a better way of doing this?
947+
panic!("Unsupported callee ABI");
948+
}
949+
}
950+
951+
if fn_abi.conv != exp_abi {
939952
throw_ub_format!(
940953
"calling a function with ABI {} using caller ABI {}",
941-
exp_abi.name(),
942-
call_conv.name()
954+
callee_abi_name,
955+
caller_abi_name
943956
)
944957
}
945958
interp_ok(())
@@ -971,7 +984,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
971984
fn check_abi_and_shim_symbol_clash(
972985
&mut self,
973986
abi: &FnAbi<'tcx, Ty<'tcx>>,
974-
exp_abi: ExternAbi,
987+
exp_abi: Conv,
975988
link_name: Symbol,
976989
) -> InterpResult<'tcx, ()> {
977990
self.check_abi(abi, exp_abi)?;
@@ -996,7 +1009,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
9961009
fn check_shim<'a, const N: usize>(
9971010
&mut self,
9981011
abi: &FnAbi<'tcx, Ty<'tcx>>,
999-
exp_abi: ExternAbi,
1012+
exp_abi: Conv,
10001013
link_name: Symbol,
10011014
args: &'a [OpTy<'tcx>],
10021015
) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]>

src/tools/miri/src/shims/backtrace.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use rustc_abi::{ExternAbi, Size};
1+
use rustc_abi::Size;
22
use rustc_ast::ast::Mutability;
33
use rustc_middle::ty::layout::LayoutOf as _;
44
use rustc_middle::ty::{self, Instance, Ty};
55
use rustc_span::{BytePos, Loc, Symbol, hygiene};
66
use rustc_target::callconv::FnAbi;
7+
use rustc_target::callconv::Conv;
78

89
use crate::helpers::check_min_arg_count;
910
use crate::*;
@@ -18,7 +19,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1819
dest: &MPlaceTy<'tcx>,
1920
) -> InterpResult<'tcx> {
2021
let this = self.eval_context_mut();
21-
let [flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
22+
let [flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
2223

2324
let flags = this.read_scalar(flags)?.to_u64()?;
2425
if flags != 0 {
@@ -73,7 +74,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
7374
// storage for pointers is allocated by miri
7475
// deallocating the slice is undefined behavior with a custom global allocator
7576
0 => {
76-
let [_flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
77+
let [_flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
7778

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

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

9394
let buf_place = this.deref_pointer(buf)?;
9495

@@ -144,7 +145,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
144145
dest: &MPlaceTy<'tcx>,
145146
) -> InterpResult<'tcx> {
146147
let this = self.eval_context_mut();
147-
let [ptr, flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
148+
let [ptr, flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
148149

149150
let flags = this.read_scalar(flags)?.to_u64()?;
150151

@@ -223,7 +224,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
223224
let this = self.eval_context_mut();
224225

225226
let [ptr, flags, name_ptr, filename_ptr] =
226-
this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
227+
this.check_shim(abi, Conv::Rust, link_name, args)?;
227228

228229
let flags = this.read_scalar(flags)?.to_u64()?;
229230
if flags != 0 {

0 commit comments

Comments
 (0)