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
NVPTX: Avoid PassMode::Direct for args in C abi #117671
base: master
Are you sure you want to change the base?
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
@rustbot label +O-NVPTX |
Sadly, no. The best we have are the API docs. I improved them a bit recently, but we are still lacking some proper "big-picture" docs for this. largely this is because while the system was designed with some big-picture ideas ~5 years ago, those were not written down at the time and since then it's been hotfixed and patched without regard for a coherent story. The entire system needs an overhaul. See rust-lang/compiler-team#672: the compiler team accepted the proposal to overhaul this, but we're still looking for a volunteer to do the work.
😂 I knew nothing about this until around 3 months ago, and spent way too much time on it since.^^ I still don't feel like an expert, since all I know is reverse engineered from looking at parts of rustc. There are many things about ABI I do not know. But at this point I think I know at least how rustc deals with ABI, and I know some necessary (but not sufficient) conditions for ABI adjustments to make sense. |
Sadly, for this PR, I can't really tell if it makes any sense. But if it helps fix the assertions and also still generates working code for your tests, then it's at least an improvement... |
I think you will want to use |
I did experiment with casting to #[repr(C)]
pub struct SingleU8 {
f: u8,
} The problem was that since it was passed as a single register of size 8bit it passed it like a primitive type |
😱 |
Sorry, too busy to review this 😰 r? compiler |
r? compiler |
☔ The latest upstream changes (presumably #117500) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay in getting to this - we don't have an expert in NVPTX on the team, so I'll take a stab at reviewing this so it isn't stuck forever. It seems reasonable to me.
Does this mean that NVPTX can be re-enabled in tests/ui/abi/compatibility.rs
now? If so, could you do that in this PR? Otherwise let me know and I'll approve this.
When rebasing there are unfortunately regressions on some of the tests related to returning structs. I will look into re-enabling the compatibility test when I have investigated these regressions. If there's any silver lining I guess it is that it highlights the importance of #117458 and getting the nvptx tests up and running again in CI. |
Yeah it should be re-enabled, otherwise the claim that it fixes the issue is not accurate. |
Checking status of this PR. @kjetilkjeka is this PR waiting on #117458? Switching the review flag for a rebase, thanks. @rustbot author |
Yes, this is waiting for #117458 It turned out to be more difficult than anticipated to get correct. I will of course spend the time to figure it out, but when I manage to get it right I would hate for it to break again. Therefore I would love to wait until the nvptx tests are enabled in CI so I can write tests and be confident that things will keep working. |
Is this still blocked now that #117458 is merged? |
@kjetilkjeka when you have a sec. can you look at this patch again? Thanks @rustbot author |
Fixes #117480
I must admit that I'm confused about
PassMode
altogether, is there a good sum-up threads for this anywhere? I'm especially confused about how "indirect" and "byval" goes together. To me it seems like "indirect" basically means "use a indirection through a pointer", while "byval" basically means "do not use indirection through a pointer".The return used to keep
PassMode::Direct
for small aggregates. It turns out thatmake_indirect
messes up the tests and one way to fix it is to keepPassMode::Direct
for all aggregates. I have mostly seen this PassMode mentioned for args. Is it also a problem for returns? When experimenting withbyval
as an alternative i ran into this assertI have added tests for the same kind of types that is already tested for the "ptx-kernel" abi. The tests cannot be enabled until something like #117458 is completed and merged.
CC: @RalfJung since you seem to be the expert on this and have already helped me out tremendously
CC: @RDambrosio016 in case this influence your work on
rustc_codegen_nvvm
@rustbot label +O-NVPTX