diff options
author | Lang Hames <lhames@gmail.com> | 2019-04-26 22:58:39 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2019-04-26 22:58:39 +0000 |
commit | a9fdf375b3769a1df18d72aa6eb1e627a22a29e7 (patch) | |
tree | d0da4440cb41c3968535132865e0823055a1930b /llvm/tools | |
parent | 353f593976d8edf4310498358582e3d49f807754 (diff) | |
download | bcm5719-llvm-a9fdf375b3769a1df18d72aa6eb1e627a22a29e7.tar.gz bcm5719-llvm-a9fdf375b3769a1df18d72aa6eb1e627a22a29e7.zip |
[ORC] Add a 'plugin' interface to ObjectLinkingLayer for events/configuration.
ObjectLinkingLayer::Plugin provides event notifications when objects are loaded,
emitted, and removed. It also provides a modifyPassConfig callback that allows
plugins to modify the JITLink pass configuration.
This patch moves eh-frame registration into its own plugin, and teaches
llvm-jitlink to only add that plugin when performing execution runs on
non-Windows platforms. This should allow us to re-enable the test case that was
removed in r359198.
llvm-svn: 359357
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 383442f8a4c..5ecf66ae9e4 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -214,13 +214,27 @@ static void dumpSectionContents(raw_ostream &OS, AtomGraph &G) { } } -Session::Session(Triple TT) - : ObjLayer(ES, MemMgr, ObjectLinkingLayer::NotifyLoadedFunction(), - ObjectLinkingLayer::NotifyEmittedFunction(), - [this](const Triple &TT, PassConfiguration &PassConfig) { - modifyPassConfig(TT, PassConfig); - }), - TT(std::move(TT)) {} +Session::Session(Triple TT) : ObjLayer(ES, MemMgr), TT(std::move(TT)) { + + /// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the + /// Session. + class JITLinkSessionPlugin : public ObjectLinkingLayer::Plugin { + public: + JITLinkSessionPlugin(Session &S) : S(S) {} + void modifyPassConfig(MaterializationResponsibility &MR, const Triple &TT, + PassConfiguration &PassConfig) { + S.modifyPassConfig(TT, PassConfig); + } + + private: + Session &S; + }; + + if (!NoExec && !TT.isOSWindows()) + ObjLayer.addPlugin(llvm::make_unique<LocalEHFrameRegistrationPlugin>()); + + ObjLayer.addPlugin(llvm::make_unique<JITLinkSessionPlugin>(*this)); +} void Session::dumpSessionInfo(raw_ostream &OS) { OS << "Registered addresses:\n" << SymbolInfos << FileInfos; |