From 8192ebb6c01a72d54aabc01e4b7605eb18b6a30a Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sat, 6 Feb 2016 00:55:08 +0000 Subject: [PATCH] [Orc] Slightly improve the x86-64 resolver block machine code. 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 --- .../ExecutionEngine/Orc/OrcArchitectureSupport.h | 2 +- .../Orc/OrcArchitectureSupport.cpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/llvm/ExecutionEngine/Orc/OrcArchitectureSupport.h b/include/llvm/ExecutionEngine/Orc/OrcArchitectureSupport.h index 01558eee0847..abf392b5b01a 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcArchitectureSupport.h +++ b/include/llvm/ExecutionEngine/Orc/OrcArchitectureSupport.h @@ -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; diff --git a/lib/ExecutionEngine/Orc/OrcArchitectureSupport.cpp b/lib/ExecutionEngine/Orc/OrcArchitectureSupport.cpp index 054fdadc8004..606b5616f59e 100644 --- a/lib/ExecutionEngine/Orc/OrcArchitectureSupport.cpp +++ b/lib/ExecutionEngine/Orc/OrcArchitectureSupport.cpp @@ -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 , %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 , %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: - - // 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));