Skip to content

Commit 0b7cb9e

Browse files
committed
Fix all ExternAbi
1 parent 46dd656 commit 0b7cb9e

File tree

18 files changed

+111
-94
lines changed

18 files changed

+111
-94
lines changed

compiler/rustc_const_eval/src/const_eval/dummy_machine.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ impl<'tcx> interpret::Machine<'tcx> for DummyMachine {
8888
fn find_mir_or_eval_fn(
8989
_ecx: &mut InterpCx<'tcx, Self>,
9090
_instance: ty::Instance<'tcx>,
91-
_abi: rustc_abi::ExternAbi,
92-
_fnabi: &FnAbi<'tcx, Ty<'tcx>>,
91+
_abi: &FnAbi<'tcx, Ty<'tcx>>,
9392
_args: &[interpret::FnArg<'tcx, Self::Provenance>],
9493
_destination: &interpret::MPlaceTy<'tcx, Self::Provenance>,
9594
_target: Option<BasicBlock>,

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::{Borrow, Cow};
22
use std::fmt;
33
use std::hash::Hash;
44

5-
use rustc_abi::{Align, ExternAbi, Size};
5+
use rustc_abi::{Align, Size};
66
use rustc_ast::Mutability;
77
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, IndexEntry};
88
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -335,8 +335,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
335335
fn find_mir_or_eval_fn(
336336
ecx: &mut InterpCx<'tcx, Self>,
337337
orig_instance: ty::Instance<'tcx>,
338-
_abi: ExternAbi,
339-
_fnabi: &FnAbi<'tcx, Ty<'tcx>>,
338+
_abi: &FnAbi<'tcx, Ty<'tcx>>,
340339
args: &[FnArg<'tcx>],
341340
dest: &MPlaceTy<'tcx>,
342341
ret: Option<mir::BasicBlock>,

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
519519
return M::call_extra_fn(
520520
self,
521521
extra,
522-
caller_abi,
522+
caller_fn_abi,
523523
args,
524524
destination,
525525
target,
@@ -570,7 +570,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
570570
let Some((body, instance)) = M::find_mir_or_eval_fn(
571571
self,
572572
instance,
573-
caller_abi,
574573
caller_fn_abi,
575574
args,
576575
destination,

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ use std::borrow::{Borrow, Cow};
66
use std::fmt::Debug;
77
use std::hash::Hash;
88

9-
use rustc_abi::{Align, ExternAbi, Size};
9+
use rustc_abi::{Align, Size};
1010
use rustc_apfloat::{Float, FloatConvert};
1111
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1212
use rustc_middle::query::TyCtxtAt;
13-
use rustc_middle::ty::Ty;
13+
1414
use rustc_middle::ty::layout::TyAndLayout;
1515
use rustc_middle::{mir, ty};
1616
use rustc_span::Span;
1717
use rustc_span::def_id::DefId;
1818
use rustc_target::callconv::FnAbi;
19+
use rustc_middle::ty::Ty;
1920

2021
use super::{
2122
AllocBytes, AllocId, AllocKind, AllocRange, Allocation, CTFE_ALLOC_SALT, ConstAllocation,
@@ -202,8 +203,7 @@ pub trait Machine<'tcx>: Sized {
202203
fn find_mir_or_eval_fn(
203204
ecx: &mut InterpCx<'tcx, Self>,
204205
instance: ty::Instance<'tcx>,
205-
abi: ExternAbi,
206-
_fnabi: &FnAbi<'tcx, Ty<'tcx>>,
206+
abi: &FnAbi<'tcx, Ty<'tcx>>,
207207
args: &[FnArg<'tcx, Self::Provenance>],
208208
destination: &MPlaceTy<'tcx, Self::Provenance>,
209209
target: Option<mir::BasicBlock>,
@@ -215,7 +215,7 @@ pub trait Machine<'tcx>: Sized {
215215
fn call_extra_fn(
216216
ecx: &mut InterpCx<'tcx, Self>,
217217
fn_val: Self::ExtraFnVal,
218-
abi: ExternAbi,
218+
abi: &FnAbi<'tcx, Ty<'tcx>>,
219219
args: &[FnArg<'tcx, Self::Provenance>],
220220
destination: &MPlaceTy<'tcx, Self::Provenance>,
221221
target: Option<mir::BasicBlock>,
@@ -654,7 +654,7 @@ pub macro compile_time_machine(<$tcx: lifetime>) {
654654
fn call_extra_fn(
655655
_ecx: &mut InterpCx<$tcx, Self>,
656656
fn_val: !,
657-
_abi: ExternAbi,
657+
_abi: &FnAbi<$tcx, Ty<$tcx>>,
658658
_args: &[FnArg<$tcx>],
659659
_destination: &MPlaceTy<$tcx, Self::Provenance>,
660660
_target: Option<mir::BasicBlock>,

src/tools/miri/src/helpers.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -936,11 +936,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
936936
}
937937
};
938938
if call_conv != exp_abi {
939-
throw_ub_format!(
940-
"calling a function with ABI {} using caller ABI {}",
941-
exp_abi.name(),
942-
call_conv.name()
943-
)
939+
throw_ub_format!(
940+
"calling a function with ABI {} using caller ABI {}",
941+
exp_abi.name(),
942+
call_conv.name()
943+
)
944944
}
945945
interp_ok(())
946946
}
@@ -970,11 +970,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
970970

971971
fn check_abi_and_shim_symbol_clash(
972972
&mut self,
973-
fnabi: &FnAbi<'tcx, Ty<'tcx>>,
973+
abi: &FnAbi<'tcx, Ty<'tcx>>,
974974
exp_abi: ExternAbi,
975975
link_name: Symbol,
976976
) -> InterpResult<'tcx, ()> {
977-
self.check_abi(fnabi, exp_abi)?;
977+
self.check_abi(abi, exp_abi)?;
978978
if let Some((body, instance)) = self.eval_context_mut().lookup_exported_symbol(link_name)? {
979979
// If compiler-builtins is providing the symbol, then don't treat it as a clash.
980980
// We'll use our built-in implementation in `emulate_foreign_item_inner` for increased
@@ -995,16 +995,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
995995

996996
fn check_shim<'a, const N: usize>(
997997
&mut self,
998-
abi: ExternAbi,
999-
_fnabi: &FnAbi<'tcx, Ty<'tcx>>,
998+
abi: &FnAbi<'tcx, Ty<'tcx>>,
1000999
exp_abi: ExternAbi,
10011000
link_name: Symbol,
10021001
args: &'a [OpTy<'tcx>],
10031002
) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]>
10041003
where
10051004
&'a [OpTy<'tcx>; N]: TryFrom<&'a [OpTy<'tcx>]>,
10061005
{
1007-
self.check_abi_and_shim_symbol_clash(_fnabi, exp_abi, link_name)?;
1006+
self.check_abi_and_shim_symbol_clash(abi, exp_abi, link_name)?;
10081007
check_arg_count(args)
10091008
}
10101009

src/tools/miri/src/machine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_session::config::InliningThreshold;
2424
use rustc_span::def_id::{CrateNum, DefId};
2525
use rustc_span::{Span, SpanData, Symbol};
2626

27+
2728
use crate::concurrency::cpu_affinity::{self, CpuAffinityMask};
2829
use crate::concurrency::data_race::{self, NaReadType, NaWriteType};
2930
use crate::concurrency::weak_memory;
@@ -1006,8 +1007,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10061007
fn find_mir_or_eval_fn(
10071008
ecx: &mut MiriInterpCx<'tcx>,
10081009
instance: ty::Instance<'tcx>,
1009-
abi: ExternAbi,
1010-
_fnabi: &FnAbi<'tcx, Ty<'tcx>>,
1010+
abi: &FnAbi<'tcx, Ty<'tcx>>,
10111011
args: &[FnArg<'tcx, Provenance>],
10121012
dest: &MPlaceTy<'tcx>,
10131013
ret: Option<mir::BasicBlock>,
@@ -1023,7 +1023,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10231023
// Any needed call to `goto_block` will be performed by `emulate_foreign_item`.
10241024
let args = ecx.copy_fn_args(args); // FIXME: Should `InPlace` arguments be reset to uninit?
10251025
let link_name = Symbol::intern(ecx.tcx.symbol_name(instance).name);
1026-
return ecx.emulate_foreign_item(link_name, abi, _fnabi, &args, dest, ret, unwind);
1026+
return ecx.emulate_foreign_item(link_name, abi, &args, dest, ret, unwind);
10271027
}
10281028

10291029
// Otherwise, load the MIR.
@@ -1034,7 +1034,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10341034
fn call_extra_fn(
10351035
ecx: &mut MiriInterpCx<'tcx>,
10361036
fn_val: DynSym,
1037-
abi: ExternAbi,
1037+
abi: &FnAbi<'tcx, Ty<'tcx>>,
10381038
args: &[FnArg<'tcx, Provenance>],
10391039
dest: &MPlaceTy<'tcx>,
10401040
ret: Option<mir::BasicBlock>,

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
1212
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1313
fn handle_miri_backtrace_size(
1414
&mut self,
15-
fnabi: &FnAbi<'tcx, Ty<'tcx>>,
15+
abi: &FnAbi<'tcx, Ty<'tcx>>,
1616
link_name: Symbol,
1717
args: &[OpTy<'tcx>],
1818
dest: &MPlaceTy<'tcx>,
1919
) -> InterpResult<'tcx> {
2020
let this = self.eval_context_mut();
21-
let [flags] = this.check_shim(fnabi, ExternAbi::Rust, link_name, args)?;
21+
let [flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
2222

2323
let flags = this.read_scalar(flags)?.to_u64()?;
2424
if flags != 0 {
@@ -32,7 +32,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3232

3333
fn handle_miri_get_backtrace(
3434
&mut self,
35-
abi: ExternAbi,
35+
abi: &FnAbi<'tcx, Ty<'tcx>>,
3636
link_name: Symbol,
3737
args: &[OpTy<'tcx>],
3838
dest: &MPlaceTy<'tcx>,
@@ -138,13 +138,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
138138

139139
fn handle_miri_resolve_frame(
140140
&mut self,
141-
fnabi: &FnAbi<'tcx, Ty<'tcx>>,
141+
abi: &FnAbi<'tcx, Ty<'tcx>>,
142142
link_name: Symbol,
143143
args: &[OpTy<'tcx>],
144144
dest: &MPlaceTy<'tcx>,
145145
) -> InterpResult<'tcx> {
146146
let this = self.eval_context_mut();
147-
let [ptr, flags] = this.check_shim(fnabi, ExternAbi::Rust, link_name, args)?;
147+
let [ptr, flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
148148

149149
let flags = this.read_scalar(flags)?.to_u64()?;
150150

@@ -216,14 +216,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
216216

217217
fn handle_miri_resolve_frame_names(
218218
&mut self,
219-
fnabi: &FnAbi<'tcx, Ty<'tcx>>,
219+
abi: &FnAbi<'tcx, Ty<'tcx>>,
220220
link_name: Symbol,
221221
args: &[OpTy<'tcx>],
222222
) -> InterpResult<'tcx> {
223223
let this = self.eval_context_mut();
224224

225225
let [ptr, flags, name_ptr, filename_ptr] =
226-
this.check_shim(fnabi, ExternAbi::Rust, link_name, args)?;
226+
this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
227227

228228
let flags = this.read_scalar(flags)?.to_u64()?;
229229
if flags != 0 {

0 commit comments

Comments
 (0)