Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1224)

Issue 154066: [PATCH] Make X86-64 in the Large model always emit 64-bit calls (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 5 months ago by Jeffrey Yasskin
Modified:
14 years, 5 months ago
Reviewers:
gohman
CC:
llvm-commits_cs.uiuc.edu
Base URL:
https://llvm.org/svn/llvm-project/llvm/trunk/
Visibility:
Public.

Description

Make X86-64 in the Large model always emit 64-bit calls. The large code model is documented at http://www.x86-64.org/documentation/abi.pdf and says that calls should assume their target doesn't live within the 32-bit pc-relative offset that fits in the call instruction. To do this, we turn off the global-address->target-global-address conversion in X86TargetLowering::LowerCall(). The first attempt at this broke the lazy JIT because it can separate the movabs(imm->reg) from the actual call instruction. The lazy JIT receives the address of the movabs as a relocation and needs to record the return address from the call; and then when that call happens, it needs to patch the movabs with the newly-compiled target. We could thread the call instruction into the relocation and record the movabs<->call mapping explicitly, but that seems to require at least as much new complication in the code generator as this change. To fix this, we make lazy functions _always_ go through a call stub. You'd think we'd only have to force lazy calls through a stub on difficult platforms, but that turns out to break indirect calls through a function pointer. The right fix for that is to distinguish between calls and address-of operations on uncompiled functions, but that's complex enough to leave for someone else to do. Another attempt at this defined a new CALL64i pseudo-instruction, which expanded to a 2-instruction sequence in the assembly output and was special-cased in the X86CodeEmitter's emitInstruction() function. That broke indirect calls in the same way as above. This patch also removes a hack forcing Darwin to the small code model. Without far-call-stubs, the small code model requires things of the JITMemoryManager that the DefaultJITMemoryManager can't provide. Thanks to echristo for lots of testing!

Patch Set 1 #

Patch Set 2 : Attempt emitting far-call as a 2-instruction unit #

Patch Set 3 : Third time's the charm #

Patch Set 4 : Remove inline lazy calls from x86-32 #

Patch Set 5 : Fix 80-column issue #

Patch Set 6 : Avoid breaking tail calls, assume large code model=>64bit #

Patch Set 7 : Make the test pass on Darwin64 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+184 lines, -53 lines) Patch
M lib/ExecutionEngine/JIT/JITEmitter.cpp View 3 4 5 6 2 chunks +0 lines, -17 lines 0 comments Download
M lib/Target/X86/X86CodeEmitter.cpp View 1 2 3 4 5 6 8 chunks +8 lines, -19 lines 0 comments Download
M lib/Target/X86/X86ISelLowering.cpp View 1 3 4 5 6 3 chunks +17 lines, -4 lines 0 comments Download
M lib/Target/X86/X86JITInfo.cpp View 1 3 4 5 6 1 chunk +3 lines, -2 lines 0 comments Download
M test/Makefile View 1 2 3 4 5 6 1 chunk +3 lines, -3 lines 0 comments Download
M unittests/ExecutionEngine/JIT/JITTest.cpp View 1 2 3 4 5 6 4 chunks +150 lines, -6 lines 0 comments Download
M utils/lit/TestFormats.py View 1 2 3 4 5 6 1 chunk +3 lines, -2 lines 0 comments Download

Messages

Total messages: 1
Jeffrey Yasskin
14 years, 5 months ago (2009-11-12 19:19:16 UTC) #1
Patch at http://codereview.appspot.com/download/issue154066_1033.diff

I'm unfamiliar with the code generator, so please go over that part of the
change with a fine-toothed comb.

This patch doesn't include r86941, assuming that'll be rolled back temporarily.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b