summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-08-13 16:05:18 +0000
committerLang Hames <lhames@gmail.com>2019-08-13 16:05:18 +0000
commit52a34a78d9aff1bb5e66e7c32490229ea177e075 (patch)
tree15ee224459a7c3aed11d4868e4501946dfdd530c /llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
parent76945821b9cad3baebad5c36ae00ab173f8529c6 (diff)
downloadbcm5719-llvm-52a34a78d9aff1bb5e66e7c32490229ea177e075.tar.gz
bcm5719-llvm-52a34a78d9aff1bb5e66e7c32490229ea177e075.zip
[ORC] Refactor definition-generation, add a generator for static libraries.
This patch replaces the JITDylib::DefinitionGenerator typedef with a class of the same name, and adds support for attaching a sequence of DefinitionGeneration objects to a JITDylib. This patch also adds a new definition generator, StaticLibraryDefinitionGenerator, that can be used to add symbols fom a static library to a JITDylib. An object from the static library will be added (via a supplied ObjectLayer reference) whenever a symbol from that object is referenced. To enable testing, lli is updated to add support for the --extra-archive option when running in -jit-kind=orc-lazy mode. llvm-svn: 368707
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index adc4f52b8e4..375318c323f 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -243,14 +243,15 @@ TEST_F(CoreAPIsStandardTest, LookupFlagsTest) {
TEST_F(CoreAPIsStandardTest, LookupWithGeneratorFailure) {
- class BadGenerator {
+ class BadGenerator : public JITDylib::DefinitionGenerator {
public:
- Expected<SymbolNameSet> operator()(JITDylib &, const SymbolNameSet &) {
+ Expected<SymbolNameSet> tryToGenerate(JITDylib &,
+ const SymbolNameSet &) override {
return make_error<StringError>("BadGenerator", inconvertibleErrorCode());
}
};
- JD.setGenerator(BadGenerator());
+ JD.addGenerator(llvm::make_unique<BadGenerator>());
EXPECT_THAT_ERROR(JD.lookupFlags({Foo}).takeError(), Failed<StringError>())
<< "Generator failure did not propagate through lookupFlags";
@@ -343,7 +344,7 @@ TEST_F(CoreAPIsStandardTest, TestReexportsGenerator) {
auto Filter = [this](SymbolStringPtr Name) { return Name != Bar; };
- JD.setGenerator(ReexportsGenerator(JD2, false, Filter));
+ JD.addGenerator(llvm::make_unique<ReexportsGenerator>(JD2, false, Filter));
auto Flags = cantFail(JD.lookupFlags({Foo, Bar, Baz}));
EXPECT_EQ(Flags.size(), 1U) << "Unexpected number of results";
@@ -667,10 +668,29 @@ TEST_F(CoreAPIsStandardTest, DefineMaterializingSymbol) {
TEST_F(CoreAPIsStandardTest, GeneratorTest) {
cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));
- JD.setGenerator([&](JITDylib &JD2, const SymbolNameSet &Names) {
- cantFail(JD2.define(absoluteSymbols({{Bar, BarSym}})));
- return SymbolNameSet({Bar});
- });
+ class TestGenerator : public JITDylib::DefinitionGenerator {
+ public:
+ TestGenerator(SymbolMap Symbols) : Symbols(std::move(Symbols)) {}
+ Expected<SymbolNameSet> tryToGenerate(JITDylib &JD,
+ const SymbolNameSet &Names) {
+ SymbolMap NewDefs;
+ SymbolNameSet NewNames;
+
+ for (auto &Name : Names) {
+ if (Symbols.count(Name)) {
+ NewDefs[Name] = Symbols[Name];
+ NewNames.insert(Name);
+ }
+ }
+ cantFail(JD.define(absoluteSymbols(std::move(NewDefs))));
+ return NewNames;
+ };
+
+ private:
+ SymbolMap Symbols;
+ };
+
+ JD.addGenerator(llvm::make_unique<TestGenerator>(SymbolMap({{Bar, BarSym}})));
auto Result =
cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Bar}));
OpenPOWER on IntegriCloud