summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-05-31 19:29:03 +0000
committerLang Hames <lhames@gmail.com>2018-05-31 19:29:03 +0000
commit6fe6616c474a722d7516161c9cee48dc191a215e (patch)
tree481ce4de958d75406ae58d82031b64a1720275a4 /llvm/unittests/ExecutionEngine
parentd3a76f5bbc7b39d246e910779a2592ce67fe1e48 (diff)
downloadbcm5719-llvm-6fe6616c474a722d7516161c9cee48dc191a215e.tar.gz
bcm5719-llvm-6fe6616c474a722d7516161c9cee48dc191a215e.zip
[ORC] Add a getRequestedSymbols method to MaterializationResponsibility.
This method returns the set of symbols in the target VSO that have queries waiting on them. This can be used to make decisions about which symbols to delegate to another MaterializationUnit (typically this will involve delegating all symbols that have *not* been requested to another MaterializationUnit so that materialization of those symbols can be deferred until they are requested). llvm-svn: 333684
Diffstat (limited to 'llvm/unittests/ExecutionEngine')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index 1e2a7caa60f..bc7a3622a06 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -678,4 +678,60 @@ TEST(CoreAPIsTest, TestLookupWithThreadedMaterialization) {
#endif
}
+TEST(CoreAPIsTest, TestGetRequestedSymbolsAndDelegate) {
+ ExecutionSession ES;
+ auto Foo = ES.getSymbolStringPool().intern("foo");
+ auto Bar = ES.getSymbolStringPool().intern("bar");
+
+ JITEvaluatedSymbol FooSym(0xdeadbeef, JITSymbolFlags::Exported);
+ JITEvaluatedSymbol BarSym(0xcafef00d, JITSymbolFlags::Exported);
+
+ SymbolNameSet Names({Foo, Bar});
+
+ bool FooMaterialized = false;
+ bool BarMaterialized = false;
+
+ auto MU = llvm::make_unique<SimpleMaterializationUnit>(
+ SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
+ [&](MaterializationResponsibility R) {
+ auto Requested = R.getRequestedSymbols();
+ EXPECT_EQ(Requested.size(), 1U) << "Expected one symbol requested";
+ EXPECT_EQ(*Requested.begin(), Foo) << "Expected \"Foo\" requested";
+
+ auto NewMU = llvm::make_unique<SimpleMaterializationUnit>(
+ SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
+ [&](MaterializationResponsibility R2) {
+ R2.resolve(SymbolMap({{Bar, BarSym}}));
+ R2.finalize();
+ BarMaterialized = true;
+ });
+
+ R.delegate(std::move(NewMU));
+
+ R.resolve(SymbolMap({{Foo, FooSym}}));
+ R.finalize();
+
+ FooMaterialized = true;
+ });
+
+ auto &V = ES.createVSO("V");
+
+ cantFail(V.define(MU));
+
+ EXPECT_FALSE(FooMaterialized) << "Foo should not be materialized yet";
+ EXPECT_FALSE(BarMaterialized) << "Bar should not be materialized yet";
+
+ auto FooSymResult = cantFail(lookup({&V}, Foo));
+ EXPECT_EQ(FooSymResult.getAddress(), FooSym.getAddress())
+ << "Address mismatch for Foo";
+
+ EXPECT_TRUE(FooMaterialized) << "Foo should be materialized now";
+ EXPECT_FALSE(BarMaterialized) << "Bar still should not be materialized";
+
+ auto BarSymResult = cantFail(lookup({&V}, Bar));
+ EXPECT_EQ(BarSymResult.getAddress(), BarSym.getAddress())
+ << "Address mismatch for Bar";
+ EXPECT_TRUE(BarMaterialized) << "Bar should be materialized now";
+}
+
} // namespace
OpenPOWER on IntegriCloud