This is an archive of the discontinued LLVM Phabricator instance.

musttail: Forward regparms of variadic functions on x86_64
ClosedPublic

Authored by rnk on Aug 25 2014, 8:34 PM.

Details

Summary

If a variadic function body contains a musttail call, then we copy all
of the remaining register parameters into virtual registers in the
function prologue. We track the virtual registers through the function
body, and add them as additional registers to pass to the call. Because
this is all done in virtual registers, the register allocator usually
gives us good code. If the function does a call, however, it will have
to spill and reload all argument registers (ew).

Forwarding regparms on x86_32 is not implemented because most compilers
don't support varargs in 32-bit with regparms.

Diff Detail

Event Timeline

rnk updated this revision to Diff 12933.Aug 25 2014, 8:34 PM
rnk retitled this revision from to musttail: Forward regparms of variadic functions on x86_64.
rnk updated this object.
rnk added a reviewer: majnemer.
rnk added a subscriber: Unknown Object (MLST).
majnemer added inline comments.Aug 29 2014, 1:34 PM
lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
151

if (const auto *CI = dyn_cast<CallInst>(I)) { would be a little nicer when considering that I is a const_iterator.

lib/Target/X86/X86ISelLowering.cpp
2291–2296

Do we want a TODO here for vectorcall?

rnk updated this revision to Diff 13107.Aug 29 2014, 2:13 PM
  • Add a const and munge some comments
rnk closed this revision.Aug 29 2014, 2:51 PM
rnk updated this revision to Diff 13112.

Closed by commit rL216780 (authored by @rnk).