[ORC] Remove AsynchronousSymbolQuery while I debug an issue on one of the

builders.

llvm-svn: 321941
This commit is contained in:
Lang Hames 2018-01-06 20:14:22 +00:00
parent 80788d8088
commit 0b93cd7351
5 changed files with 0 additions and 231 deletions

View File

@ -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

View File

@ -1,5 +1,4 @@
add_llvm_library(LLVMOrcJIT
Core.cpp
ExecutionUtils.cpp
IndirectionUtils.cpp
NullResolver.cpp

View File

@ -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.

View File

@ -11,7 +11,6 @@ set(LLVM_LINK_COMPONENTS
add_llvm_unittest(OrcJITTests
CompileOnDemandLayerTest.cpp
CoreAPIsTest.cpp
IndirectionUtilsTest.cpp
GlobalMappingLayerTest.cpp
LazyEmittingLayerTest.cpp

View File

@ -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";
}
}