[SPARC] Make calls to function with big return values work
authorKoakuma <koachan@protonmail.com>
Tue, 18 Oct 2022 00:01:55 +0000 (00:01 +0000)
committerTobias Hieta <tobias@hieta.se>
Fri, 28 Oct 2022 07:38:21 +0000 (09:38 +0200)
commit08bd84e8a6358eb412fcef279f8875e2d69a3374
treebe512372b3d347636926ac576e3a6f225ec5ccf6
parent9d46557baa84ab4342707c119cf9c77c9148230e
[SPARC] Make calls to function with big return values work

Implement CanLowerReturn and associated CallingConv changes for SPARC/SPARC64.

In particular, for SPARC64 there's new `RetCC_Sparc64_*` functions that handles the return case of the calling convention.
It uses the same analysis as `CC_Sparc64_*` family of funtions, but fails if the return value doesn't fit into the return registers.

This makes calls to functions with big return values converted to an sret function as expected, instead of crashing LLVM.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D132465

(cherry picked from commit d3fcbee10d893b9e01e563c3840414ba89283484)
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/Target/Sparc/SparcCallingConv.td
llvm/lib/Target/Sparc/SparcISelLowering.cpp
llvm/lib/Target/Sparc/SparcISelLowering.h
llvm/test/CodeGen/SPARC/64abi.ll
llvm/test/CodeGen/SPARC/bigreturn.ll [new file with mode: 0644]