[llvm] r277257 - [Orc] Add support for updating stub targets to CompileOnDemandLayer.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 1 15:49:25 PDT 2016


On Mon, Aug 1, 2016 at 3:46 PM Lang Hames <lhames at gmail.com> wrote:

> Hi Dave,
>
> Why is the C binding the best path to testing this? That seems
>> strange/surprising to me. (would expect it'd be testable via the C++ API in
>> a more narrow way sooner/without as much other infrastructure)
>
>
> Actually we could add a test to the CompileOnDemandLayer tests that
> "updatePointer" returns true for a symbol that has been added, and false
> otherwise.
>
> To actually test the behavior though we need an execution test. Since
> execution unit tests have a higher maintenance burden (can only be run on
> certain platforms, require a fully working stack) we only maintain one: the
> C Bindings Stack unit test.
>

Ah, rightio, thanks for the context.


>
> - Lang.
>
> On Mon, Aug 1, 2016 at 9:28 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>>
>>
>> On Fri, Jul 29, 2016 at 6:05 PM Lang Hames via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: lhames
>>> Date: Fri Jul 29 19:57:54 2016
>>> New Revision: 277257
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=277257&view=rev
>>> Log:
>>> [Orc] Add support for updating stub targets to CompileOnDemandLayer.
>>>
>>> This makes it possible to implement re-optimization on top of the
>>> CompileOnDemandLayer.
>>>
>>> Test case to come in a future patch: This will need an execution test,
>>> and
>>> execution tests require a full working stack. The best option is to
>>> plumb this
>>> API up to the C Bindings stack and add a C bindings test for this.
>>>
>>
>> Why is the C binding the best path to testing this? That seems
>> strange/surprising to me. (would expect it'd be testable via the C++ API in
>> a more narrow way sooner/without as much other infrastructure)
>>
>>
>>>
>>> Patch by Sean Ogden. Thanks Sean!
>>>
>>>
>>> Modified:
>>>     llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
>>>     llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
>>>
>>> Modified:
>>> llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=277257&r1=277256&r2=277257&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
>>> (original)
>>> +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
>>> Fri Jul 29 19:57:54 2016
>>> @@ -236,6 +236,32 @@ public:
>>>      return H->findSymbol(Name, ExportedSymbolsOnly);
>>>    }
>>>
>>> +  /// @brief Update the stub for the given function to point at
>>> FnBodyAddr.
>>> +  /// This can be used to support re-optimization.
>>> +  /// @return true if the function exists and the stub is updated, false
>>> +  ///         otherwise.
>>> +  //
>>> +  // FIXME: We should track and free associated resources (unused
>>> compile
>>> +  //        callbacks, uncompiled IR, and no-longer-needed/reachable
>>> function
>>> +  //        implementations).
>>> +  // FIXME: Return Error once the JIT APIs are Errorized.
>>> +  bool updatePointer(std::string FuncName, TargetAddress FnBodyAddr) {
>>> +    //Find out which logical dylib contains our symbol
>>> +    auto LDI = LogicalDylibs.begin();
>>> +    for (auto LDE = LogicalDylibs.end(); LDI != LDE; ++LDI) {
>>> +      if (auto LMResources =
>>> LDI->getLogicalModuleResourcesForSymbol(FuncName, false)) {
>>> +        Module &SrcM = LMResources->SourceModule->getResource();
>>> +        std::string CalledFnName = mangle(FuncName,
>>> SrcM.getDataLayout());
>>> +        if (auto EC =
>>> LMResources->StubsMgr->updatePointer(CalledFnName, FnBodyAddr)) {
>>> +          return false;
>>> +        }
>>> +        else
>>> +          return true;
>>> +      }
>>> +    }
>>> +    return false;
>>> +  }
>>> +
>>>  private:
>>>
>>>    template <typename ModulePtrT>
>>>
>>> Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h?rev=277257&r1=277256&r2=277257&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h (original)
>>> +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h Fri Jul
>>> 29 19:57:54 2016
>>> @@ -123,6 +123,16 @@ public:
>>>
>>>    LogicalDylibResources& getDylibResources() { return DylibResources; }
>>>
>>> +  LogicalModuleResources*
>>> +  getLogicalModuleResourcesForSymbol(const std::string &Name,
>>> +                                     bool ExportedSymbolsOnly) {
>>> +    for (auto LMI = LogicalModules.begin(), LME = LogicalModules.end();
>>> +         LMI != LME; ++LMI)
>>> +      if (auto Sym = LMI->Resources.findSymbol(Name,
>>> ExportedSymbolsOnly))
>>> +        return &LMI->Resources;
>>> +    return nullptr;
>>> +  }
>>> +
>>>  protected:
>>>    BaseLayerT BaseLayer;
>>>    LogicalModuleList LogicalModules;
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160801/95b8f2a8/attachment.html>


More information about the llvm-commits mailing list