This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][GlobalISel] Add lowerCall for calling convention
ClosedPublic

Authored by nitinjohnraj on Feb 23 2020, 11:11 AM.

Details

Summary

This patch implements minimal support for lowering function calls to callees with arguments and/or return values according to the RISC-V calling convention. Integer, pointer and aggregate types are supported.

Feedback is very much appreciated.

Diff Detail

Unit TestsFailed

Event Timeline

lewis-revill created this revision.Feb 23 2020, 11:11 AM

Rebase, update test structure. Correct missing defs by adding CallReturnHandler.

Joe added a subscriber: Joe.Mar 17 2020, 5:02 AM

If you're supporting a pointer value return type, should there be a test for this?

Other than that, this looks fine to me - although should wait until somebody more experienced looks at it.

Side note: Would it be worth, in the future, to outline the process of finding In/OutputArgs and ArgInfos to something like a computeOutgoingArgs/computeIncomingArgs that fills a list of ISD::In/OutputArg and ArgInfos? Or would this just obfuscate things?

Add test for pointer return type

Bug fix - add target flags to call instruction.

lenary resigned from this revision.Jan 14 2021, 10:10 AM
rkruppe removed a subscriber: rkruppe.Jan 14 2021, 10:20 AM
lewis-revill edited the summary of this revision. (Show Details)

Rebased, and updated where appropriate to continue to build correctly.

arsenm added inline comments.Jan 17 2022, 4:41 PM
llvm/lib/Target/RISCV/RISCVCallLowering.cpp
311 ↗(On Diff #399997)

Same comment on the other half of the call lowering patches

Use ValueAssigners to avoid rewriting generic infrastructure and use determineAndHandleAssignments instead.

lewis-revill marked an inline comment as done.Jan 26 2022, 4:23 AM
lewis-revill retitled this revision from [WIP][RISCV][GlobalISel] Add lowerCall for calling convention to [RISCV][GlobalISel] Add lowerCall for calling convention.Feb 9 2022, 3:13 AM
lewis-revill edited the summary of this revision. (Show Details)
arsenm accepted this revision.Feb 9 2022, 8:45 AM
arsenm added inline comments.
llvm/lib/Target/RISCV/RISCVCallLowering.cpp
263 ↗(On Diff #403214)

Not sure why you're bothering to filter these out. splitToValueTypes should handle near everything (I'm aware of some assertions on weird non-byte element sized vectors)

This revision is now accepted and ready to land.Feb 9 2022, 8:45 AM
nitinjohnraj commandeered this revision.Apr 5 2023, 1:11 PM
nitinjohnraj added a reviewer: lewis-revill.
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2023, 1:11 PM
arsenm added inline comments.Apr 8 2023, 5:17 AM
llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/calls.ll
265

Use opaque pointers

267

Could use sret/byval tests. Also cases where the argument/return list is too long and needs to go to the stack

eopXD added inline comments.Apr 12 2023, 5:05 AM
llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
305

This seems to contradict with the description of this patch, "Simple non-aggregate types are supported."

Added tests for aggregate types, sret and byval

nitinjohnraj requested review of this revision.May 22 2023, 10:21 AM
nitinjohnraj added inline comments.
llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
305

You're right. I've updated the description and added a test accordingly.

llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/calls.ll
265

Updated.

267

Could use sret/byval tests.

I've added these.

Also cases where the argument/return list is too long and needs to go to the stack

Are there other examples of a test like this?

nitinjohnraj edited the summary of this revision. (Show Details)
nitinjohnraj marked 2 inline comments as done.
evandro removed a subscriber: evandro.May 22 2023, 5:24 PM

As stated in the parent revision, we will correctly handle byval, sret and cases where the number of arguments exceed the number of available registers in a future patch.

nitinjohnraj marked an inline comment as done.May 30 2023, 1:48 PM
arsenm accepted this revision.May 31 2023, 1:47 AM
arsenm added inline comments.
llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
259

Should add some tail call cases. You should set IsTailCall to false if you aren’t handling them

This revision is now accepted and ready to land.May 31 2023, 1:47 AM
nitinjohnraj marked an inline comment as done.

Set IsTailCall to false. We will handle tail calls in a future patch.

This revision was landed with ongoing or failed builds.Jun 1 2023, 3:59 PM
This revision was automatically updated to reflect the committed changes.