-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
miri function argument passing should use FnAbi #56166
Comments
It seems this issue has been open for a while, is it still relevant? If so, I would like to take a shot at it 😄. |
Awesome! Nobody has been working on this so far, so you are free to grab it. :) @eddyb your mentoring is needed :D |
I have started with the refactoring by moving the @eddyb do you have some pointers on this? I might also ask around on IRC. Perhaps I should change the signature to be |
Figured out the situation with the |
I have created a duplicate implementation of Current changes are in my fork, should I already turn it into a WIP pull request? |
That's a good idea, because it makes commenting on the impl much easier |
@RalfJung cx.type_is_freeze(ty)
ty.is_freeze(cx, ParamEnv::reveal_all(), DUMMY_SPAN) Instead of moving |
Done! |
Depends on how often it gets called. But really I have very little experience in rustc outside miri, so I'll leave this to @eddyb. |
@eddyb Regarding moving This is defined in pub trait FnTypeExt<'tcx> {
fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self;
fn new(cx: &CodegenCx<'ll, 'tcx>,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>]) -> Self;
fn new_vtable(cx: &CodegenCx<'ll, 'tcx>,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>]) -> Self;
fn new_internal(
cx: &CodegenCx<'ll, 'tcx>,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>],
mk_arg_type: impl Fn(Ty<'tcx>, Option<usize>) -> ArgType<'tcx, Ty<'tcx>>,
) -> Self;
fn adjust_for_abi(&mut self,
cx: &CodegenCx<'ll, 'tcx>,
abi: Abi);
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn llvm_cconv(&self) -> llvm::CallConv;
fn apply_attrs_llfn(&self, llfn: &'ll Value);
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value);
} Looks like we need to move everything except fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn llvm_cconv(&self) -> llvm::CallConv;
fn apply_attrs_llfn(&self, llfn: &'ll Value); These methods seem to so some conversion from |
… r=eddyb refactor some `FnType` stuff to `rustc::ty::layout` Does work in the direction of rust-lang#56166.
refactor some `FnType` stuff to `rustc::ty::layout` Does work in the direction of #56166.
Also see what @eddyb wrote at rust-lang/miri#1038 (comment) |
So... what would it take to use this in Miri? @eddyb @oli-obk and maybe @bjorn3
and adjust the Is there code in our codegen backends that uses |
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:Cc @oli-obk
The text was updated successfully, but these errors were encountered: