Skip to content
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

Include ABI information in rustc_layout(debug) #115168

Closed
RalfJung opened this issue Aug 24, 2023 · 3 comments · Fixed by #115226
Closed

Include ABI information in rustc_layout(debug) #115168

RalfJung opened this issue Aug 24, 2023 · 3 comments · Fixed by #115226

Comments

@RalfJung
Copy link
Member

It is currently rather hard to figure out which PassMode a type will get. It would be great to have some way to display that information, similar to rustc_layout(debug). The logic for computing PassMode is currently here and we'd have to find some way to invoke it:

let mut arg = ArgAbi::new(cx, layout, |layout, scalar, offset| {
let mut attrs = ArgAttributes::new();
adjust_for_rust_scalar(
*cx,
&mut attrs,
scalar,
*layout,
offset,
is_return,
drop_target_pointee,
);
attrs
});

@eddyb @bjorn3 any advice on how to implement this? Or is it meaningless to ask about the PassMode of a type, since this has to always be considered in the context of a particular function signature?

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 24, 2023
@RalfJung
Copy link
Member Author

RalfJung commented Aug 24, 2023

I should also note that the PassMode type is really confusing. For example, PassMode::Indirect has an on_stack field, but it also carries an ArgAttributes that has an IN_REG flag -- so the argument can be both on the stack and in a register at the same time? That obviously wouldn't make any sense, but the representation allows it...

@RalfJung
Copy link
Member Author

I found this gem

fn_abi_adjust_for_abi(cx, &mut fn_abi, sig.abi, fn_def_id)?;

so yeah I guess there's no way to say anything about the context of a concrete function signature. Fun times...

@bjorn3
Copy link
Member

bjorn3 commented Aug 24, 2023

For example, PassMode::Indirect has an on_stack field, but it also carries an ArgAttributes that has an IN_RET flag -- so the argument can be both on the stack and in a register at the same time?

You mean InReg? I'm not quite sure what it exactly does, but I did assume it would be better served as separate flag for PassMode::Direct and possibly PassMode::Pair.

Maybe we could have a #[rustc_fn_abi(debug)] attribute to be applied to functions and then whenever said function is monomorphized (or in case of an extern {} function whenever it is referenced) we could print the computed FnAbi?

@bors bors closed this as completed in 0fe46ee Aug 27, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Aug 29, 2023
add rustc_abi debugging attribute

This is the call ABI equivalent of `rustc_layout(debug)`.

Fixes rust-lang/rust#115168
r? `@bjorn3`
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants