This is an archive of the discontinued LLVM Phabricator instance.

x86_64: Fix calls to __morestack under the large code model.
ClosedPublic

Authored by pcc on Dec 28 2014, 6:06 AM.

Details

Summary

Under the large code model, we cannot assume that morestack lives within
2^31 bytes of the call site, so we cannot use pc-relative addressing. We
cannot perform the call via a temporary register, as the rax register may
be used to store the static chain, and all other suitable registers may be
either callee-save or used for parameter passing. We cannot use the stack
at this point either because
morestack manipulates the stack directly.

To avoid these issues, perform an indirect call via a read-only memory
location containing the address.

This solution is not perfect, as it assumes that the .rodata section
is laid out within 2^31 bytes of each function body, but this seems to
be sufficient for JIT.

Diff Detail

Event Timeline

pcc updated this revision to Diff 17657.Dec 28 2014, 6:06 AM
pcc retitled this revision from to x86_64: Fix calls to __morestack under the large code model..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added a subscriber: Unknown Object (MLST).
reames added a subscriber: reames.Dec 29 2014, 12:53 PM

LGTM w/comments addressed.

include/llvm/CodeGen/MachineModuleInfo.h
164

Add a comment about what this means and why it's needed.

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
998

I'm concerned about how this interacts with the code just before it w.r.t. changing sections. Can it be moved right above the trampoline check?

lib/Target/X86/X86FrameLowering.cpp
1644

Can you be slightly more verbose here? In particular, your comments about not having a free register in general is important. Also, document the assumption w.r.t. section layout.

This revision was automatically updated to reflect the committed changes.