1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
//===----- 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:
Error createStub(StringRef StubName, TargetAddress InitAddr,
JITSymbolFlags Flags) override {
llvm_unreachable("Not implemented");
}
Error 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");
}
Error 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.";
}
}
|