summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-09-12 21:48:59 +0000
committerLang Hames <lhames@gmail.com>2018-09-12 21:48:59 +0000
commit13014d3ce336fa30ca480ae4912ab72847910610 (patch)
tree11c79662b71a68e7a162c9a77a5344d7a24e0122 /llvm/unittests/ExecutionEngine/Orc
parent9d0f9ced40627bb2d1566546c2ebe861ff44284c (diff)
downloadbcm5719-llvm-13014d3ce336fa30ca480ae4912ab72847910610.tar.gz
bcm5719-llvm-13014d3ce336fa30ca480ae4912ab72847910610.zip
[ORC] Add a special 'main' JITDylib that is created on ExecutionSession
construction, a new convenience lookup method, and add-to layer methods. ExecutionSession now creates a special 'main' JITDylib upon construction. All subsequently created JITDylibs are added to the main JITDylib's search order by default (controlled by the AddToMainDylibSearchOrder parameter to ExecutionSession::createDylib). The main JITDylib's search order will be used in the future to properly handle cross-JITDylib weak symbols, with the first definition in this search order selected. This commit also adds a new ExecutionSession::lookup convenience method that performs a blocking lookup using the main JITDylib's search order, as this will be a very common operation for clients. Finally, new convenience overloads of IRLayer and ObjectLayer's add methods are introduced that add the given program representations to the main dylib, which is likely to be the common case. llvm-svn: 342086
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp10
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h4
2 files changed, 12 insertions, 2 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index 796736e86bd..b3cd4b517ca 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -815,4 +815,14 @@ TEST_F(CoreAPIsStandardTest, TestMaterializeWeakSymbol) {
FooResponsibility->emit();
}
+TEST_F(CoreAPIsStandardTest, TestMainJITDylibAndDefaultLookupOrder) {
+ cantFail(ES.getMainJITDylib().define(absoluteSymbols({{Foo, FooSym}})));
+ auto Results = cantFail(ES.lookup({Foo}));
+
+ EXPECT_EQ(Results.size(), 1U) << "Incorrect number of results";
+ EXPECT_EQ(Results.count(Foo), 1U) << "Expected result for 'Foo'";
+ EXPECT_EQ(Results[Foo].getAddress(), FooSym.getAddress())
+ << "Expected result address to match Foo's address";
+}
+
} // namespace
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index 05a0b11b866..acc0e5b04ab 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -46,9 +46,9 @@ namespace orc {
// linkage and non-hidden visibility.
// (5) V -- A JITDylib associated with ES.
class CoreAPIsBasedStandardTest : public testing::Test {
-public:
protected:
- ExecutionSession ES;
+ std::shared_ptr<SymbolStringPool> SSP = std::make_shared<SymbolStringPool>();
+ ExecutionSession ES{SSP};
JITDylib &JD = ES.createJITDylib("JD");
SymbolStringPtr Foo = ES.getSymbolStringPool().intern("foo");
SymbolStringPtr Bar = ES.getSymbolStringPool().intern("bar");
OpenPOWER on IntegriCloud