1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp
Lang Hames dde8f900ec [Orc] Rename IndirectStubsManagerBase to IndirectStubsManager.
No functional change.

llvm-svn: 254885
2015-12-06 19:44:45 +00:00

76 lines
2.4 KiB
C++

//===----- CompileOnDemandLayerTest.cpp - Unit tests for the COD layer ----===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "OrcTestCommon.h"
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "gtest/gtest.h"
using namespace llvm;
using namespace llvm::orc;
namespace {
class DummyCallbackManager : public orc::JITCompileCallbackManager {
public:
DummyCallbackManager() : JITCompileCallbackManager(0) { }
public:
void grow() override { llvm_unreachable("not implemented"); }
};
class DummyStubsManager : public orc::IndirectStubsManager {
public:
std::error_code createStub(StringRef StubName, TargetAddress InitAddr,
JITSymbolFlags Flags) override {
llvm_unreachable("Not implemented");
}
std::error_code createStubs(const StubInitsMap &StubInits) override {
llvm_unreachable("Not implemented");
}
JITSymbol findStub(StringRef Name, bool ExportedStubsOnly) override {
llvm_unreachable("Not implemented");
}
JITSymbol findPointer(StringRef Name) override {
llvm_unreachable("Not implemented");
}
std::error_code updatePointer(StringRef Name,
TargetAddress NewAddr) override {
llvm_unreachable("Not implemented");
}
};
TEST(CompileOnDemandLayerTest, FindSymbol) {
auto MockBaseLayer =
createMockBaseLayer<int>(DoNothingAndReturn<int>(0),
DoNothingAndReturn<void>(),
[](const std::string &Name, bool) {
if (Name == "foo")
return JITSymbol(1, JITSymbolFlags::Exported);
return JITSymbol(nullptr);
},
DoNothingAndReturn<JITSymbol>(nullptr));
typedef decltype(MockBaseLayer) MockBaseLayerT;
DummyCallbackManager CallbackMgr;
llvm::orc::CompileOnDemandLayer<MockBaseLayerT> COD(
MockBaseLayer, [](Function &F) { return std::set<Function *>{&F}; },
CallbackMgr, [] { return llvm::make_unique<DummyStubsManager>(); }, true);
auto Sym = COD.findSymbol("foo", true);
EXPECT_TRUE(!!Sym)
<< "CompileOnDemand::findSymbol should call findSymbol in the base layer.";
}
}