summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2017-07-04 04:42:30 +0000
committerLang Hames <lhames@gmail.com>2017-07-04 04:42:30 +0000
commit5b51816020a0daf35f8c24ca06ddffb24d1d493e (patch)
treee31025566467d993f049a6ed82299fc64fe83401 /llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
parentb224d985940212e4f8986a5f505d7c7bff563fb4 (diff)
downloadbcm5719-llvm-5b51816020a0daf35f8c24ca06ddffb24d1d493e.tar.gz
bcm5719-llvm-5b51816020a0daf35f8c24ca06ddffb24d1d493e.zip
[Orc] Remove the memory manager argument to addModule, and de-templatize the
symbol resolver argument. De-templatizing the symbol resolver is part of the ongoing simplification of ORC layer API. Removing the memory management argument (and delegating construction of memory managers for RTDyldObjectLinkingLayer to a functor passed in to the constructor) allows us to build JITs whose base object layers need not be compatible with RTDyldObjectLinkingLayer's memory mangement scheme. For example, a 'remote object layer' that sends fully relocatable objects directly to the remote does not need a memory management scheme at all (that will be handled by the remote). llvm-svn: 307058
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index 7c821bc2c34..383ce8fe54c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -45,9 +45,9 @@ public:
};
TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
- class SectionMemoryManagerWrapper : public SectionMemoryManager {
+ class MemoryManagerWrapper : public SectionMemoryManager {
public:
- SectionMemoryManagerWrapper(bool &DebugSeen) : DebugSeen(DebugSeen) {}
+ MemoryManagerWrapper(bool &DebugSeen) : DebugSeen(DebugSeen) {}
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID,
StringRef SectionName,
@@ -63,7 +63,10 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
bool &DebugSeen;
};
- RTDyldObjectLinkingLayer ObjLayer;
+ bool DebugSectionSeen = false;
+ auto MM = std::make_shared<MemoryManagerWrapper>(DebugSectionSeen);
+
+ RTDyldObjectLinkingLayer ObjLayer([&MM]() { return MM; });
LLVMContext Context;
auto M = llvm::make_unique<Module>("", Context);
@@ -89,9 +92,6 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
std::make_shared<object::OwningBinary<object::ObjectFile>>(
SimpleCompiler(*TM)(*M));
- bool DebugSectionSeen = false;
- auto SMMW =
- std::make_shared<SectionMemoryManagerWrapper>(DebugSectionSeen);
auto Resolver =
createLambdaResolver(
[](const std::string &Name) {
@@ -103,7 +103,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
{
// Test with ProcessAllSections = false (the default).
- auto H = ObjLayer.addObject(Obj, SMMW, &*Resolver);
+ auto H = ObjLayer.addObject(Obj, Resolver);
ObjLayer.emitAndFinalize(H);
EXPECT_EQ(DebugSectionSeen, false)
<< "Unexpected debug info section";
@@ -113,7 +113,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
{
// Test with ProcessAllSections = true.
ObjLayer.setProcessAllSections(true);
- auto H = ObjLayer.addObject(Obj, SMMW, &*Resolver);
+ auto H = ObjLayer.addObject(Obj, Resolver);
ObjLayer.emitAndFinalize(H);
EXPECT_EQ(DebugSectionSeen, true)
<< "Expected debug info section not seen";
@@ -125,7 +125,9 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
if (!TM)
return;
- RTDyldObjectLinkingLayer ObjLayer;
+ auto MM = std::make_shared<SectionMemoryManagerWrapper>();
+
+ RTDyldObjectLinkingLayer ObjLayer([&MM]() { return MM; });
SimpleCompiler Compile(*TM);
// Create a pair of modules that will trigger recursive finalization:
@@ -179,15 +181,14 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
return JITSymbol(nullptr);
});
- auto SMMW = std::make_shared<SectionMemoryManagerWrapper>();
- ObjLayer.addObject(std::move(Obj1), SMMW, &*Resolver);
- auto H = ObjLayer.addObject(std::move(Obj2), SMMW, &*Resolver);
+ ObjLayer.addObject(std::move(Obj1), Resolver);
+ auto H = ObjLayer.addObject(std::move(Obj2), Resolver);
ObjLayer.emitAndFinalize(H);
ObjLayer.removeObject(H);
// Finalization of module 2 should trigger finalization of module 1.
// Verify that finalize on SMMW is only called once.
- EXPECT_EQ(SMMW->FinalizationCount, 1)
+ EXPECT_EQ(MM->FinalizationCount, 1)
<< "Extra call to finalize";
}
@@ -195,7 +196,9 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
if (!TM)
return;
- RTDyldObjectLinkingLayer ObjLayer;
+ auto MM = std::make_shared<SectionMemoryManagerWrapper>();
+
+ RTDyldObjectLinkingLayer ObjLayer([&MM]() { return MM; });
SimpleCompiler Compile(*TM);
// Create a pair of unrelated modules:
@@ -240,15 +243,14 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
std::make_shared<object::OwningBinary<object::ObjectFile>>(
Compile(*MB2.getModule()));
- auto SMMW = std::make_shared<SectionMemoryManagerWrapper>();
- NullResolver NR;
- auto H = ObjLayer.addObject(std::move(Obj1), SMMW, &NR);
- ObjLayer.addObject(std::move(Obj2), SMMW, &NR);
+ auto NR = std::make_shared<NullResolver>();
+ auto H = ObjLayer.addObject(std::move(Obj1), NR);
+ ObjLayer.addObject(std::move(Obj2), NR);
ObjLayer.emitAndFinalize(H);
ObjLayer.removeObject(H);
// Only one call to needsToReserveAllocationSpace should have been made.
- EXPECT_EQ(SMMW->NeedsToReserveAllocationSpaceCount, 1)
+ EXPECT_EQ(MM->NeedsToReserveAllocationSpaceCount, 1)
<< "More than one call to needsToReserveAllocationSpace "
"(multiple unrelated objects loaded prior to finalization)";
}
OpenPOWER on IntegriCloud