diff options
author | Lang Hames <lhames@gmail.com> | 2018-05-31 19:29:03 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-05-31 19:29:03 +0000 |
commit | e9015c77605278e4650908cfa5491e3badc58e75 (patch) | |
tree | 1943d11c37524ecffdc9424a6190e6b90bd24f25 /unittests/ExecutionEngine | |
parent | 5da314cda88ceeea8bf303ebfeeea1c8b30915c3 (diff) |
[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).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ExecutionEngine')
-rw-r--r-- | unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index 1e2a7caa60f..bc7a3622a06 100644 --- a/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/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 |