-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
LLVM is unable to allocate certain function returns on sparc-unknown-linux-gnu
#80712
Comments
@AaronKutch is this specific to (u128, u128)? Or is it an issue for all tuples of integers? |
I don't know because 32-bit SPARC is not a target I can easily download and test from rustup. Arrays and other structures should be tested. |
My guess is that the return value ends up getting passed via registers. If that's true, the fix can be as easy as adjusting the ABI code to pass the return value indirectly. I'm also quite surprised the first thing attempted in working around the issue in
clang's behaviour is irrelevant for |
I know the basics around calling conventions in assembly, but I'm not familiar with the implementation details in Rust and LLVM. Shouldn't LLVM be pushing values onto the stack instead of giving up when it realizes that the registers cannot hold all the values? I can define a function What I mean by lowering to the same IR that clang generates is that Rust's IR relies on LLVM dealing with it:
clang's IR explicitly puts the value on the stack for LLVM:
So this would be a way of fully supporting
What do you mean by changing calling convention? The only way of forcing custom calling conventions is to use assembly in |
Well, if the functions in question are internal implementation details, you can mark them as
which should in principle give you the same ABI (and LLVM IR) as what clang uses in the first place. |
I suppose that would have also worked, but still an ugly workaround for just one edge case, the root of which should be fixed. I should mention that the choice I made in |
Filled bugs for the LLVM asserts upstream https://bugs.llvm.org/show_bug.cgi?id=48698 and https://bugs.llvm.org/show_bug.cgi?id=48699 but we should still adjust ABI code in Rust. |
48698 appears to have been migrated to Github as llvm/llvm-project#48042 and has been closed |
Some time ago,
compiler-builtins
ran into an issue where thesparc-unknown-linux-gnu
target was unable to handle functions that return(u128, u128)
. I made a temporary workaround incompiler-builtins
and said that I would try to fix the underlying issue over winter break. There are currently two proposals for adding functions that return tuples of integers, rust-lang/rfcs#914 and I remember something about widening multiplication that returns a tuple (but I can't find it for some reason). The workaround I made incompiler-builtins
will not work in those cases, since the function returning a tuple is directly in the public interface. Sincesparc-unknown-linux-gnu
is a tier 2.5 target important to some people, we need to fix the issue in LLVM ahead of time or implement some kind of lowering that leads to the same IR that clang generates. Unfortunately, I got distracted by other things and will not have time to dive into LLVM. I am opening this issue so that someone with more experience with LLVM internals can fix the issue. More details are in rust-lang/compiler-builtins#390 and rust-lang/rfcs#914 .The text was updated successfully, but these errors were encountered: