summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-04-30 00:03:26 +0000
committerLang Hames <lhames@gmail.com>2019-04-30 00:03:26 +0000
commitb12867230cd84a3cf9d451a8b25f55789cc59bb3 (patch)
tree24f934b3d2e2c9d9d0ae1669e2708bac1a4658fd /llvm/unittests/ExecutionEngine/Orc
parent1a52eaf7733867f1e92921a057a4cace203050b1 (diff)
downloadbcm5719-llvm-b12867230cd84a3cf9d451a8b25f55789cc59bb3.tar.gz
bcm5719-llvm-b12867230cd84a3cf9d451a8b25f55789cc59bb3.zip
[ORC] Allow JITDylib definition generators to return Errors.
Background: A definition generator can be attached to a JITDylib to generate new definitions in response to queries. For example: a generator that forwards calls to dlsym can map symbols from a dynamic library into the JIT process on demand. If definition generation fails then the generator should be able to return an error. This allows the JIT API to distinguish between the case where a generator does not provide a definition, and the case where it was not able to determine whether it provided a definition due to an error. The immediate motivation for this is cross-process symbol lookups: If the remote-lookup generator is attached to a JITDylib early in the search list, and if a generator failure is misinterpreted as "no definition in this JITDylib" then lookup may continue and bind to a different definition in a later JITDylib, which is a bug. llvm-svn: 359521
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp26
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp4
2 files changed, 25 insertions, 5 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index 7b29f4c90da..ec167a1cdbd 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -216,7 +216,7 @@ TEST_F(CoreAPIsStandardTest, ChainedJITDylibLookup) {
OnReadyRun = true;
});
- JD2.legacyLookup(Q, JD.legacyLookup(Q, {Foo}));
+ cantFail(JD2.legacyLookup(Q, cantFail(JD.legacyLookup(Q, {Foo}))));
EXPECT_TRUE(OnResolvedRun) << "OnResolved was not run for empty query";
EXPECT_TRUE(OnReadyRun) << "OnReady was not run for empty query";
@@ -260,7 +260,7 @@ TEST_F(CoreAPIsStandardTest, LookupFlagsTest) {
SymbolNameSet Names({Foo, Bar, Baz});
- auto SymbolFlags = JD.lookupFlags(Names);
+ auto SymbolFlags = cantFail(JD.lookupFlags(Names));
EXPECT_EQ(SymbolFlags.size(), 2U)
<< "Returned symbol flags contains unexpected results";
@@ -273,6 +273,26 @@ TEST_F(CoreAPIsStandardTest, LookupFlagsTest) {
<< "Incorrect flags returned for Bar";
}
+TEST_F(CoreAPIsStandardTest, LookupWithGeneratorFailure) {
+
+ class BadGenerator {
+ public:
+ Expected<SymbolNameSet> operator()(JITDylib &, const SymbolNameSet &) {
+ return make_error<StringError>("BadGenerator", inconvertibleErrorCode());
+ }
+ };
+
+ JD.setGenerator(BadGenerator());
+
+ EXPECT_THAT_ERROR(JD.lookupFlags({Foo}).takeError(), Failed<StringError>())
+ << "Generator failure did not propagate through lookupFlags";
+
+ EXPECT_THAT_ERROR(
+ ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}).takeError(),
+ Failed<StringError>())
+ << "Generator failure did not propagate through lookup";
+}
+
TEST_F(CoreAPIsStandardTest, TestBasicAliases) {
cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}})));
cantFail(JD.define(symbolAliases({{Baz, {Foo, JITSymbolFlags::Exported}},
@@ -356,7 +376,7 @@ TEST_F(CoreAPIsStandardTest, TestReexportsGenerator) {
JD.setGenerator(ReexportsGenerator(JD2, false, Filter));
- auto Flags = JD.lookupFlags({Foo, Bar, Baz});
+ auto Flags = cantFail(JD.lookupFlags({Foo, Bar, Baz}));
EXPECT_EQ(Flags.size(), 1U) << "Unexpected number of results";
EXPECT_EQ(Flags[Foo], FooSym.getFlags()) << "Unexpected flags for Foo";
diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
index ea7479ff1c2..dca3eeb75fe 100644
--- a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
@@ -24,7 +24,7 @@ TEST_F(LegacyAPIsStandardTest, TestLambdaSymbolResolver) {
auto Resolver = createSymbolResolver(
[&](const SymbolNameSet &Symbols) {
- auto FlagsMap = JD.lookupFlags(Symbols);
+ auto FlagsMap = cantFail(JD.lookupFlags(Symbols));
SymbolNameSet Result;
for (auto &KV : FlagsMap)
if (!KV.second.isStrong())
@@ -32,7 +32,7 @@ TEST_F(LegacyAPIsStandardTest, TestLambdaSymbolResolver) {
return Result;
},
[&](std::shared_ptr<AsynchronousSymbolQuery> Q, SymbolNameSet Symbols) {
- return JD.legacyLookup(std::move(Q), Symbols);
+ return cantFail(JD.legacyLookup(std::move(Q), Symbols));
});
auto RS = Resolver->getResponsibilitySet(SymbolNameSet({Bar, Baz}));
OpenPOWER on IntegriCloud