<div dir="ltr">Sorry - I should say I committed r251942 to *fix* it. That fix will break the builders too if r251933 doesn't go back in. <div><br></div><div>- Lang.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 3, 2015 at 5:38 PM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I just committed r251942 to reinstate it.<div><br></div><div>Any chance you could re-apply it - I'm traveling and my internet is pretty patchy. ><</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Lang.</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 3, 2015 at 5:28 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi lang,<br>
<br>
Sorry I reverted this as it broke the build:<br>
<br>
/home/espindola/llvm/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp:1314:3:<br>
error: too many template arguments for class template<br>
'JITCompileCallbackManager'<br>
  JITCompileCallbackManager<LazyEmitLayerT, OrcX86_64> CompileCallbacks;<br>
<br>
On 3 November 2015 at 11:10, Lang Hames via llvm-commits<br>
<div><div><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: lhames<br>
> Date: Tue Nov  3 10:10:18 2015<br>
> New Revision: 251933<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=251933&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=251933&view=rev</a><br>
> Log:<br>
> [Orc] Directly emit machine code for the x86 resolver block and trampolines.<br>
><br>
> Bypassing LLVM for this has a number of benefits:<br>
><br>
> 1) Laziness support becomes asm-syntax agnostic (previously lazy jitting didn't<br>
>    work on Windows as the resolver block was in Darwin asm).<br>
><br>
> 2) For cross-process JITs, it allows resolver blocks and trampolines to be<br>
>    emitted directly in the target process, reducing cross process traffic.<br>
><br>
> 3) It should be marginally faster.<br>
><br>
><br>
> Modified:<br>
>     llvm/trunk/include/llvm-c/OrcBindings.h<br>
>     llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h<br>
>     llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h<br>
>     llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h<br>
>     llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp<br>
>     llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp<br>
>     llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h<br>
>     llvm/trunk/lib/ExecutionEngine/Orc/OrcTargetSupport.cpp<br>
>     llvm/trunk/tools/lli/OrcLazyJIT.cpp<br>
>     llvm/trunk/tools/lli/OrcLazyJIT.h<br>
>     llvm/trunk/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp<br>
>     llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm-c/OrcBindings.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/OrcBindings.h?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/OrcBindings.h?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm-c/OrcBindings.h (original)<br>
> +++ llvm/trunk/include/llvm-c/OrcBindings.h Tue Nov  3 10:10:18 2015<br>
> @@ -47,8 +47,7 @@ typedef uint64_t (*LLVMOrcLazyCompileCal<br>
>   * client should not attempt to dispose of the Target Machine, or it will result<br>
>   * in a double-free.<br>
>   */<br>
> -LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM,<br>
> -                                         LLVMContextRef Context);<br>
> +LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM);<br>
><br>
>  /**<br>
>   * Mangle the given symbol.<br>
><br>
> Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h (original)<br>
> +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h Tue Nov  3 10:10:18 2015<br>
> @@ -242,7 +242,7 @@ private:<br>
>          // Create a callback, associate it with the stub for the function,<br>
>          // and set the compile action to compile the partition containing the<br>
>          // function.<br>
> -        auto CCInfo = CompileCallbackMgr.getCompileCallback(SrcM.getContext());<br>
> +        auto CCInfo = CompileCallbackMgr.getCompileCallback();<br>
>          StubInits[mangle(F.getName(), DL)] =<br>
>            std::make_pair(CCInfo.getAddress(),<br>
>                           JITSymbolBase::flagsFromGlobalValue(F));<br>
><br>
> Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h (original)<br>
> +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h Tue Nov  3 10:10:18 2015<br>
> @@ -27,8 +27,7 @@<br>
>  namespace llvm {<br>
>  namespace orc {<br>
><br>
> -/// @brief Base class for JITLayer independent aspects of<br>
> -///        JITCompileCallbackManager.<br>
> +/// @brief Target-independent base class JITCompileCallbackManager.<br>
>  class JITCompileCallbackManagerBase {<br>
>  public:<br>
><br>
> @@ -54,13 +53,8 @@ public:<br>
>    /// @brief Construct a JITCompileCallbackManagerBase.<br>
>    /// @param ErrorHandlerAddress The address of an error handler in the target<br>
>    ///                            process to be used if a compile callback fails.<br>
> -  /// @param NumTrampolinesPerBlock Number of trampolines to emit if there is no<br>
> -  ///                             available trampoline when getCompileCallback is<br>
> -  ///                             called.<br>
> -  JITCompileCallbackManagerBase(TargetAddress ErrorHandlerAddress,<br>
> -                                unsigned NumTrampolinesPerBlock)<br>
> -    : ErrorHandlerAddress(ErrorHandlerAddress),<br>
> -      NumTrampolinesPerBlock(NumTrampolinesPerBlock) {}<br>
> +  JITCompileCallbackManagerBase(TargetAddress ErrorHandlerAddress)<br>
> +    : ErrorHandlerAddress(ErrorHandlerAddress) {}<br>
><br>
>    virtual ~JITCompileCallbackManagerBase() {}<br>
><br>
> @@ -90,7 +84,7 @@ public:<br>
>    }<br>
><br>
>    /// @brief Reserve a compile callback.<br>
> -  virtual CompileCallbackInfo getCompileCallback(LLVMContext &Context) = 0;<br>
> +  virtual CompileCallbackInfo getCompileCallback() = 0;<br>
><br>
>    /// @brief Get a CompileCallbackInfo for an existing callback.<br>
>    CompileCallbackInfo getCompileCallbackInfo(TargetAddress TrampolineAddr) {<br>
> @@ -113,7 +107,6 @@ public:<br>
><br>
>  protected:<br>
>    TargetAddress ErrorHandlerAddress;<br>
> -  unsigned NumTrampolinesPerBlock;<br>
><br>
>    typedef std::map<TargetAddress, CompileFtor> TrampolineMapT;<br>
>    TrampolineMapT ActiveTrampolines;<br>
> @@ -124,69 +117,54 @@ private:<br>
>  };<br>
><br>
>  /// @brief Manage compile callbacks.<br>
> -template <typename JITLayerT, typename TargetT><br>
> +template <typename TargetT><br>
>  class JITCompileCallbackManager : public JITCompileCallbackManagerBase {<br>
>  public:<br>
><br>
>    /// @brief Construct a JITCompileCallbackManager.<br>
> -  /// @param JIT JIT layer to emit callback trampolines, etc. into.<br>
> -  /// @param Context LLVMContext to use for trampoline & resolve block modules.<br>
>    /// @param ErrorHandlerAddress The address of an error handler in the target<br>
>    ///                            process to be used if a compile callback fails.<br>
> -  /// @param NumTrampolinesPerBlock Number of trampolines to allocate whenever<br>
> -  ///                               there is no existing callback trampoline.<br>
> -  ///                               (Trampolines are allocated in blocks for<br>
> -  ///                               efficiency.)<br>
> -  JITCompileCallbackManager(JITLayerT &JIT, RuntimeDyld::MemoryManager &MemMgr,<br>
> -                            LLVMContext &Context,<br>
> -                            TargetAddress ErrorHandlerAddress,<br>
> -                            unsigned NumTrampolinesPerBlock)<br>
> -    : JITCompileCallbackManagerBase(ErrorHandlerAddress,<br>
> -                                    NumTrampolinesPerBlock),<br>
> -      JIT(JIT), MemMgr(MemMgr) {<br>
> -    emitResolverBlock(Context);<br>
> +  JITCompileCallbackManager(TargetAddress ErrorHandlerAddress)<br>
> +    : JITCompileCallbackManagerBase(ErrorHandlerAddress) {<br>
> +<br>
> +    /// Set up the resolver block.<br>
> +    std::error_code EC;<br>
> +    ResolverBlock =<br>
> +      sys::OwningMemoryBlock(<br>
> +        sys::Memory::allocateMappedMemory(TargetT::ResolverCodeSize, nullptr,<br>
> +                                          sys::Memory::MF_READ |<br>
> +                                          sys::Memory::MF_WRITE, EC));<br>
> +    assert(!EC && "Failed to allocate resolver block");<br>
> +<br>
> +    TargetT::writeResolverCode(static_cast<uint8_t*>(ResolverBlock.base()),<br>
> +                              &reenter, this);<br>
> +<br>
> +    EC = sys::Memory::protectMappedMemory(ResolverBlock.getMemoryBlock(),<br>
> +                                         sys::Memory::MF_READ |<br>
> +                                         sys::Memory::MF_EXEC);<br>
> +    assert(!EC && "Failed to mprotect resolver block");<br>
>    }<br>
><br>
>    /// @brief Get/create a compile callback with the given signature.<br>
> -  CompileCallbackInfo getCompileCallback(LLVMContext &Context) final {<br>
> -    TargetAddress TrampolineAddr = getAvailableTrampolineAddr(Context);<br>
> +  CompileCallbackInfo getCompileCallback() final {<br>
> +    TargetAddress TrampolineAddr = getAvailableTrampolineAddr();<br>
>      auto &Compile = this->ActiveTrampolines[TrampolineAddr];<br>
>      return CompileCallbackInfo(TrampolineAddr, Compile);<br>
>    }<br>
><br>
>  private:<br>
><br>
> -  std::vector<std::unique_ptr<Module>><br>
> -  SingletonSet(std::unique_ptr<Module> M) {<br>
> -    std::vector<std::unique_ptr<Module>> Ms;<br>
> -    Ms.push_back(std::move(M));<br>
> -    return Ms;<br>
> -  }<br>
> -<br>
> -  void emitResolverBlock(LLVMContext &Context) {<br>
> -    std::unique_ptr<Module> M(new Module("resolver_block_module",<br>
> -                                         Context));<br>
> -    TargetT::insertResolverBlock(*M, *this);<br>
> -    auto NonResolver =<br>
> -      createLambdaResolver(<br>
> -          [](const std::string &Name) -> RuntimeDyld::SymbolInfo {<br>
> -            llvm_unreachable("External symbols in resolver block?");<br>
> -          },<br>
> -          [](const std::string &Name) -> RuntimeDyld::SymbolInfo {<br>
> -            llvm_unreachable("Dylib symbols in resolver block?");<br>
> -          });<br>
> -    auto H = JIT.addModuleSet(SingletonSet(std::move(M)), &MemMgr,<br>
> -                              std::move(NonResolver));<br>
> -    JIT.emitAndFinalize(H);<br>
> -    auto ResolverBlockSymbol =<br>
> -      JIT.findSymbolIn(H, TargetT::ResolverBlockName, false);<br>
> -    assert(ResolverBlockSymbol && "Failed to insert resolver block");<br>
> -    ResolverBlockAddr = ResolverBlockSymbol.getAddress();<br>
> +  static TargetAddress reenter(void *CCMgr, void *TrampolineId) {<br>
> +    JITCompileCallbackManager *Mgr =<br>
> +      static_cast<JITCompileCallbackManager*>(CCMgr);<br>
> +    return Mgr->executeCompileCallback(<br>
> +             static_cast<TargetAddress>(<br>
> +               reinterpret_cast<uintptr_t>(TrampolineId)));<br>
>    }<br>
><br>
> -  TargetAddress getAvailableTrampolineAddr(LLVMContext &Context) {<br>
> +  TargetAddress getAvailableTrampolineAddr() {<br>
>      if (this->AvailableTrampolines.empty())<br>
> -      grow(Context);<br>
> +      grow();<br>
>      assert(!this->AvailableTrampolines.empty() &&<br>
>             "Failed to grow available trampolines.");<br>
>      TargetAddress TrampolineAddr = this->AvailableTrampolines.back();<br>
> @@ -194,35 +172,41 @@ private:<br>
>      return TrampolineAddr;<br>
>    }<br>
><br>
> -  void grow(LLVMContext &Context) {<br>
> +  void grow() {<br>
>      assert(this->AvailableTrampolines.empty() && "Growing prematurely?");<br>
> -    std::unique_ptr<Module> M(new Module("trampoline_block", Context));<br>
> -    auto GetLabelName =<br>
> -      TargetT::insertCompileCallbackTrampolines(*M, ResolverBlockAddr,<br>
> -                                                this->NumTrampolinesPerBlock,<br>
> -                                                this->ActiveTrampolines.size());<br>
> -    auto NonResolver =<br>
> -      createLambdaResolver(<br>
> -          [](const std::string &Name) -> RuntimeDyld::SymbolInfo {<br>
> -            llvm_unreachable("External symbols in trampoline block?");<br>
> -          },<br>
> -          [](const std::string &Name) -> RuntimeDyld::SymbolInfo {<br>
> -            llvm_unreachable("Dylib symbols in trampoline block?");<br>
> -          });<br>
> -    auto H = JIT.addModuleSet(SingletonSet(std::move(M)), &MemMgr,<br>
> -                              std::move(NonResolver));<br>
> -    JIT.emitAndFinalize(H);<br>
> -    for (unsigned I = 0; I < this->NumTrampolinesPerBlock; ++I) {<br>
> -      std::string Name = GetLabelName(I);<br>
> -      auto TrampolineSymbol = JIT.findSymbolIn(H, Name, false);<br>
> -      assert(TrampolineSymbol && "Failed to emit trampoline.");<br>
> -      this->AvailableTrampolines.push_back(TrampolineSymbol.getAddress());<br>
> -    }<br>
> +<br>
> +    std::error_code EC;<br>
> +    auto TrampolineBlock =<br>
> +      sys::OwningMemoryBlock(<br>
> +        sys::Memory::allocateMappedMemory(TargetT::PageSize, nullptr,<br>
> +                                          sys::Memory::MF_READ |<br>
> +                                          sys::Memory::MF_WRITE, EC));<br>
> +    assert(!EC && "Failed to allocate trampoline block");<br>
> +<br>
> +<br>
> +    unsigned NumTrampolines =<br>
> +      (TargetT::PageSize - TargetT::PointerSize) / TargetT::TrampolineSize;<br>
> +<br>
> +    uint8_t *TrampolineMem = static_cast<uint8_t*>(TrampolineBlock.base());<br>
> +    TargetT::writeTrampolines(TrampolineMem, ResolverBlock.base(),<br>
> +                             NumTrampolines);<br>
> +<br>
> +    for (unsigned I = 0; I < NumTrampolines; ++I)<br>
> +      this->AvailableTrampolines.push_back(<br>
> +        static_cast<TargetAddress>(<br>
> +         reinterpret_cast<uintptr_t>(<br>
> +                                     TrampolineMem + (I * TargetT::TrampolineSize))));<br>
> +<br>
> +    EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(),<br>
> +                                         sys::Memory::MF_READ |<br>
> +                                         sys::Memory::MF_EXEC);<br>
> +    assert(!EC && "Failed to mprotect trampoline block");<br>
> +<br>
> +    TrampolineBlocks.push_back(std::move(TrampolineBlock));<br>
>    }<br>
><br>
> -  JITLayerT &JIT;<br>
> -  RuntimeDyld::MemoryManager &MemMgr;<br>
> -  TargetAddress ResolverBlockAddr;<br>
> +  sys::OwningMemoryBlock ResolverBlock;<br>
> +  std::vector<sys::OwningMemoryBlock> TrampolineBlocks;<br>
>  };<br>
><br>
>  /// @brief Base class for managing collections of named indirect stubs.<br>
><br>
> Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h (original)<br>
> +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h Tue Nov  3 10:10:18 2015<br>
> @@ -26,29 +26,24 @@ namespace orc {<br>
><br>
>  class OrcX86_64 {<br>
>  public:<br>
> -  static const char *ResolverBlockName;<br>
> +  static const unsigned PageSize = 4096;<br>
> +  static const unsigned PointerSize = 8;<br>
> +  static const unsigned TrampolineSize = 8;<br>
> +  static const unsigned ResolverCodeSize = 0x78;<br>
><br>
> -  /// @brief Insert module-level inline callback asm into module M for the<br>
> -  /// symbols managed by JITResolveCallbackHandler J.<br>
> -  static void insertResolverBlock(Module &M,<br>
> -                                  JITCompileCallbackManagerBase &JCBM);<br>
> +  typedef TargetAddress (*JITReentryFn)(void *CallbackMgr,<br>
> +                                        void *TrampolineId);<br>
><br>
> -  /// @brief Get a label name from the given index.<br>
> -  typedef std::function<std::string(unsigned)> LabelNameFtor;<br>
> +  /// @brief Write the resolver code into the given memory. The user is be<br>
> +  ///        responsible for allocating the memory and setting permissions.<br>
> +  static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,<br>
> +                               void *CallbackMgr);<br>
><br>
> -  /// @brief Insert the requested number of trampolines into the given module.<br>
> -  /// @param M Module to insert the call block into.<br>
> -  /// @param NumCalls Number of calls to create in the call block.<br>
> -  /// @param StartIndex Optional argument specifying the index suffix to start<br>
> -  ///                   with.<br>
> -  /// @return A functor that provides the symbol name for each entry in the call<br>
> -  ///         block.<br>
> -  ///<br>
> -  static LabelNameFtor insertCompileCallbackTrampolines(<br>
> -                                                    Module &M,<br>
> -                                                    TargetAddress TrampolineAddr,<br>
> -                                                    unsigned NumCalls,<br>
> -                                                    unsigned StartIndex = 0);<br>
> +  /// @brief Write the requsted number of trampolines into the given memory,<br>
> +  ///        which must be big enough to hold 1 pointer, plus NumTrampolines<br>
> +  ///        trampolines.<br>
> +  static void writeTrampolines(uint8_t *TrampolineMem, void *ResolverAddr,<br>
> +                              unsigned NumTrampolines);<br>
><br>
>    /// @brief Provide information about stub blocks generated by the<br>
>    ///        makeIndirectStubsBlock function.<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp Tue Nov  3 10:10:18 2015<br>
> @@ -12,20 +12,18 @@<br>
><br>
>  using namespace llvm;<br>
><br>
> -LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM,<br>
> -                                         LLVMContextRef Context) {<br>
> +LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM) {<br>
>    TargetMachine *TM2(unwrap(TM));<br>
> -  LLVMContext &Ctx = *unwrap(Context);<br>
><br>
>    Triple T(TM2->getTargetTriple());<br>
><br>
> -  auto CallbackMgrBuilder = OrcCBindingsStack::createCallbackManagerBuilder(T);<br>
> +  auto CompileCallbackMgr = OrcCBindingsStack::createCompileCallbackMgr(T);<br>
>    auto IndirectStubsMgrBuilder =<br>
>      OrcCBindingsStack::createIndirectStubsMgrBuilder(T);<br>
><br>
>    OrcCBindingsStack *JITStack =<br>
> -    new OrcCBindingsStack(*TM2, Ctx, CallbackMgrBuilder,<br>
> -                          IndirectStubsMgrBuilder);<br>
> +    new OrcCBindingsStack(*TM2, std::move(CompileCallbackMgr),<br>
> +                         IndirectStubsMgrBuilder);<br>
><br>
>    return wrap(JITStack);<br>
>  }<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp Tue Nov  3 10:10:18 2015<br>
> @@ -17,19 +17,14 @@<br>
><br>
>  using namespace llvm;<br>
><br>
> -OrcCBindingsStack::CallbackManagerBuilder<br>
> -OrcCBindingsStack::createCallbackManagerBuilder(Triple T) {<br>
> +std::unique_ptr<OrcCBindingsStack::CompileCallbackMgr><br>
> +OrcCBindingsStack::createCompileCallbackMgr(Triple T) {<br>
>    switch (T.getArch()) {<br>
>      default: return nullptr;<br>
><br>
>      case Triple::x86_64: {<br>
> -      typedef orc::JITCompileCallbackManager<CompileLayerT,<br>
> -                                             orc::OrcX86_64> CCMgrT;<br>
> -      return [](CompileLayerT &CompileLayer, RuntimeDyld::MemoryManager &MemMgr,<br>
> -                LLVMContext &Context) {<br>
> -               return llvm::make_unique<CCMgrT>(CompileLayer, MemMgr, Context, 0,<br>
> -                                                64);<br>
> -             };<br>
> +      typedef orc::JITCompileCallbackManager<orc::OrcX86_64> CCMgrT;<br>
> +      return llvm::make_unique<CCMgrT>(0);<br>
>      }<br>
>    }<br>
>  }<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h Tue Nov  3 10:10:18 2015<br>
> @@ -34,10 +34,7 @@ public:<br>
>    typedef orc::IRCompileLayer<ObjLayerT> CompileLayerT;<br>
>    typedef orc::CompileOnDemandLayer<CompileLayerT, CompileCallbackMgr> CODLayerT;<br>
><br>
> -  typedef std::function<<br>
> -            std::unique_ptr<CompileCallbackMgr>(CompileLayerT&,<br>
> -                                                RuntimeDyld::MemoryManager&,<br>
> -                                                LLVMContext&)><br>
> +  typedef std::function<std::unique_ptr<CompileCallbackMgr>()><br>
>      CallbackManagerBuilder;<br>
><br>
>    typedef CODLayerT::IndirectStubsManagerBuilderT IndirectStubsManagerBuilder;<br>
> @@ -86,19 +83,18 @@ public:<br>
><br>
>    typedef unsigned ModuleHandleT;<br>
><br>
> -  static CallbackManagerBuilder createCallbackManagerBuilder(Triple T);<br>
> +  static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T);<br>
>    static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);<br>
><br>
> -  OrcCBindingsStack(TargetMachine &TM, LLVMContext &Context,<br>
> -                    CallbackManagerBuilder &BuildCallbackMgr,<br>
> +  OrcCBindingsStack(TargetMachine &TM,<br>
> +                   std::unique_ptr<CompileCallbackMgr> CCMgr,<br>
>                      IndirectStubsManagerBuilder IndirectStubsMgrBuilder)<br>
> -    : Context(Context), DL(TM.createDataLayout()),<br>
> +    : DL(TM.createDataLayout()), CCMgr(std::move(CCMgr)),<br>
>        ObjectLayer(),<br>
>        CompileLayer(ObjectLayer, orc::SimpleCompiler(TM)),<br>
> -      CCMgr(BuildCallbackMgr(CompileLayer, CCMgrMemMgr, Context)),<br>
>        CODLayer(CompileLayer,<br>
>                 [](Function &F) { std::set<Function*> S; S.insert(&F); return S; },<br>
> -               *CCMgr, std::move(IndirectStubsMgrBuilder), false),<br>
> +               *this->CCMgr, std::move(IndirectStubsMgrBuilder), false),<br>
>        IndirectStubsMgr(IndirectStubsMgrBuilder()),<br>
>        CXXRuntimeOverrides([this](const std::string &S) { return mangle(S); }) {}<br>
><br>
> @@ -127,7 +123,7 @@ public:<br>
>    orc::TargetAddress<br>
>    createLazyCompileCallback(LLVMOrcLazyCompileCallbackFn Callback,<br>
>                              void *CallbackCtx) {<br>
> -    auto CCInfo = CCMgr->getCompileCallback(Context);<br>
> +    auto CCInfo = CCMgr->getCompileCallback();<br>
>      CCInfo.setCompileAction(<br>
>        [=]() -> orc::TargetAddress {<br>
>          return Callback(wrap(this), CallbackCtx);<br>
> @@ -264,13 +260,12 @@ private:<br>
>      return NewHandle;<br>
>    }<br>
><br>
> -  LLVMContext &Context;<br>
>    DataLayout DL;<br>
>    SectionMemoryManager CCMgrMemMgr;<br>
><br>
> +  std::unique_ptr<CompileCallbackMgr> CCMgr;<br>
>    ObjLayerT ObjectLayer;<br>
>    CompileLayerT CompileLayer;<br>
> -  std::unique_ptr<CompileCallbackMgr> CCMgr;<br>
>    CODLayerT CODLayer;<br>
><br>
>    std::unique_ptr<orc::IndirectStubsManagerBase> IndirectStubsMgr;<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcTargetSupport.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcTargetSupport.cpp?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcTargetSupport.cpp?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcTargetSupport.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcTargetSupport.cpp Tue Nov  3 10:10:18 2015<br>
> @@ -12,136 +12,88 @@<br>
>  #include "llvm/Support/Process.h"<br>
>  #include <array><br>
><br>
> -using namespace llvm::orc;<br>
> -<br>
> -namespace {<br>
> -<br>
> -uint64_t executeCompileCallback(JITCompileCallbackManagerBase *JCBM,<br>
> -                                TargetAddress CallbackID) {<br>
> -  return JCBM->executeCompileCallback(CallbackID);<br>
> -}<br>
> -<br>
> -}<br>
> -<br>
>  namespace llvm {<br>
>  namespace orc {<br>
><br>
> -const char* OrcX86_64::ResolverBlockName = "orc_resolver_block";<br>
> +void OrcX86_64::writeResolverCode(uint8_t *ResolverMem, JITReentryFn ReentryFn,<br>
> +                                  void *CallbackMgr) {<br>
><br>
> -void OrcX86_64::insertResolverBlock(<br>
> -    Module &M, JITCompileCallbackManagerBase &JCBM) {<br>
> +  const uint8_t ResolverCode[] = {<br>
> +                                               // resolver_entry:<br>
> +    0x55,                                      // 0x00: pushq     %rbp<br>
> +    0x48, 0x89, 0xe5,                          // 0x01: movq      %rsp, %rbp<br>
> +    0x50,                                      // 0x04: pushq     %rax<br>
> +    0x53,                                      // 0x05: pushq     %rbx<br>
> +    0x51,                                      // 0x06: pushq     %rcx<br>
> +    0x52,                                      // 0x07: pushq     %rdx<br>
> +    0x56,                                      // 0x08: pushq     %rsi<br>
> +    0x57,                                      // 0x09: pushq     %rdi<br>
> +    0x41, 0x50,                                // 0x0a: pushq     %r8<br>
> +    0x41, 0x51,                                // 0x0c: pushq     %r9<br>
> +    0x41, 0x52,                                // 0x0e: pushq     %r10<br>
> +    0x41, 0x53,                                // 0x10: pushq     %r11<br>
> +    0x41, 0x54,                                // 0x12: pushq     %r12<br>
> +    0x41, 0x55,                                // 0x14: pushq     %r13<br>
> +    0x41, 0x56,                                // 0x16: pushq     %r14<br>
> +    0x41, 0x57,                                // 0x18: pushq     %r15<br>
> +    0x48, 0x81, 0xec, 0x08, 0x02, 0x00, 0x00,  // 0x1a: subq      20, %rsp<br>
> +    0x48, 0x0f, 0xae, 0x04, 0x24,              // 0x21: fxsave64  (%rsp)<br>
> +    0x48, 0x8d, 0x3d, 0x43, 0x00, 0x00, 0x00,  // 0x26: leaq      67(%rip), %rdi<br>
> +    0x48, 0x8b, 0x3f,                          // 0x2d: movq      (%rdi), %rdi<br>
> +    0x48, 0x8b, 0x75, 0x08,                    // 0x30: movq      8(%rbp), %rsi<br>
> +    0x48, 0x83, 0xee, 0x06,                    // 0x34: subq      $6, %rsi<br>
> +    0x48, 0xb8,                                // 0x38: movabsq   $0, %rax<br>
> +<br>
> +    // 0x3a: JIT re-entry fn addr:<br>
> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,<br>
> +<br>
> +    0xff, 0xd0,                                // 0x42: callq     *%rax<br>
> +    0x48, 0x89, 0x45, 0x08,                    // 0x44: movq      %rax, 8(%rbp)<br>
> +    0x48, 0x0f, 0xae, 0x0c, 0x24,              // 0x48: fxrstor64 (%rsp)<br>
> +    0x48, 0x81, 0xc4, 0x08, 0x02, 0x00, 0x00,  // 0x4d: addq      20, %rsp<br>
> +    0x41, 0x5f,                                // 0x54: popq      %r15<br>
> +    0x41, 0x5e,                                // 0x56: popq      %r14<br>
> +    0x41, 0x5d,                                // 0x58: popq      %r13<br>
> +    0x41, 0x5c,                                // 0x5a: popq      %r12<br>
> +    0x41, 0x5b,                                // 0x5c: popq      %r11<br>
> +    0x41, 0x5a,                                // 0x5e: popq      %r10<br>
> +    0x41, 0x59,                                // 0x60: popq      %r9<br>
> +    0x41, 0x58,                                // 0x62: popq      %r8<br>
> +    0x5f,                                      // 0x64: popq      %rdi<br>
> +    0x5e,                                      // 0x65: popq      %rsi<br>
> +    0x5a,                                      // 0x66: popq      %rdx<br>
> +    0x59,                                      // 0x67: popq      %rcx<br>
> +    0x5b,                                      // 0x68: popq      %rbx<br>
> +    0x58,                                      // 0x69: popq      %rax<br>
> +    0x5d,                                      // 0x6a: popq      %rbp<br>
> +    0xc3,                                      // 0x6b: retq<br>
> +    0x00, 0x00, 0x00, 0x00,                    // 0x6c: <padding><br>
><br>
> -  // Trampoline code-sequence length, used to get trampoline address from return<br>
> -  // address.<br>
> -  const unsigned X86_64_TrampolineLength = 6;<br>
> -<br>
> -  // List of x86-64 GPRs to save. Note - RBP saved separately below.<br>
> -  std::array<const char *, 14> GPRs = {{<br>
> -      "rax", "rbx", "rcx", "rdx",<br>
> -      "rsi", "rdi", "r8", "r9",<br>
> -      "r10", "r11", "r12", "r13",<br>
> -      "r14", "r15"<br>
> -    }};<br>
> -<br>
> -  // Address of the executeCompileCallback function.<br>
> -  uint64_t CallbackAddr =<br>
> -      static_cast<uint64_t>(<br>
> -        reinterpret_cast<uintptr_t>(executeCompileCallback));<br>
> -<br>
> -  std::ostringstream AsmStream;<br>
> -  Triple TT(M.getTargetTriple());<br>
> -<br>
> -  // Switch to text section.<br>
> -  if (TT.getOS() == Triple::Darwin)<br>
> -    AsmStream << ".section __TEXT,__text,regular,pure_instructions\n"<br>
> -              << ".align 4, 0x90\n";<br>
> -  else<br>
> -    AsmStream << ".text\n"<br>
> -              << ".align 16, 0x90\n";<br>
> -<br>
> -  // Bake in a pointer to the callback manager immediately before the<br>
> -  // start of the resolver function.<br>
> -  AsmStream << "jit_callback_manager_addr:\n"<br>
> -            << "  .quad " << &JCBM << "\n";<br>
> -<br>
> -  // Start the resolver function.<br>
> -  AsmStream << ResolverBlockName << ":\n"<br>
> -            << "  pushq     %rbp\n"<br>
> -            << "  movq      %rsp, %rbp\n";<br>
> -<br>
> -  // Store the GPRs.<br>
> -  for (const auto &GPR : GPRs)<br>
> -    AsmStream << "  pushq     %" << GPR << "\n";<br>
> -<br>
> -  // Store floating-point state with FXSAVE.<br>
> -  // Note: We need to keep the stack 16-byte aligned, so if we've emitted an odd<br>
> -  //       number of 64-bit pushes so far (GPRs.size() plus 1 for RBP) then add<br>
> -  //       an extra 64 bits of padding to the FXSave area.<br>
> -  unsigned Padding = (GPRs.size() + 1) % 2 ? 8 : 0;<br>
> -  unsigned FXSaveSize = 512 + Padding;<br>
> -  AsmStream << "  subq      $" << FXSaveSize << ", %rsp\n"<br>
> -            << "  fxsave64  (%rsp)\n"<br>
> -<br>
> -  // Load callback manager address, compute trampoline address, call JIT.<br>
> -            << "  lea       jit_callback_manager_addr(%rip), %rdi\n"<br>
> -            << "  movq      (%rdi), %rdi\n"<br>
> -            << "  movq      0x8(%rbp), %rsi\n"<br>
> -            << "  subq      $" << X86_64_TrampolineLength << ", %rsi\n"<br>
> -            << "  movabsq   $" << CallbackAddr << ", %rax\n"<br>
> -            << "  callq     *%rax\n"<br>
> -<br>
> -  // Replace the return to the trampoline with the return address of the<br>
> -  // compiled function body.<br>
> -            << "  movq      %rax, 0x8(%rbp)\n"<br>
> -<br>
> -  // Restore the floating point state.<br>
> -            << "  fxrstor64 (%rsp)\n"<br>
> -            << "  addq      $" << FXSaveSize << ", %rsp\n";<br>
> -<br>
> -  for (const auto &GPR : make_range(GPRs.rbegin(), GPRs.rend()))<br>
> -    AsmStream << "  popq      %" << GPR << "\n";<br>
> -<br>
> -  // Restore original RBP and return to compiled function body.<br>
> -  AsmStream << "  popq      %rbp\n"<br>
> -            << "  retq\n";<br>
> +    // 0x70: Callback mgr address.<br>
> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,<br>
> +  };<br>
><br>
> -  M.appendModuleInlineAsm(AsmStream.str());<br>
> +  const unsigned ReentryFnAddrOffset = 0x3a;<br>
> +  const unsigned CallbackMgrAddrOffset = 0x70;<br>
> +<br>
> +  memcpy(ResolverMem, ResolverCode, sizeof(ResolverCode));<br>
> +  memcpy(ResolverMem + ReentryFnAddrOffset, &ReentryFn, sizeof(ReentryFn));<br>
> +  memcpy(ResolverMem + CallbackMgrAddrOffset, &CallbackMgr,<br>
> +         sizeof(CallbackMgr));<br>
>  }<br>
><br>
> -OrcX86_64::LabelNameFtor<br>
> -OrcX86_64::insertCompileCallbackTrampolines(Module &M,<br>
> -                                            TargetAddress ResolverBlockAddr,<br>
> -                                            unsigned NumCalls,<br>
> -                                            unsigned StartIndex) {<br>
> -  const char *ResolverBlockPtrName = "Lorc_resolve_block_addr";<br>
> -<br>
> -  std::ostringstream AsmStream;<br>
> -  Triple TT(M.getTargetTriple());<br>
> -<br>
> -  if (TT.getOS() == Triple::Darwin)<br>
> -    AsmStream << ".section __TEXT,__text,regular,pure_instructions\n"<br>
> -              << ".align 4, 0x90\n";<br>
> -  else<br>
> -    AsmStream << ".text\n"<br>
> -              << ".align 16, 0x90\n";<br>
> -<br>
> -  AsmStream << ResolverBlockPtrName << ":\n"<br>
> -            << "  .quad " << ResolverBlockAddr << "\n";<br>
> -<br>
> -  auto GetLabelName =<br>
> -    [=](unsigned I) {<br>
> -      std::ostringstream LabelStream;<br>
> -      LabelStream << "orc_jcc_" << (StartIndex + I);<br>
> -      return LabelStream.str();<br>
> -  };<br>
> +void OrcX86_64::writeTrampolines(uint8_t *TrampolineMem, void *ResolverAddr,<br>
> +                                unsigned NumTrampolines) {<br>
> +<br>
> +  unsigned OffsetToPtr = NumTrampolines * TrampolineSize;<br>
><br>
> -  for (unsigned I = 0; I < NumCalls; ++I)<br>
> -    AsmStream << GetLabelName(I) << ":\n"<br>
> -              << "  callq *" << ResolverBlockPtrName << "(%rip)\n";<br>
> +  memcpy(TrampolineMem + OffsetToPtr, &ResolverAddr, sizeof(void*));<br>
><br>
> -  M.appendModuleInlineAsm(AsmStream.str());<br>
> +  uint64_t *Trampolines = reinterpret_cast<uint64_t*>(TrampolineMem);<br>
> +  uint64_t CallIndirPCRel = 0xf1c40000000015ff;<br>
><br>
> -  return GetLabelName;<br>
> +  for (unsigned I = 0; I < NumTrampolines; ++I, OffsetToPtr -= TrampolineSize)<br>
> +    Trampolines[I] = CallIndirPCRel | ((OffsetToPtr - 6) << 16);<br>
>  }<br>
><br>
>  std::error_code OrcX86_64::emitIndirectStubsBlock(IndirectStubsInfo &StubsInfo,<br>
><br>
> Modified: llvm/trunk/tools/lli/OrcLazyJIT.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/lli/OrcLazyJIT.cpp (original)<br>
> +++ llvm/trunk/tools/lli/OrcLazyJIT.cpp Tue Nov  3 10:10:18 2015<br>
> @@ -46,19 +46,14 @@ namespace {<br>
>                                 cl::init(true), cl::Hidden);<br>
>  }<br>
><br>
> -OrcLazyJIT::CallbackManagerBuilder<br>
> -OrcLazyJIT::createCallbackMgrBuilder(Triple T) {<br>
> +std::unique_ptr<OrcLazyJIT::CompileCallbackMgr><br>
> +OrcLazyJIT::createCompileCallbackMgr(Triple T) {<br>
>    switch (T.getArch()) {<br>
>      default: return nullptr;<br>
><br>
>      case Triple::x86_64: {<br>
> -      typedef orc::JITCompileCallbackManager<IRDumpLayerT,<br>
> -                                             orc::OrcX86_64> CCMgrT;<br>
> -      return [](IRDumpLayerT &IRDumpLayer, RuntimeDyld::MemoryManager &MemMgr,<br>
> -                LLVMContext &Context) {<br>
> -               return llvm::make_unique<CCMgrT>(IRDumpLayer, MemMgr, Context, 0,<br>
> -                                                64);<br>
> -             };<br>
> +      typedef orc::JITCompileCallbackManager<orc::OrcX86_64> CCMgrT;<br>
> +      return llvm::make_unique<CCMgrT>(0);<br>
>      }<br>
>    }<br>
>  }<br>
> @@ -146,13 +141,12 @@ int llvm::runOrcLazyJIT(std::unique_ptr<<br>
>    EngineBuilder EB;<br>
>    EB.setOptLevel(getOptLevel());<br>
>    auto TM = std::unique_ptr<TargetMachine>(EB.selectTarget());<br>
> -  auto &Context = getGlobalContext();<br>
> -  auto CallbackMgrBuilder =<br>
> -    OrcLazyJIT::createCallbackMgrBuilder(Triple(TM->getTargetTriple()));<br>
> +  auto CompileCallbackMgr =<br>
> +    OrcLazyJIT::createCompileCallbackMgr(Triple(TM->getTargetTriple()));<br>
><br>
>    // If we couldn't build the factory function then there must not be a callback<br>
>    // manager for this target. Bail out.<br>
> -  if (!CallbackMgrBuilder) {<br>
> +  if (!CompileCallbackMgr) {<br>
>      errs() << "No callback manager available for target '"<br>
>             << TM->getTargetTriple().str() << "'.\n";<br>
>      return 1;<br>
> @@ -169,7 +163,7 @@ int llvm::runOrcLazyJIT(std::unique_ptr<<br>
>    }<br>
><br>
>    // Everything looks good. Build the JIT.<br>
> -  OrcLazyJIT J(std::move(TM), Context, CallbackMgrBuilder,<br>
> +  OrcLazyJIT J(std::move(TM), std::move(CompileCallbackMgr),<br>
>                 std::move(IndirectStubsMgrBuilder),<br>
>                 OrcInlineStubs);<br>
><br>
><br>
> Modified: llvm/trunk/tools/lli/OrcLazyJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/lli/OrcLazyJIT.h (original)<br>
> +++ llvm/trunk/tools/lli/OrcLazyJIT.h Tue Nov  3 10:10:18 2015<br>
> @@ -23,7 +23,6 @@<br>
>  #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"<br>
>  #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"<br>
>  #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"<br>
> -#include "llvm/IR/LLVMContext.h"<br>
><br>
>  namespace llvm {<br>
><br>
> @@ -41,21 +40,16 @@ public:<br>
>      IndirectStubsManagerBuilder;<br>
>    typedef CODLayerT::ModuleSetHandleT ModuleHandleT;<br>
><br>
> -  typedef std::function<<br>
> -            std::unique_ptr<CompileCallbackMgr>(IRDumpLayerT&,<br>
> -                                                RuntimeDyld::MemoryManager&,<br>
> -                                                LLVMContext&)><br>
> -    CallbackManagerBuilder;<br>
> -<br>
> -  OrcLazyJIT(std::unique_ptr<TargetMachine> TM, LLVMContext &Context,<br>
> -             CallbackManagerBuilder &BuildCallbackMgr,<br>
> +  OrcLazyJIT(std::unique_ptr<TargetMachine> TM,<br>
> +             std::unique_ptr<CompileCallbackMgr> CCMgr,<br>
>               IndirectStubsManagerBuilder IndirectStubsMgrBuilder,<br>
>               bool InlineStubs)<br>
> -      : TM(std::move(TM)), DL(this->TM->createDataLayout()), ObjectLayer(),<br>
> +      : TM(std::move(TM)), DL(this->TM->createDataLayout()),<br>
> +       CCMgr(std::move(CCMgr)),<br>
> +       ObjectLayer(),<br>
>          CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),<br>
>          IRDumpLayer(CompileLayer, createDebugDumper()),<br>
> -        CCMgr(BuildCallbackMgr(IRDumpLayer, CCMgrMemMgr, Context)),<br>
> -        CODLayer(IRDumpLayer, extractSingleFunction, *CCMgr,<br>
> +        CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr,<br>
>                   std::move(IndirectStubsMgrBuilder), InlineStubs),<br>
>          CXXRuntimeOverrides(<br>
>              [this](const std::string &S) { return mangle(S); }) {}<br>
> @@ -68,8 +62,7 @@ public:<br>
>        DtorRunner.runViaLayer(CODLayer);<br>
>    }<br>
><br>
> -  static CallbackManagerBuilder createCallbackMgrBuilder(Triple T);<br>
> -<br>
> +  static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T);<br>
>    static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);<br>
><br>
>    ModuleHandleT addModule(std::unique_ptr<Module> M) {<br>
> @@ -155,10 +148,10 @@ private:<br>
>    DataLayout DL;<br>
>    SectionMemoryManager CCMgrMemMgr;<br>
><br>
> +  std::unique_ptr<CompileCallbackMgr> CCMgr;<br>
>    ObjLayerT ObjectLayer;<br>
>    CompileLayerT CompileLayer;<br>
>    IRDumpLayerT IRDumpLayer;<br>
> -  std::unique_ptr<CompileCallbackMgr> CCMgr;<br>
>    CODLayerT CODLayer;<br>
><br>
>    orc::LocalCXXRuntimeOverrides CXXRuntimeOverrides;<br>
><br>
> Modified: llvm/trunk/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp (original)<br>
> +++ llvm/trunk/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp Tue Nov  3 10:10:18 2015<br>
> @@ -19,11 +19,11 @@ namespace {<br>
>  class DummyCallbackManager : public orc::JITCompileCallbackManagerBase {<br>
>  public:<br>
>    DummyCallbackManager()<br>
> -      : JITCompileCallbackManagerBase(0, 0), NextStubAddress(0),<br>
> +      : JITCompileCallbackManagerBase(0), NextStubAddress(0),<br>
>          UniversalCompile([]() { return 0; }) {<br>
>    }<br>
><br>
> -  CompileCallbackInfo getCompileCallback(LLVMContext &Context) override {<br>
> +  CompileCallbackInfo getCompileCallback() override {<br>
>      return CompileCallbackInfo(++NextStubAddress, UniversalCompile);<br>
>    }<br>
>  public:<br>
><br>
> Modified: llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp?rev=251933&r1=251932&r2=251933&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp?rev=251933&r1=251932&r2=251933&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp (original)<br>
> +++ llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp Tue Nov  3 10:10:18 2015<br>
> @@ -82,7 +82,7 @@ TEST_F(OrcCAPIExecutionTest, TestEagerIR<br>
>      return;<br>
><br>
>    LLVMOrcJITStackRef JIT =<br>
> -    LLVMOrcCreateInstance(wrap(TM.get()), LLVMGetGlobalContext());<br>
> +    LLVMOrcCreateInstance(wrap(TM.get()));<br>
><br>
>    std::unique_ptr<Module> M = createTestModule(TM->getTargetTriple());<br>
><br>
> @@ -106,7 +106,7 @@ TEST_F(OrcCAPIExecutionTest, TestLazyIRC<br>
>      return;<br>
><br>
>    LLVMOrcJITStackRef JIT =<br>
> -    LLVMOrcCreateInstance(wrap(TM.get()), LLVMGetGlobalContext());<br>
> +    LLVMOrcCreateInstance(wrap(TM.get()));<br>
><br>
>    std::unique_ptr<Module> M = createTestModule(TM->getTargetTriple());<br>
><br>
> @@ -130,7 +130,7 @@ TEST_F(OrcCAPIExecutionTest, TestDirectC<br>
>      return;<br>
><br>
>    LLVMOrcJITStackRef JIT =<br>
> -    LLVMOrcCreateInstance(wrap(TM.get()), LLVMGetGlobalContext());<br>
> +    LLVMOrcCreateInstance(wrap(TM.get()));<br>
><br>
>    LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>