This is an archive of the discontinued LLVM Phabricator instance.

[SPARC] Make calls to function with big return values work

Authored by koakuma on Aug 23 2022, 5:41 AM.



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.

Diff Detail

Event Timeline

koakuma created this revision.Aug 23 2022, 5:41 AM
koakuma requested review of this revision.Aug 23 2022, 5:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 5:41 AM
koakuma updated this revision to Diff 454974.Aug 23 2022, 3:00 PM

Change formatting as suggested by clang-format.

Ping. Is there anything else I should do for this?

MaskRay added inline comments.

OK. This looks similar to X86/PowerPC.


OK. Similar to other targets.


This checks nearly every instruction. Use PATH=DIR_WITH_LLC:$PATH llvm/utils/


Add other interesting tests like {i64, i64} ?


-NEXT helps catch problems if the code sequence changes. generated output uses -NEXT.

MaskRay added inline comments.Oct 16 2022, 1:37 PM

-unknown-linux-gnu can be deleted as that doesn't affect codegen. Make the target triple general.

koakuma added inline comments.Oct 17 2022, 6:55 AM

So the {i64, i64} case is already tested in 64abi.ll, but the corresponding {i32, i32} for 32-bit ABI isn't tested yet.
I'll rework the tests so it would directly be inside the main ABI test files instead of in a new file.

koakuma updated this revision to Diff 468204.Oct 17 2022, 7:53 AM

Move all sret-related tests into one file and autogenerate the test cases.

MaskRay accepted this revision.Oct 17 2022, 8:59 AM



Consider using ;; for non-RUN non-CHECK comments. It makes comments stand out in some editors and helps to recognize comments.

This revision is now accepted and ready to land.Oct 17 2022, 8:59 AM

Thanks, can you please commit it to me, @MaskRay?
My email address is

This revision was automatically updated to reflect the committed changes.