Skip to content

[AArch64][GlobalIsel] Cannot lower return of struct type with 9 fields #50062

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

Closed
DavidSpickett opened this issue Jun 15, 2021 · 3 comments
Closed
Assignees
Labels

Comments

@DavidSpickett
Copy link
Collaborator

Bugzilla Link 50718
Version trunk
OS Linux
Attachments IR test file, test C file
CC @qcolombet

Extended Description

This was found while working on #49991 , which deals with various combinations of aggregates and how registers are assigned to them with FastIsel on AArch64.

I didn't find any issue with GlobalIsel apart from whenever we would need to return by stack.

If you try to return a type like this:
%T1 = type { double, double, double, double, double, double, double, double, double }

When we try to lower the return we run out of D registers (0-7 is allowed for argument passing and return) and so fail and there appears to be no fallback path to put the argument on the stack.
(though I'm unfamiliar with globalisel so maybe I have some strict mode on, and it could fall back somehow)

./bin/llc -mtriple=aarch64-none-linux-gnu -o - test.ll -global-isel

LLVM ERROR: unable to translate instruction: ret (in function: return_argument_1)
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/david.spickett/build-llvm-aarch64/bin/llc -mtriple=aarch64-none-linux-gnu -o - /home/david.spickett/llvm-project/llvm/test/CodeGen/AArch64/argument-blocks-array-of-struct.ll -global-isel

  1.  Running pass 'Function Pass Manager' on module '/home/david.spickett/llvm-project/llvm/test/CodeGen/AArch64/argument-blocks-array-of-struct.ll'.
    
  2.  Running pass 'IRTranslator' on function '@return_argument_1'
    

#​0 0x0000aaaac0e2e2c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/david.spickett/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
Aborted (core dumped)

If you have 8 items in the type it uses d0-d7 registers as expected.

If you try to do the same thing from C it works probably because something else transforms the IR so you don't have to ask for 9 registers.

Godbolt with both examples: https://godbolt.org/z/3j7qoPvhf (files also attached)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@aemerson
Copy link
Contributor

aemerson commented Mar 2, 2022

Sorry for missing this. Assigning to myself.

@llvmbot
Copy link
Member

llvmbot commented Mar 2, 2022

@llvm/issue-subscribers-backend-aarch64

@c-rhodes
Copy link
Collaborator

now fixed looking at the godbolt link above

davemgreen added a commit that referenced this issue May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants