Description
In the miri engine, when evaluating a function call, it can happen that caller and callee do not agree on the type of an argument. In this case, the argument effectively gets transmuted from the caller type to the callee type. However, this is not legal for all types, and whether it is legal depends on horrible details of the ABI. This logic is implemented for codegen, where it is called FnType
. miri should probably use that same infrastructure.
The relevant code in miri that would need changing is here. Currently, we only allow argument type punning for the Rust ABI, and we only allow the valid range of a Scalar
/ScalarPair
to change -- effectively, we allow one side to have &T
while the other side has *const T
.
For the FnType
side, I do not know much, but @eddyb offered to mentor someone trying to do this cleanup. :) He also left the following hints:
move some code from rustc_codegen_ssa and then compare ArgType pairwise.
The main issue to moving that stuff around is pointee_info_at (it would have to be moved to rustc::ty::layout, as an additional method in TyLayoutMethods):
rust/src/librustc_codegen_llvm/abi.rs
Line 487 in dae6c93
Everything else is mostly relying on rustc_target doing the heavy lifting, already.
Cc @oli-obk