Page MenuHomePhabricator

[RISCV] Support fast calling convention
ClosedPublic

Authored by shiva0217 on Oct 6 2019, 7:16 PM.

Details

Summary

LLVM may annotate the function with fastcc if there has only one caller and there're no other caller out of the module and the function is not naked or contain variable arguments.
The fastcc functions could pass the arguments by the caller saved registers.

Diff Detail

Event Timeline

shiva0217 created this revision.Oct 6 2019, 7:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2019, 7:16 PM
hiraditya added inline comments.
lib/Target/RISCV/RISCVISelLowering.cpp
2046 ↗(On Diff #223450)

nit: no need to put braces around one liners.

shiva0217 updated this revision to Diff 223791.Oct 8 2019, 12:12 AM

Update patch to address the comment

Hi @hiraditya, thanks for the comment.

lenary added a comment.Oct 8 2019, 7:26 AM

I like this change.

fastcc is LLVM-internal only, right? Checking that we don't have to care about splitting operands that don't fit into registers, or any other psABI details, right?

You said you had some performance numbers, it would be useful to have them in a comment on this patch.

jrtc27 added a comment.Oct 8 2019, 8:45 AM

I wonder whether it would be nicer to add CC_RISCV_FastCC as a function, much like CC_RISCV, instead, to match the current code style.

shiva0217 updated this revision to Diff 223906.Oct 8 2019, 11:17 AM

Update patch to address the feedbacks

Hi @lenary and @jrtc27, thanks for the comments.

I like this change.

fastcc is LLVM-internal only, right? Checking that we don't have to care about splitting operands that don't fit into registers, or any other psABI details, right?

Yes, to my understanding, fastcc doesn't need to care about psABI details.

I wonder whether it would be nicer to add CC_RISCV_FastCC as a function, much like CC_RISCV, instead, to match the current code style.

Ok, the code style has been synced and it also easier to extend when we support RV32E in the future, thanks.

I was worried about how this would work with varargs, but I see from the IR Reference that fastcc requires both prototypes to match, and disallows varargs.

In the future we should refactor this into a tablegen'd CallingConvention, but that can happen later.

lenary accepted this revision.Oct 14 2019, 8:30 AM
This revision is now accepted and ready to land.Oct 14 2019, 8:30 AM
This revision was automatically updated to reflect the committed changes.