Skip to content

Commit

Permalink
[Orc] Slightly improve the x86-64 resolver block machine code.
Browse files Browse the repository at this point in the history
Replace leaq + movq of a pointer with a single movabsq.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259968 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lhames committed Feb 6, 2016
1 parent 0f73f7a commit 8192ebb
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/llvm/ExecutionEngine/Orc/OrcArchitectureSupport.h
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ class OrcX86_64 {
public:
static const unsigned PointerSize = 8;
static const unsigned TrampolineSize = 8;
static const unsigned ResolverCodeSize = 0x78;
static const unsigned ResolverCodeSize = 0x6C;

typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;

15 changes: 7 additions & 8 deletions lib/ExecutionEngine/Orc/OrcArchitectureSupport.cpp
Original file line number Diff line number Diff line change
@@ -38,11 +38,14 @@ void OrcX86_64::writeResolverCode(uint8_t *ResolverMem, JITReentryFn ReentryFn,
0x41, 0x57, // 0x18: pushq %r15
0x48, 0x81, 0xec, 0x08, 0x02, 0x00, 0x00, // 0x1a: subq 0x208, %rsp
0x48, 0x0f, 0xae, 0x04, 0x24, // 0x21: fxsave64 (%rsp)
0x48, 0x8d, 0x3d, 0x43, 0x00, 0x00, 0x00, // 0x26: leaq 67(%rip), %rdi
0x48, 0x8b, 0x3f, // 0x2d: movq (%rdi), %rdi
0x48, 0xbf, // 0x26: movabsq <CBMgr>, %rdi

// 0x28: Callback manager addr.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x48, 0x8b, 0x75, 0x08, // 0x30: movq 8(%rbp), %rsi
0x48, 0x83, 0xee, 0x06, // 0x34: subq $6, %rsi
0x48, 0xb8, // 0x38: movabsq $0, %rax
0x48, 0xb8, // 0x38: movabsq <REntry>, %rax

// 0x3a: JIT re-entry fn addr:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -67,14 +70,10 @@ void OrcX86_64::writeResolverCode(uint8_t *ResolverMem, JITReentryFn ReentryFn,
0x58, // 0x69: popq %rax
0x5d, // 0x6a: popq %rbp
0xc3, // 0x6b: retq
0x00, 0x00, 0x00, 0x00, // 0x6c: <padding>

// 0x70: Callback mgr address.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

const unsigned ReentryFnAddrOffset = 0x3a;
const unsigned CallbackMgrAddrOffset = 0x70;
const unsigned CallbackMgrAddrOffset = 0x28;

memcpy(ResolverMem, ResolverCode, sizeof(ResolverCode));
memcpy(ResolverMem + ReentryFnAddrOffset, &ReentryFn, sizeof(ReentryFn));

0 comments on commit 8192ebb

Please sign in to comment.