summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-07-21 00:12:05 +0000
committerLang Hames <lhames@gmail.com>2018-07-21 00:12:05 +0000
commit960246dbee67c827eb4339b0fe68b7534b5a79d8 (patch)
tree31873c4fc592065ca74526ceff09d85665158043 /llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
parented92f608bb0f138342aa0280e7b6899b5ff732ba (diff)
downloadbcm5719-llvm-960246dbee67c827eb4339b0fe68b7534b5a79d8.tar.gz
bcm5719-llvm-960246dbee67c827eb4339b0fe68b7534b5a79d8.zip
[ORC] Re-apply r336760 with fixes.
llvm-svn: 337637
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp54
1 files changed, 48 insertions, 6 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index d53c4558e0c..baa1e3b5e8c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -231,6 +231,48 @@ TEST_F(CoreAPIsStandardTest, TestChainedAliases) {
<< "\"Baz\"'s address should match \"Foo\"'s";
}
+TEST_F(CoreAPIsStandardTest, TestBasicReExports) {
+ // Test that the basic use case of re-exporting a single symbol from another
+ // VSO works.
+ cantFail(V.define(absoluteSymbols({{Foo, FooSym}})));
+
+ auto &V2 = ES.createVSO("V2");
+
+ cantFail(V2.define(reexports(V, {{Bar, {Foo, BarSym.getFlags()}}})));
+
+ auto Result = cantFail(lookup({&V2}, Bar));
+ EXPECT_EQ(Result.getAddress(), FooSym.getAddress())
+ << "Re-export Bar for symbol Foo should match FooSym's address";
+}
+
+TEST_F(CoreAPIsStandardTest, TestThatReExportsDontUnnecessarilyMaterialize) {
+ // Test that re-exports do not materialize symbols that have not been queried
+ // for.
+ cantFail(V.define(absoluteSymbols({{Foo, FooSym}})));
+
+ bool BarMaterialized = false;
+ auto BarMU = llvm::make_unique<SimpleMaterializationUnit>(
+ SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
+ [&](MaterializationResponsibility R) {
+ BarMaterialized = true;
+ R.resolve({{Bar, BarSym}});
+ R.finalize();
+ });
+
+ cantFail(V.define(BarMU));
+
+ auto &V2 = ES.createVSO("V2");
+
+ cantFail(V2.define(reexports(
+ V, {{Baz, {Foo, BazSym.getFlags()}}, {Qux, {Bar, QuxSym.getFlags()}}})));
+
+ auto Result = cantFail(lookup({&V2}, Baz));
+ EXPECT_EQ(Result.getAddress(), FooSym.getAddress())
+ << "Re-export Baz for symbol Foo should match FooSym's address";
+
+ EXPECT_FALSE(BarMaterialized) << "Bar should not have been materialized";
+}
+
TEST_F(CoreAPIsStandardTest, TestTrivialCircularDependency) {
Optional<MaterializationResponsibility> FooR;
auto FooMU = llvm::make_unique<SimpleMaterializationUnit>(
@@ -338,15 +380,15 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneVSO) {
NoDependenciesToRegister);
// Add a circular dependency: Foo -> Bar, Bar -> Baz, Baz -> Foo.
- FooR->addDependencies({{&V, SymbolNameSet({Bar})}});
- BarR->addDependencies({{&V, SymbolNameSet({Baz})}});
- BazR->addDependencies({{&V, SymbolNameSet({Foo})}});
+ FooR->addDependenciesForAll({{&V, SymbolNameSet({Bar})}});
+ BarR->addDependenciesForAll({{&V, SymbolNameSet({Baz})}});
+ BazR->addDependenciesForAll({{&V, SymbolNameSet({Foo})}});
// Add self-dependencies for good measure. This tests that the implementation
// of addDependencies filters these out.
- FooR->addDependencies({{&V, SymbolNameSet({Foo})}});
- BarR->addDependencies({{&V, SymbolNameSet({Bar})}});
- BazR->addDependencies({{&V, SymbolNameSet({Baz})}});
+ FooR->addDependenciesForAll({{&V, SymbolNameSet({Foo})}});
+ BarR->addDependenciesForAll({{&V, SymbolNameSet({Bar})}});
+ BazR->addDependenciesForAll({{&V, SymbolNameSet({Baz})}});
// Check that nothing has been resolved yet.
EXPECT_FALSE(FooResolved) << "\"Foo\" should not be resolved yet";
OpenPOWER on IntegriCloud