mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-11 15:07:58 +00:00
075c1e2e1a
This patch replaces RuntimeDyld::SymbolInfo with JITSymbol: A symbol class that is capable of lazy materialization (i.e. the symbol definition needn't be emitted until the address is requested). This can be used to support common and weak symbols in the JIT (though this is not implemented in this patch). For consistency, RuntimeDyld::SymbolResolver is renamed to JITSymbolResolver. For space efficiency a new class, JITEvaluatedSymbol, is introduced that behaves like the old RuntimeDyld::SymbolInfo - i.e. it is just a pair of an address and symbol flags. Instances of JITEvaluatedSymbol can be used in symbol-tables to avoid paying the space cost of the materializer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277386 91177308-0d34-0410-b5e6-96231b3b80d8
74 lines
2.2 KiB
C++
74 lines
2.2 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:
|
|
Error createStub(StringRef StubName, JITTargetAddress 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, JITTargetAddress 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.";
|
|
}
|
|
}
|