Skip to content

Commit 3732391

Browse files
committed
Change other ExternAbi to Conv
1 parent 55eaabd commit 3732391

29 files changed

+224
-224
lines changed

src/tools/miri/src/bin/miri.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::path::PathBuf;
2929
use std::str::FromStr;
3030

3131
use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode};
32-
use rustc_abi::ExternAbi;
3332
use rustc_data_structures::sync::Lrc;
3433
use rustc_driver::Compilation;
3534
use rustc_hir::def_id::LOCAL_CRATE;
@@ -368,7 +367,7 @@ fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
368367
tcx.types.isize,
369368
false,
370369
hir::Safety::Safe,
371-
ExternAbi::Rust,
370+
Conv::Rust,
372371
));
373372

374373
let correct_func_sig = check_function_signature(

src/tools/miri/src/eval.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::path::PathBuf;
66
use std::task::Poll;
77
use std::{iter, thread};
88

9-
use rustc_abi::ExternAbi;
9+
1010
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1111
use rustc_hir::def::Namespace;
1212
use rustc_hir::def_id::DefId;
@@ -391,7 +391,7 @@ pub fn create_ecx<'tcx>(
391391

392392
ecx.call_function(
393393
start_instance,
394-
ExternAbi::Rust,
394+
Conv::Rust,
395395
&[
396396
ImmTy::from_scalar(
397397
Scalar::from_pointer(main_ptr, &ecx),
@@ -409,7 +409,7 @@ pub fn create_ecx<'tcx>(
409409
EntryFnType::Start => {
410410
ecx.call_function(
411411
entry_instance,
412-
ExternAbi::Rust,
412+
Conv::Rust,
413413
&[argc, argv],
414414
Some(&ret_place),
415415
StackPopCleanup::Root { cleanup: true },

src/tools/miri/src/machine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{fmt, process};
1010

1111
use rand::rngs::StdRng;
1212
use rand::{Rng, SeedableRng};
13-
use rustc_abi::{Align, ExternAbi, Size};
13+
use rustc_abi::{Align, Size};
1414
use rustc_target::callconv::FnAbi;
1515
use rustc_attr::InlineAttr;
1616
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -1076,7 +1076,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10761076
// Call the lang item.
10771077
let panic = ecx.tcx.lang_items().get(reason.lang_item()).unwrap();
10781078
let panic = ty::Instance::mono(ecx.tcx.tcx, panic);
1079-
ecx.call_function(panic, ExternAbi::Rust, &[], None, StackPopCleanup::Goto {
1079+
ecx.call_function(panic, Conv::Rust, &[], None, StackPopCleanup::Goto {
10801080
ret: None,
10811081
unwind: mir::UnwindAction::Unreachable,
10821082
})?;

src/tools/miri/src/shims/foreign_items.rs

+39-39
Large diffs are not rendered by default.

src/tools/miri/src/shims/panic.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! gets popped *during unwinding*, we take the panic payload and store it according to the extra
1212
//! metadata we remembered when pushing said frame.
1313
14-
use rustc_abi::ExternAbi;
1514
use rustc_ast::Mutability;
1615
use rustc_middle::{mir, ty};
1716
use rustc_target::spec::PanicStrategy;
@@ -88,7 +87,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8887
trace!("try_fn: {:?}", f_instance);
8988
this.call_function(
9089
f_instance,
91-
ExternAbi::Rust,
90+
Conv::Rust,
9291
&[data.clone()],
9392
None,
9493
// Directly return to caller.
@@ -139,7 +138,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
139138
trace!("catch_fn: {:?}", f_instance);
140139
this.call_function(
141140
f_instance,
142-
ExternAbi::Rust,
141+
Conv::Rust,
143142
&[catch_unwind.data, payload],
144143
None,
145144
// Directly return to caller of `try`.
@@ -168,7 +167,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
168167
let panic = ty::Instance::mono(this.tcx.tcx, panic);
169168
this.call_function(
170169
panic,
171-
ExternAbi::Rust,
170+
Conv::Rust,
172171
&[this.mplace_to_ref(&msg)?],
173172
None,
174173
StackPopCleanup::Goto { ret: None, unwind },
@@ -187,7 +186,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
187186
let panic = ty::Instance::mono(this.tcx.tcx, panic);
188187
this.call_function(
189188
panic,
190-
ExternAbi::Rust,
189+
Conv::Rust,
191190
&[this.mplace_to_ref(&msg)?],
192191
None,
193192
StackPopCleanup::Goto { ret: None, unwind: mir::UnwindAction::Unreachable },
@@ -216,7 +215,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
216215
let panic_bounds_check = ty::Instance::mono(this.tcx.tcx, panic_bounds_check);
217216
this.call_function(
218217
panic_bounds_check,
219-
ExternAbi::Rust,
218+
Conv::Rust,
220219
&[index, len],
221220
None,
222221
StackPopCleanup::Goto { ret: None, unwind },
@@ -237,7 +236,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
237236
ty::Instance::mono(this.tcx.tcx, panic_misaligned_pointer_dereference);
238237
this.call_function(
239238
panic_misaligned_pointer_dereference,
240-
ExternAbi::Rust,
239+
Conv::Rust,
241240
&[required, found],
242241
None,
243242
StackPopCleanup::Goto { ret: None, unwind },
@@ -248,7 +247,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
248247
// Call the lang item associated with this message.
249248
let fn_item = this.tcx.require_lang_item(msg.panic_function(), None);
250249
let instance = ty::Instance::mono(this.tcx.tcx, fn_item);
251-
this.call_function(instance, ExternAbi::Rust, &[], None, StackPopCleanup::Goto {
250+
this.call_function(instance, Conv::Rust, &[], None, StackPopCleanup::Goto {
252251
ret: None,
253252
unwind,
254253
})?;

src/tools/miri/src/shims/tls.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::BTreeMap;
44
use std::collections::btree_map::Entry as BTreeEntry;
55
use std::task::Poll;
66

7-
use rustc_abi::{ExternAbi, HasDataLayout, Size};
7+
use rustc_abi::{HasDataLayout, Size};
88
use rustc_middle::ty;
99

1010
use crate::*;
@@ -322,6 +322,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
322322
// but both are ignored by std.
323323
this.call_function(
324324
thread_callback,
325+
// TODO: is there any equivalent Conv:: that we can use here?
325326
ExternAbi::System { unwind: false },
326327
&[null_ptr.clone(), ImmTy::from_scalar(reason, this.machine.layouts.u32), null_ptr],
327328
None,
@@ -343,7 +344,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
343344

344345
this.call_function(
345346
instance,
346-
ExternAbi::C { unwind: false },
347+
Conv::C,
347348
&[ImmTy::from_scalar(data, this.machine.layouts.mut_raw_ptr)],
348349
None,
349350
StackPopCleanup::Root { cleanup: true },
@@ -380,7 +381,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
380381

381382
this.call_function(
382383
instance,
383-
ExternAbi::C { unwind: false },
384+
Conv::C,
384385
&[ImmTy::from_scalar(ptr, this.machine.layouts.mut_raw_ptr)],
385386
None,
386387
StackPopCleanup::Root { cleanup: true },

src/tools/miri/src/shims/unix/android/foreign_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_abi::ExternAbi;
1+
22
use rustc_span::Symbol;
33
use rustc_target::callconv::FnAbi;
44
use rustc_middle::ty::Ty;
@@ -24,7 +24,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2424
match link_name.as_str() {
2525
// Miscellaneous
2626
"__errno" => {
27-
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
27+
let [] = this.check_shim(abi, Conv::C, link_name, args)?;
2828
let errno_place = this.last_error_place()?;
2929
this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
3030
}

src/tools/miri/src/shims/unix/android/thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_abi::{ExternAbi, Size};
1+
use rustc_abi::Size;
22
use rustc_span::Symbol;
33
use rustc_target::callconv::FnAbi;
44
use rustc_middle::ty::Ty;
@@ -18,7 +18,7 @@ pub fn prctl<'tcx>(
1818
) -> InterpResult<'tcx> {
1919
// We do not use `check_shim` here because `prctl` is variadic. The argument
2020
// count is checked bellow.
21-
this.check_abi_and_shim_symbol_clash(abi, ExternAbi::C { unwind: false }, link_name)?;
21+
this.check_abi_and_shim_symbol_clash(abi, Conv::C, link_name)?;
2222

2323
// FIXME: Use constants once https://github.com/rust-lang/libc/pull/3941 backported to the 0.2 branch.
2424
let pr_set_name = 15;

src/tools/miri/src/shims/unix/freebsd/foreign_items.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_abi::ExternAbi;
1+
22
use rustc_span::Symbol;
33
use rustc_target::callconv::FnAbi;
44
use rustc_middle::ty::Ty;
@@ -24,7 +24,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2424
// Threading
2525
"pthread_set_name_np" => {
2626
let [thread, name] =
27-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
27+
this.check_shim(abi, Conv::C, link_name, args)?;
2828
let max_len = usize::MAX; // FreeBSD does not seem to have a limit.
2929
// FreeBSD's pthread_set_name_np does not return anything.
3030
this.pthread_setname_np(
@@ -36,7 +36,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3636
}
3737
"pthread_get_name_np" => {
3838
let [thread, name, len] =
39-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
39+
this.check_shim(abi, Conv::C, link_name, args)?;
4040
// FreeBSD's pthread_get_name_np does not return anything
4141
// and uses strlcpy, which truncates the resulting value,
4242
// but always adds a null terminator (except for zero-sized buffers).
@@ -54,32 +54,32 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5454
// since freebsd 12 the former form can be expected.
5555
"stat" | "stat@FBSD_1.0" => {
5656
let [path, buf] =
57-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
57+
this.check_shim(abi, Conv::C, link_name, args)?;
5858
let result = this.macos_fbsd_stat(path, buf)?;
5959
this.write_scalar(result, dest)?;
6060
}
6161
"lstat" | "lstat@FBSD_1.0" => {
6262
let [path, buf] =
63-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
63+
this.check_shim(abi, Conv::C, link_name, args)?;
6464
let result = this.macos_fbsd_lstat(path, buf)?;
6565
this.write_scalar(result, dest)?;
6666
}
6767
"fstat" | "fstat@FBSD_1.0" => {
6868
let [fd, buf] =
69-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
69+
this.check_shim(abi, Conv::C, link_name, args)?;
7070
let result = this.macos_fbsd_fstat(fd, buf)?;
7171
this.write_scalar(result, dest)?;
7272
}
7373
"readdir_r" | "readdir_r@FBSD_1.0" => {
7474
let [dirp, entry, result] =
75-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
75+
this.check_shim(abi, Conv::C, link_name, args)?;
7676
let result = this.macos_fbsd_readdir_r(dirp, entry, result)?;
7777
this.write_scalar(result, dest)?;
7878
}
7979

8080
// Miscellaneous
8181
"__error" => {
82-
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
82+
let [] = this.check_shim(abi, Conv::C, link_name, args)?;
8383
let errno_place = this.last_error_place()?;
8484
this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
8585
}
@@ -88,7 +88,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8888
// These shims are enabled only when the caller is in the standard library.
8989
"pthread_attr_get_np" if this.frame_in_std() => {
9090
let [_thread, _attr] =
91-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
91+
this.check_shim(abi, Conv::C, link_name, args)?;
9292
this.write_null(dest)?;
9393
}
9494

src/tools/miri/src/shims/unix/linux/foreign_items.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -37,52 +37,52 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3737
// File related shims
3838
"readdir64" => {
3939
let [dirp] =
40-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
40+
this.check_shim(abi, Conv::C, link_name, args)?;
4141
let result = this.linux_readdir64(dirp)?;
4242
this.write_scalar(result, dest)?;
4343
}
4444
"sync_file_range" => {
4545
let [fd, offset, nbytes, flags] =
46-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
46+
this.check_shim(abi, Conv::C, link_name, args)?;
4747
let result = this.sync_file_range(fd, offset, nbytes, flags)?;
4848
this.write_scalar(result, dest)?;
4949
}
5050
"statx" => {
5151
let [dirfd, pathname, flags, mask, statxbuf] =
52-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
52+
this.check_shim(abi, Conv::C, link_name, args)?;
5353
let result = this.linux_statx(dirfd, pathname, flags, mask, statxbuf)?;
5454
this.write_scalar(result, dest)?;
5555
}
5656

5757
// epoll, eventfd
5858
"epoll_create1" => {
5959
let [flag] =
60-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
60+
this.check_shim(abi, Conv::C, link_name, args)?;
6161
let result = this.epoll_create1(flag)?;
6262
this.write_scalar(result, dest)?;
6363
}
6464
"epoll_ctl" => {
6565
let [epfd, op, fd, event] =
66-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
66+
this.check_shim(abi, Conv::C, link_name, args)?;
6767
let result = this.epoll_ctl(epfd, op, fd, event)?;
6868
this.write_scalar(result, dest)?;
6969
}
7070
"epoll_wait" => {
7171
let [epfd, events, maxevents, timeout] =
72-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
72+
this.check_shim(abi, Conv::C, link_name, args)?;
7373
this.epoll_wait(epfd, events, maxevents, timeout, dest)?;
7474
}
7575
"eventfd" => {
7676
let [val, flag] =
77-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
77+
this.check_shim(abi, Conv::C, link_name, args)?;
7878
let result = this.eventfd(val, flag)?;
7979
this.write_scalar(result, dest)?;
8080
}
8181

8282
// Threading
8383
"pthread_setname_np" => {
8484
let [thread, name] =
85-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
85+
this.check_shim(abi, Conv::C, link_name, args)?;
8686
let res = match this.pthread_setname_np(
8787
this.read_scalar(thread)?,
8888
this.read_scalar(name)?,
@@ -98,7 +98,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
9898
}
9999
"pthread_getname_np" => {
100100
let [thread, name, len] =
101-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
101+
this.check_shim(abi, Conv::C, link_name, args)?;
102102
// The function's behavior isn't portable between platforms.
103103
// In case of glibc, the length of the output buffer must
104104
// be not shorter than TASK_COMM_LEN.
@@ -121,7 +121,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
121121
this.write_scalar(res, dest)?;
122122
}
123123
"gettid" => {
124-
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
124+
let [] = this.check_shim(abi, Conv::C, link_name, args)?;
125125
let result = this.linux_gettid()?;
126126
this.write_scalar(result, dest)?;
127127
}
@@ -134,29 +134,29 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
134134
// Miscellaneous
135135
"mmap64" => {
136136
let [addr, length, prot, flags, fd, offset] =
137-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
137+
this.check_shim(abi, Conv::C, link_name, args)?;
138138
let offset = this.read_scalar(offset)?.to_i64()?;
139139
let ptr = this.mmap(addr, length, prot, flags, fd, offset.into())?;
140140
this.write_scalar(ptr, dest)?;
141141
}
142142
"mremap" => {
143143
let [old_address, old_size, new_size, flags] =
144-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
144+
this.check_shim(abi, Conv::C, link_name, args)?;
145145
let ptr = this.mremap(old_address, old_size, new_size, flags)?;
146146
this.write_scalar(ptr, dest)?;
147147
}
148148
"__errno_location" => {
149-
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
149+
let [] = this.check_shim(abi, Conv::C, link_name, args)?;
150150
let errno_place = this.last_error_place()?;
151151
this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
152152
}
153153
"__libc_current_sigrtmin" => {
154-
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
154+
let [] = this.check_shim(abi, Conv::C, link_name, args)?;
155155

156156
this.write_int(SIGRTMIN, dest)?;
157157
}
158158
"__libc_current_sigrtmax" => {
159-
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
159+
let [] = this.check_shim(abi, Conv::C, link_name, args)?;
160160

161161
this.write_int(SIGRTMAX, dest)?;
162162
}
@@ -165,7 +165,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
165165
// These shims are enabled only when the caller is in the standard library.
166166
"pthread_getattr_np" if this.frame_in_std() => {
167167
let [_thread, _attr] =
168-
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
168+
this.check_shim(abi, Conv::C, link_name, args)?;
169169
this.write_null(dest)?;
170170
}
171171

0 commit comments

Comments
 (0)