This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC][NFC] refactor eligible check for tail call optimization
ClosedPublic

Authored by tingwang on Jan 13 2023, 3:07 AM.

Details

Summary

The check logic for TCO is scattered in two functions: IsEligibleForTailCallOptimization_64SVR4() IsEligibleForTailCallOptimization(), and serves instruction selection phase only at this moment.

There is one scenario (D131953) during transformation, we would like to determine if tailcall can be guaranteed or not. Existing logic cannot be directly reused due to dependency on DAG and SDValue etc.

This patch aims to refactor existing logic to export an API for TCO eligible query before instruction selection phase.

Diff Detail

Event Timeline

tingwang created this revision.Jan 13 2023, 3:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2023, 3:07 AM
tingwang requested review of this revision.Jan 13 2023, 3:07 AM
shchenz accepted this revision as: shchenz.Feb 17 2023, 2:10 AM

LGTM. Please wait for some days for other reviewers.

nit: I think this patch should be NFC, right? If so please update the patch title.

This revision is now accepted and ready to land.Feb 17 2023, 2:10 AM
tingwang retitled this revision from [PowerPC] refactor eligible check for tail call optimization to [PowerPC][NFC] refactor eligible check for tail call optimization.Feb 19 2023, 4:08 PM
nemanjai added inline comments.Feb 19 2023, 4:28 PM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5650–5660

This seems like a strange structure. You have 3 disjoint conditions that each simply set a Boolean variable that is then returned. Why not:

if (...)
  return false;
else if (...)
  return IsEligibleForTailCallOptimization_64SVR4(...);
else
  return IsEligibleForTailCallOptimization(...);
tingwang updated this revision to Diff 498703.Feb 19 2023, 5:58 PM

Address comments.

tingwang marked an inline comment as done.Feb 19 2023, 5:59 PM
shchenz added inline comments.Feb 19 2023, 6:05 PM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5651

nit: no need for the two else.

tingwang updated this revision to Diff 498709.Feb 19 2023, 6:28 PM

Address comment and removed the second else.

tingwang marked an inline comment as done.Feb 19 2023, 6:28 PM
tingwang updated this revision to Diff 498713.Feb 19 2023, 8:25 PM

Continue NIT: maybe remove the first else makes more sense...

nemanjai accepted this revision.Feb 20 2023, 7:40 AM

LGTM. Thanks.