diff options
-rw-r--r-- | llvm/include/llvm/ExecutionEngine/Orc/Core.h | 88 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/Core.cpp | 84 | ||||
-rw-r--r-- | llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 57 |
5 files changed, 0 insertions, 231 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h deleted file mode 100644 index b1dc00c3fab..00000000000 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ /dev/null @@ -1,88 +0,0 @@ -//===------ Core.h -- Core ORC APIs (Layer, JITDylib, etc.) -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Contains core ORC APIs. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_EXECUTIONENGINE_ORC_CORE_H -#define LLVM_EXECUTIONENGINE_ORC_CORE_H - -#include "llvm/ExecutionEngine/JITSymbol.h" -#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h" - -#include <functional> -#include <map> -#include <set> - -namespace llvm { -namespace orc { - -/// @brief A set of symbol names (represented by SymbolStringPtrs for -// efficiency). -using SymbolNameSet = std::set<SymbolStringPtr>; - -/// @brief A map from symbol names (as SymbolStringPtrs) to JITSymbols -/// (address/flags pairs). -using SymbolMap = std::map<SymbolStringPtr, JITSymbol>; - -/// @brief A symbol query that returns results via a callback when results are -/// ready. -/// -/// makes a callback when all symbols are available. -class AsynchronousSymbolQuery { -public: - - /// @brief Callback to notify client that symbols have been resolved. - using SymbolsResolvedCallback = std::function<void(Expected<SymbolMap>)>; - - /// @brief Callback to notify client that symbols are ready for execution. - using SymbolsReadyCallback = std::function<void(Error)>; - - /// @brief Create a query for the given symbols, notify-resolved and - /// notify-ready callbacks. - AsynchronousSymbolQuery(const SymbolNameSet &Symbols, - SymbolsResolvedCallback NotifySymbolsResolved, - SymbolsReadyCallback NotifySymbolsReady); - - /// @brief Notify client that the query failed. - /// - /// If the notify-resolved callback has not been made yet, then it is called - /// with the given error, and the notify-finalized callback is never made. - /// - /// If the notify-resolved callback has already been made then then the - /// notify-finalized callback is called with the given error. - /// - /// It is illegal to call setFailed after both callbacks have been made. - void setFailed(Error Err); - - /// @brief Set the resolved symbol information for the given symbol name. - /// - /// If this symbol was the last one not resolved, this will trigger a call to - /// the notify-finalized callback passing the completed sybol map. - void setDefinition(SymbolStringPtr Name, JITSymbol Sym); - - /// @brief Notify the query that a requested symbol is ready for execution. - /// - /// This decrements the query's internal count of not-yet-ready symbols. If - /// this call to notifySymbolFinalized sets the counter to zero, it will call - /// the notify-finalized callback with Error::success as the value. - void notifySymbolFinalized(); -private: - SymbolMap Symbols; - size_t OutstandingResolutions = 0; - size_t OutstandingFinalizations = 0; - SymbolsResolvedCallback NotifySymbolsResolved; - SymbolsReadyCallback NotifySymbolsReady; -}; - -} // End namespace orc -} // End namespace llvm - -#endif // LLVM_EXECUTIONENGINE_ORC_CORE_H diff --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt index ee64990dfb4..f83e002c758 100644 --- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt @@ -1,5 +1,4 @@ add_llvm_library(LLVMOrcJIT - Core.cpp ExecutionUtils.cpp IndirectionUtils.cpp NullResolver.cpp diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp deleted file mode 100644 index e7f13c5c0e7..00000000000 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ /dev/null @@ -1,84 +0,0 @@ -//===--------- Core.cpp - Core ORC APIs (SymbolSource, VSO, etc.) ---------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ExecutionEngine/Orc/Core.h" -#include "llvm/ExecutionEngine/Orc/OrcError.h" - -namespace llvm { -namespace orc { - -AsynchronousSymbolQuery::AsynchronousSymbolQuery( - const SymbolNameSet &Symbols, - SymbolsResolvedCallback NotifySymbolsResolved, - SymbolsReadyCallback NotifySymbolsReady) - : NotifySymbolsResolved(std::move(NotifySymbolsResolved)), - NotifySymbolsReady(std::move(NotifySymbolsReady)) { - assert(this->NotifySymbolsResolved && - "Symbols resolved callback must be set"); - assert(this->NotifySymbolsReady && "Symbols ready callback must be set"); - OutstandingResolutions = OutstandingFinalizations = Symbols.size(); -} - -void AsynchronousSymbolQuery::setFailed(Error Err) { - OutstandingResolutions = OutstandingFinalizations = 0; - if (NotifySymbolsResolved) - NotifySymbolsResolved(std::move(Err)); - else - NotifySymbolsReady(std::move(Err)); -} - -void AsynchronousSymbolQuery::setDefinition(SymbolStringPtr Name, - JITSymbol Sym) { - // If OutstandingResolutions is zero we must have errored out already. Just - // ignore this. - if (OutstandingResolutions == 0) - return; - - assert(NotifySymbolsResolved && "Notify callback not set"); - - errs() - << "OutstandingResolutions = " << OutstandingResolutions << "\n" - << "OutstandingFinalizations = " << OutstandingFinalizations << "\n" - << "Symbols.size() = " << Symbols.size() << "\n" - << "Symbols.count(Name) = " << Symbols.count(Name) << "\n" - << "Callback size = " << sizeof(SymbolsResolvedCallback) << "\n" - << "Callback offset = " - << (size_t)((char*)&NotifySymbolsResolved - (char*)this) << "\n"; - - assert(!Symbols.count(Name) && - "Symbol has already been assigned an address"); - errs() << "Past assert\n"; - Symbols.insert(std::make_pair(std::move(Name), std::move(Sym))); - errs() << "Past insert\n"; - --OutstandingResolutions; - errs() << "Past subtract\n"; - if (OutstandingResolutions == 0) { - errs() << "Past test\n"; - NotifySymbolsResolved(std::move(Symbols)); - // Null out NotifySymbolsResolved to indicate that we've already called it. - errs() << "Past callback\n"; - NotifySymbolsResolved = {}; - errs() << "Past callback-reset\n"; - } -} - -void AsynchronousSymbolQuery::notifySymbolFinalized() { - // If OutstandingFinalizations is zero we must have errored out already. Just - // ignore this. - if (OutstandingFinalizations == 0) - return; - - assert(OutstandingFinalizations > 0 && "All symbols already finalized"); - --OutstandingFinalizations; - if (OutstandingFinalizations == 0) - NotifySymbolsReady(Error::success()); -} - -} // End namespace orc. -} // End namespace llvm. diff --git a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt index 25697300e33..dd0281d0b73 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt +++ b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt @@ -11,7 +11,6 @@ set(LLVM_LINK_COMPONENTS add_llvm_unittest(OrcJITTests CompileOnDemandLayerTest.cpp - CoreAPIsTest.cpp IndirectionUtilsTest.cpp GlobalMappingLayerTest.cpp LazyEmittingLayerTest.cpp diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp deleted file mode 100644 index 51a14f58eac..00000000000 --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------- CoreAPIsTest.cpp - Unit tests for Core ORC APIs ----------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ExecutionEngine/Orc/Core.h" -#include "OrcTestCommon.h" -#include "gtest/gtest.h" - -using namespace llvm; -using namespace llvm::orc; - -namespace { - -TEST(CoreAPIsTest, AsynchronousSymbolQuerySuccessfulResolutionOnly) { - SymbolStringPool SP; - auto Foo = SP.intern("foo"); - constexpr JITTargetAddress FakeAddr = 0xdeadbeef; - SymbolNameSet Names({Foo}); - - bool OnResolutionRun = false; - bool OnReadyRun = false; - auto OnResolution = - [&](Expected<SymbolMap> Result) { - errs() << "Entered notify\n"; - EXPECT_TRUE(!!Result) << "Resolution unexpectedly returned error"; - errs() << "Past expect 1\n"; - auto I = Result->find(Foo); - errs() << "Past find\n"; - EXPECT_NE(I, Result->end()) << "Could not find symbol definition"; - errs() << "Past expect 2\n"; - EXPECT_EQ(cantFail(I->second.getAddress()), FakeAddr) - << "Resolution returned incorrect result"; - errs() << "Past expect 3\n"; - OnResolutionRun = true; - errs() << "Exiting notify\n"; - }; - auto OnReady = - [&](Error Err) { - cantFail(std::move(Err)); - OnReadyRun = true; - }; - - AsynchronousSymbolQuery Q(Names, OnResolution, OnReady); - - Q.setDefinition(Foo, JITSymbol(FakeAddr, JITSymbolFlags::Exported)); - - EXPECT_TRUE(OnResolutionRun) << "OnResolutionCallback was not run"; - EXPECT_FALSE(OnReadyRun) << "OnReady unexpectedly run"; - errs() << "Exiting test\n"; -} - -} |