diff options
author | Lang Hames <lhames@gmail.com> | 2018-08-02 20:13:58 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-08-02 20:13:58 +0000 |
commit | be1066de56118a93f11ea53ea1ac6eb95b8a90f7 (patch) | |
tree | fa652d46b44cb3b8d0496ea194012ccf6b6a2ad3 /llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | |
parent | 8899c29b1e0835f06972b03adab2e8fd91339c8d (diff) | |
download | bcm5719-llvm-be1066de56118a93f11ea53ea1ac6eb95b8a90f7.tar.gz bcm5719-llvm-be1066de56118a93f11ea53ea1ac6eb95b8a90f7.zip |
[ORC] Add a re-exports fallback definition generator.
An instance of ReexportsFallbackDefinitionGenerator can be attached to a VSO
(via setFallbackDefinitionGenerator) to re-export symbols on demandy from a
backing VSO.
llvm-svn: 338764
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp')
-rw-r--r-- | llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index baa1e3b5e8c..68c081dd520 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -273,6 +273,28 @@ TEST_F(CoreAPIsStandardTest, TestThatReExportsDontUnnecessarilyMaterialize) { EXPECT_FALSE(BarMaterialized) << "Bar should not have been materialized"; } +TEST_F(CoreAPIsStandardTest, TestReexportsFallbackGenerator) { + // Test that a re-exports fallback generator can dynamically generate + // reexports. + + auto &V2 = ES.createVSO("V2"); + cantFail(V2.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); + + auto Filter = [this](SymbolStringPtr Name) { return Name != Bar; }; + + V.setFallbackDefinitionGenerator( + ReexportsFallbackDefinitionGenerator(V2, Filter)); + + auto Flags = V.lookupFlags({Foo, Bar, Baz}); + EXPECT_EQ(Flags.size(), 1U) << "Unexpected number of results"; + EXPECT_EQ(Flags[Foo], FooSym.getFlags()) << "Unexpected flags for Foo"; + + auto Result = cantFail(lookup({&V}, Foo)); + + EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) + << "Incorrect reexported symbol address"; +} + TEST_F(CoreAPIsStandardTest, TestTrivialCircularDependency) { Optional<MaterializationResponsibility> FooR; auto FooMU = llvm::make_unique<SimpleMaterializationUnit>( |