Skip to content

Commit 8ab86bb

Browse files
Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errors
Rename `rustc_abi::Abi` to `BackendRepr` Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights. Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2 parents fdc228f + b6c6de4 commit 8ab86bb

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use std::cell::RefCell;
99
use std::fmt::Write;
1010
use std::{cmp, mem};
1111

12+
use rustc_abi::{BackendRepr, Size};
1213
use rustc_data_structures::fx::FxHashSet;
1314
use rustc_middle::mir::{Mutability, RetagKind};
1415
use rustc_middle::ty::layout::HasParamEnv;
1516
use rustc_middle::ty::{self, Ty};
16-
use rustc_target::abi::{Abi, Size};
1717

1818
use self::diagnostics::{RetagCause, RetagInfo};
1919
pub use self::item::{Item, Permission};
@@ -972,7 +972,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
972972
RetagFields::OnlyScalar => {
973973
// Matching `ArgAbi::new` at the time of writing, only fields of
974974
// `Scalar` and `ScalarPair` ABI are considered.
975-
matches!(place.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..))
975+
matches!(
976+
place.layout.backend_repr,
977+
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)
978+
)
976979
}
977980
};
978981
if recurse {

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use rustc_abi::{BackendRepr, Size};
12
use rustc_middle::mir::{Mutability, RetagKind};
23
use rustc_middle::ty::layout::HasParamEnv;
34
use rustc_middle::ty::{self, Ty};
45
use rustc_span::def_id::DefId;
5-
use rustc_target::abi::{Abi, Size};
66

77
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
88
use crate::concurrency::data_race::NaReadType;
@@ -495,7 +495,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
495495
RetagFields::OnlyScalar => {
496496
// Matching `ArgAbi::new` at the time of writing, only fields of
497497
// `Scalar` and `ScalarPair` ABI are considered.
498-
matches!(place.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..))
498+
matches!(
499+
place.layout.backend_repr,
500+
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)
501+
)
499502
}
500503
};
501504
if recurse {

src/helpers.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
349349
i: impl Into<i128>,
350350
dest: &impl Writeable<'tcx, Provenance>,
351351
) -> InterpResult<'tcx> {
352-
assert!(dest.layout().abi.is_scalar(), "write_int on non-scalar type {}", dest.layout().ty);
353-
let val = if dest.layout().abi.is_signed() {
352+
assert!(
353+
dest.layout().backend_repr.is_scalar(),
354+
"write_int on non-scalar type {}",
355+
dest.layout().ty
356+
);
357+
let val = if dest.layout().backend_repr.is_signed() {
354358
Scalar::from_int(i, dest.layout().size)
355359
} else {
356360
// `unwrap` can only fail here if `i` is negative

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern crate either;
5555
extern crate tracing;
5656

5757
// The rustc crates we need
58+
extern crate rustc_abi;
5859
extern crate rustc_apfloat;
5960
extern crate rustc_ast;
6061
extern crate rustc_attr;

src/operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2323

2424
interp_ok(match bin_op {
2525
Eq | Ne | Lt | Le | Gt | Ge => {
26-
assert_eq!(left.layout.abi, right.layout.abi); // types can differ, e.g. fn ptrs with different `for`
26+
assert_eq!(left.layout.backend_repr, right.layout.backend_repr); // types can differ, e.g. fn ptrs with different `for`
2727
let size = this.pointer_size();
2828
// Just compare the bits. ScalarPairs are compared lexicographically.
2929
// We thus always compare pairs and simply fill scalars up with 0.

src/shims/native_lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use libffi::high::call as ffi;
55
use libffi::low::CodePtr;
66
use rustc_middle::ty::{self as ty, IntTy, UintTy};
77
use rustc_span::Symbol;
8-
use rustc_target::abi::{Abi, HasDataLayout};
8+
use rustc_abi::{BackendRepr, HasDataLayout};
99

1010
use crate::*;
1111

@@ -149,7 +149,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
149149
// Get the function arguments, and convert them to `libffi`-compatible form.
150150
let mut libffi_args = Vec::<CArg>::with_capacity(args.len());
151151
for arg in args.iter() {
152-
if !matches!(arg.layout.abi, Abi::Scalar(_)) {
152+
if !matches!(arg.layout.backend_repr, BackendRepr::Scalar(_)) {
153153
throw_unsup_format!("only scalar argument types are support for native calls")
154154
}
155155
libffi_args.push(imm_to_carg(this.read_immediate(arg)?, this)?);

0 commit comments

Comments
 (0)