[SystemZ][z/OS] Support naked functions as XPLINK stubs (#239862)
A function with the `naked` attribute has no prologue or epilogue. On
z/OS XPLINK it maps to a stub function, which has a stub entry marker
instead of the normal entry point marker and has no PPA1.
AsmPrinter:
* For naked functions, emitFunctionEntryLabel() no longer calls
calculatePPA1() and no longer emits the 16-byte entry point marker. It
emits an 8-byte stub marker (eyecatcher 0x00C300C500C500, mark type
C'4'), preceded by 8 bytes of zero padding. The padding keeps the entry
point at function start + 16, the same offset as for a normal function.
* emitFunctionBodyEnd() returns early for naked functions. Otherwise it
would use DeferredPPA1.back(), which is the previous function's entry or
an empty vector.
ISel:
* LowerFormalArguments() is not called for naked functions, so the ADA
virtual register (R5 on entry) was never created. Globals and internal
callees in a stub then used an invalid register. Add
getOrCreateADAVirtualRegister(), which creates the live-in on first use,
and use it in LowerFormalArguments(), getADAEntry() and
getzOSCalleeAndADA(). A naked function that does not touch the ADA gets
no live-in.
As on Linux on Z, the backend does not diagnose stack objects, spills or
frame-requiring calls in a naked function. This is the user's contract,
and Clang already restricts naked function bodies to inline asm.
Add zos-naked.ll to test the stub marker, the padding, neighbouring
normal functions, ADA access from a stub, and the interaction with
minsize/optsize and "frame-pointer".
Assisted by: IBM Bob