This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix codegen for __attribute__((swiftasynccall)).
AbandonedPublic

Authored by varungandhi-apple on Feb 3 2021, 3:43 PM.

Details

Reviewers
rjmccall
Summary
  1. It should be mapped to LLVM's swifttailcc, which is now available.
  2. We should make sure we generate a tail call instead of an ordinary call.

Fixes rdar://73762895.

Diff Detail

Event Timeline

varungandhi-apple requested review of this revision.Feb 3 2021, 3:43 PM
varungandhi-apple created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 3:43 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I am planning to add more tests, figured it is better to put up the patch sooner rather than later.

Generate tail call when doing codegen for return statement.

Okay, seems fine to me.

clang/lib/CodeGen/CGStmt.cpp
1156

Hmm. I guess this should work in any situation where we can successfully actually do a tail call.

Please add some C++ tests, just in case.

Added checks for C++.

rjmccall accepted this revision.Mar 1 2021, 9:06 PM

LGTM

This revision is now accepted and ready to land.Mar 1 2021, 9:06 PM

Add null check for callee; instead of using getFunctionType() directly.

Otherwise, it leads to a crash when compiling gtest-all.cc.

varungandhi-apple updated this revision to Diff 329889.EditedMar 11 2021, 2:23 AM

Use musttail call instead of tail call. (This patch needs to be marked as dependent on another patch which implements proper musttail support, but that is not available yet.)

Fix codegen + add tests for methods and function pointers.

rjmccall added inline comments.Mar 29 2021, 10:18 PM
clang/lib/CodeGen/CGStmt.cpp
1240

What's with the explicit :: here?

  1. Remove '::' when calling static function.
  2. Fix bug in function merging around missing musttail.
  3. Add off-by-default check in verifier for swifttailcc->swifttailcc tail calls that are not marked musttail.