Page MenuHomePhabricator

[RISCV] Implement mayBeEmittedAsTailCall for tail call optimization
ClosedPublic

Authored by wwei on Jan 30 2020, 5:42 AM.

Details

Summary

Implement TargetLowering callback mayBeEmittedAsTailCall for riscv in CodeGenPrepare,
which will duplicate return instructions to enable tailcall optimization.

Diff Detail

Event Timeline

wwei created this revision.Jan 30 2020, 5:42 AM

Thanks, this seems like a good change. I haven't checked the source, but I wonder is it ever possible this hook triggers duplication of the returns but the tail calls don't get emitted for whatever reason? Other than that and the comment above I'd be happy with this.

llvm/test/CodeGen/RISCV/tail-calls.ll
177

Perhaps these check lines should be simplified to just the checks for the tail calls, rather than using 'CHECK-NEXT' to check every line. Just to potentially reduce the chance of this test failing for unrelated reasons. Ideally we'd be able to check the tail calls in any order too but I'm not sure how that would be done with filecheck.

luismarques added inline comments.Feb 4 2020, 6:20 AM
llvm/test/CodeGen/RISCV/tail-calls.ll
177

Since the called functions all have different names I guess a plain CHECK would do it?

evandro added a subscriber: evandro.Feb 5 2020, 1:47 PM

Overall it looks good to me. Can you please just address the test review comments?

wwei updated this revision to Diff 243537.Feb 10 2020, 6:16 AM

update test case for this patch

wwei marked 2 inline comments as done.Feb 10 2020, 6:19 AM
wwei added inline comments.
llvm/test/CodeGen/RISCV/tail-calls.ll
177

done, using CHECK should be better here.

177

done

This revision is now accepted and ready to land.Feb 12 2020, 2:24 AM
This revision was automatically updated to reflect the committed changes.