This is an archive of the discontinued LLVM Phabricator instance.

Make sure to forward arguments from vararg to musttail vararg
ClosedPublic

Authored by yinma on Oct 29 2018, 3:45 PM.

Details

Summary
Thunk functions in Windows are varag functions that call a musttail function
to pass the arguments after the fixup is done.  We need to make sure that we
forward the arguments from the caller vararg to the callee vararg function.
This is the same mechanism that is used for Windows on X86.

Diff Detail

Repository
rL LLVM

Event Timeline

yinma created this revision.Oct 29 2018, 3:45 PM
mgrang retitled this revision from Make sure to forward arguments from vararg to musttail vararg to [COFF, ARM64] Make sure to forward arguments from vararg to musttail vararg.Oct 29 2018, 4:06 PM
rnk added inline comments.Oct 29 2018, 4:26 PM
lib/Target/AArch64/AArch64ISelLowering.cpp
3152 ↗(On Diff #171598)

Please do this for all OSs, not just windows. This is a general purpose feature that is supposed to work for all targets, it's just only implemented for one right now.

3158 ↗(On Diff #171598)

Neat, I guess the code I wrote to find all the remaining regparms was generic enough to work for any convention.

3622 ↗(On Diff #171598)

Please remove the IsWin64 test so we just do this all the time. One day, someone will come asking to use this on AArch64, probably.

test/CodeGen/AArch64/vararg-tallcall.ll
1 ↗(On Diff #171598)

If it works, test some other targets, especially if the default calling convention changes based on OS.

yinma updated this revision to Diff 171744.Oct 30 2018, 11:42 AM
yinma retitled this revision from [COFF, ARM64] Make sure to forward arguments from vararg to musttail vararg to Make sure to forward arguments from vararg to musttail vararg.
yinma marked 4 inline comments as done.

Testcase should also check that the vector registers are correctly saved/restored. (Something like call void asm sideeffect "", "~{d0}"() should force a spill.) It looks like the code handles this correctly already.

Otherwise LGTM.

yinma updated this revision to Diff 171775.Oct 30 2018, 1:28 PM
This revision is now accepted and ready to land.Oct 30 2018, 1:45 PM
This revision was automatically updated to reflect the committed changes.