summaryrefslogtreecommitdiff
path: root/unittests/ExecutionEngine
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ExecutionEngine')
-rw-r--r--unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp8
-rw-r--r--unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp177
-rw-r--r--unittests/ExecutionEngine/Orc/OrcCAPITest.cpp13
-rw-r--r--unittests/ExecutionEngine/Orc/OrcTestCommon.h48
-rw-r--r--unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp56
5 files changed, 148 insertions, 154 deletions
diff --git a/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp b/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
index 213c460aa676e..f65dc0cd609dc 100644
--- a/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
+++ b/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
@@ -14,9 +14,9 @@
namespace {
struct MockBaseLayer {
- typedef int ModuleSetHandleT;
- ModuleSetHandleT addModuleSet(
- std::list<std::unique_ptr<llvm::Module>>,
+ typedef int ModuleHandleT;
+ ModuleHandleT addModule(
+ std::shared_ptr<llvm::Module>,
std::unique_ptr<llvm::RuntimeDyld::MemoryManager> MemMgr,
std::unique_ptr<llvm::JITSymbolResolver> Resolver) {
EXPECT_FALSE(MemMgr);
@@ -27,7 +27,7 @@ struct MockBaseLayer {
TEST(LazyEmittingLayerTest, Empty) {
MockBaseLayer M;
llvm::orc::LazyEmittingLayer<MockBaseLayer> L(M);
- L.addModuleSet(std::list<std::unique_ptr<llvm::Module>>(), nullptr, nullptr);
+ L.addModule(std::unique_ptr<llvm::Module>(), nullptr, nullptr);
}
}
diff --git a/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp b/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
index 68db454637c5b..2fdf9e8b7379b 100644
--- a/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
+++ b/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
@@ -31,14 +31,14 @@ typedef int MockSymbolResolver;
typedef int MockObjectFile;
// stand-in for llvm::MemoryBuffer set
-typedef int MockMemoryBufferSet;
+typedef int MockMemoryBuffer;
// Mock transform that operates on unique pointers to object files, and
// allocates new object files rather than mutating the given ones.
struct AllocatingTransform {
- std::unique_ptr<MockObjectFile>
- operator()(std::unique_ptr<MockObjectFile> Obj) const {
- return llvm::make_unique<MockObjectFile>(*Obj + 1);
+ std::shared_ptr<MockObjectFile>
+ operator()(std::shared_ptr<MockObjectFile> Obj) const {
+ return std::make_shared<MockObjectFile>(*Obj + 1);
}
};
@@ -50,48 +50,41 @@ struct AllocatingTransform {
// transform layer called the base layer and forwarded any return value.
class MockBaseLayer {
public:
- typedef int ObjSetHandleT;
+ typedef int ObjHandleT;
MockBaseLayer() : MockSymbol(nullptr) { resetExpectations(); }
- template <typename ObjSetT, typename MemoryManagerPtrT,
+ template <typename ObjPtrT, typename MemoryManagerPtrT,
typename SymbolResolverPtrT>
- ObjSetHandleT addObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
+ ObjHandleT addObject(ObjPtrT Obj, MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
EXPECT_EQ(MockManager, *MemMgr) << "MM should pass through";
EXPECT_EQ(MockResolver, *Resolver) << "Resolver should pass through";
- size_t I = 0;
- for (auto &ObjPtr : Objects) {
- EXPECT_EQ(MockObjects[I] + 1, *ObjPtr) << "Transform should be applied";
- I++;
- }
- EXPECT_EQ(MockObjects.size(), I) << "Number of objects should match";
- LastCalled = "addObjectSet";
- MockObjSetHandle = 111;
- return MockObjSetHandle;
+ EXPECT_EQ(MockObject + 1, *Obj) << "Transform should be applied";
+ LastCalled = "addObject";
+ MockObjHandle = 111;
+ return MockObjHandle;
}
- template <typename ObjSetT>
- void expectAddObjectSet(ObjSetT &Objects, MockMemoryManager *MemMgr,
- MockSymbolResolver *Resolver) {
+ template <typename ObjPtrT>
+ void expectAddObject(ObjPtrT Obj, MockMemoryManager *MemMgr,
+ MockSymbolResolver *Resolver) {
MockManager = *MemMgr;
MockResolver = *Resolver;
- for (auto &ObjPtr : Objects) {
- MockObjects.push_back(*ObjPtr);
- }
+ MockObject = *Obj;
}
- void verifyAddObjectSet(ObjSetHandleT Returned) {
- EXPECT_EQ("addObjectSet", LastCalled);
- EXPECT_EQ(MockObjSetHandle, Returned) << "Return should pass through";
+ void verifyAddObject(ObjHandleT Returned) {
+ EXPECT_EQ("addObject", LastCalled);
+ EXPECT_EQ(MockObjHandle, Returned) << "Return should pass through";
resetExpectations();
}
- void removeObjectSet(ObjSetHandleT H) {
- EXPECT_EQ(MockObjSetHandle, H);
- LastCalled = "removeObjectSet";
+ void removeObject(ObjHandleT H) {
+ EXPECT_EQ(MockObjHandle, H);
+ LastCalled = "removeObject";
}
- void expectRemoveObjectSet(ObjSetHandleT H) { MockObjSetHandle = H; }
- void verifyRemoveObjectSet() {
- EXPECT_EQ("removeObjectSet", LastCalled);
+ void expectRemoveObject(ObjHandleT H) { MockObjHandle = H; }
+ void verifyRemoveObject() {
+ EXPECT_EQ("removeObject", LastCalled);
resetExpectations();
}
@@ -114,18 +107,18 @@ public:
resetExpectations();
}
- llvm::JITSymbol findSymbolIn(ObjSetHandleT H, const std::string &Name,
+ llvm::JITSymbol findSymbolIn(ObjHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
- EXPECT_EQ(MockObjSetHandle, H) << "Handle should pass through";
+ EXPECT_EQ(MockObjHandle, H) << "Handle should pass through";
EXPECT_EQ(MockName, Name) << "Name should pass through";
EXPECT_EQ(MockBool, ExportedSymbolsOnly) << "Flag should pass through";
LastCalled = "findSymbolIn";
MockSymbol = llvm::JITSymbol(122, llvm::JITSymbolFlags::None);
return MockSymbol;
}
- void expectFindSymbolIn(ObjSetHandleT H, const std::string &Name,
+ void expectFindSymbolIn(ObjHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
- MockObjSetHandle = H;
+ MockObjHandle = H;
MockName = Name;
MockBool = ExportedSymbolsOnly;
}
@@ -136,26 +129,26 @@ public:
resetExpectations();
}
- void emitAndFinalize(ObjSetHandleT H) {
- EXPECT_EQ(MockObjSetHandle, H) << "Handle should pass through";
+ void emitAndFinalize(ObjHandleT H) {
+ EXPECT_EQ(MockObjHandle, H) << "Handle should pass through";
LastCalled = "emitAndFinalize";
}
- void expectEmitAndFinalize(ObjSetHandleT H) { MockObjSetHandle = H; }
+ void expectEmitAndFinalize(ObjHandleT H) { MockObjHandle = H; }
void verifyEmitAndFinalize() {
EXPECT_EQ("emitAndFinalize", LastCalled);
resetExpectations();
}
- void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
+ void mapSectionAddress(ObjHandleT H, const void *LocalAddress,
llvm::JITTargetAddress TargetAddr) {
- EXPECT_EQ(MockObjSetHandle, H);
+ EXPECT_EQ(MockObjHandle, H);
EXPECT_EQ(MockLocalAddress, LocalAddress);
EXPECT_EQ(MockTargetAddress, TargetAddr);
LastCalled = "mapSectionAddress";
}
- void expectMapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
+ void expectMapSectionAddress(ObjHandleT H, const void *LocalAddress,
llvm::JITTargetAddress TargetAddr) {
- MockObjSetHandle = H;
+ MockObjHandle = H;
MockLocalAddress = LocalAddress;
MockTargetAddress = TargetAddr;
}
@@ -169,27 +162,27 @@ private:
std::string LastCalled;
MockMemoryManager MockManager;
MockSymbolResolver MockResolver;
- std::vector<MockObjectFile> MockObjects;
- ObjSetHandleT MockObjSetHandle;
+ MockObjectFile MockObject;
+ ObjHandleT MockObjHandle;
std::string MockName;
bool MockBool;
llvm::JITSymbol MockSymbol;
const void *MockLocalAddress;
llvm::JITTargetAddress MockTargetAddress;
- MockMemoryBufferSet MockBufferSet;
+ MockMemoryBuffer MockBuffer;
// Clear remembered parameters between calls
void resetExpectations() {
LastCalled = "nothing";
MockManager = 0;
MockResolver = 0;
- MockObjects.clear();
- MockObjSetHandle = 0;
+ MockObject = 0;
+ MockObjHandle = 0;
MockName = "bogus";
MockSymbol = llvm::JITSymbol(nullptr);
MockLocalAddress = nullptr;
MockTargetAddress = 0;
- MockBufferSet = 0;
+ MockBuffer = 0;
}
};
@@ -204,43 +197,36 @@ TEST(ObjectTransformLayerTest, Main) {
// Create a second object transform layer using a transform (as a lambda)
// that mutates objects in place, and deals in naked pointers
ObjectTransformLayer<MockBaseLayer,
- std::function<MockObjectFile *(MockObjectFile *)>>
- T2(M, [](MockObjectFile *Obj) {
+ std::function<std::shared_ptr<MockObjectFile>(
+ std::shared_ptr<MockObjectFile>)>>
+ T2(M, [](std::shared_ptr<MockObjectFile> Obj) {
++(*Obj);
return Obj;
});
// Instantiate some mock objects to use below
- MockObjectFile MockObject1 = 211;
- MockObjectFile MockObject2 = 222;
MockMemoryManager MockManager = 233;
MockSymbolResolver MockResolver = 244;
- // Test addObjectSet with T1 (allocating, unique pointers)
- std::vector<std::unique_ptr<MockObjectFile>> Objs1;
- Objs1.push_back(llvm::make_unique<MockObjectFile>(MockObject1));
- Objs1.push_back(llvm::make_unique<MockObjectFile>(MockObject2));
+ // Test addObject with T1 (allocating)
+ auto Obj1 = std::make_shared<MockObjectFile>(211);
auto MM = llvm::make_unique<MockMemoryManager>(MockManager);
auto SR = llvm::make_unique<MockSymbolResolver>(MockResolver);
- M.expectAddObjectSet(Objs1, MM.get(), SR.get());
- auto H = T1.addObjectSet(std::move(Objs1), std::move(MM), std::move(SR));
- M.verifyAddObjectSet(H);
-
- // Test addObjectSet with T2 (mutating, naked pointers)
- llvm::SmallVector<MockObjectFile *, 2> Objs2Vec;
- Objs2Vec.push_back(&MockObject1);
- Objs2Vec.push_back(&MockObject2);
- llvm::MutableArrayRef<MockObjectFile *> Objs2(Objs2Vec);
- M.expectAddObjectSet(Objs2, &MockManager, &MockResolver);
- H = T2.addObjectSet(Objs2, &MockManager, &MockResolver);
- M.verifyAddObjectSet(H);
- EXPECT_EQ(212, MockObject1) << "Expected mutation";
- EXPECT_EQ(223, MockObject2) << "Expected mutation";
+ M.expectAddObject(Obj1, MM.get(), SR.get());
+ auto H = T1.addObject(std::move(Obj1), std::move(MM), std::move(SR));
+ M.verifyAddObject(H);
+
+ // Test addObjectSet with T2 (mutating)
+ auto Obj2 = std::make_shared<MockObjectFile>(222);
+ M.expectAddObject(Obj2, &MockManager, &MockResolver);
+ H = T2.addObject(Obj2, &MockManager, &MockResolver);
+ M.verifyAddObject(H);
+ EXPECT_EQ(223, *Obj2) << "Expected mutation";
// Test removeObjectSet
- M.expectRemoveObjectSet(H);
- T1.removeObjectSet(H);
- M.verifyRemoveObjectSet();
+ M.expectRemoveObject(H);
+ T1.removeObject(H);
+ M.verifyRemoveObject();
// Test findSymbol
std::string Name = "foo";
@@ -269,13 +255,13 @@ TEST(ObjectTransformLayerTest, Main) {
M.verifyMapSectionAddress();
// Verify transform getter (non-const)
- MockObjectFile Mutatee = 277;
- MockObjectFile *Out = T2.getTransform()(&Mutatee);
- EXPECT_EQ(&Mutatee, Out) << "Expected in-place transform";
- EXPECT_EQ(278, Mutatee) << "Expected incrementing transform";
+ auto Mutatee = std::make_shared<MockObjectFile>(277);
+ auto Out = T2.getTransform()(Mutatee);
+ EXPECT_EQ(*Mutatee, *Out) << "Expected in-place transform";
+ EXPECT_EQ(278, *Mutatee) << "Expected incrementing transform";
// Verify transform getter (const)
- auto OwnedObj = llvm::make_unique<MockObjectFile>(288);
+ auto OwnedObj = std::make_shared<MockObjectFile>(288);
const auto &T1C = T1;
OwnedObj = T1C.getTransform()(std::move(OwnedObj));
EXPECT_EQ(289, *OwnedObj) << "Expected incrementing transform";
@@ -287,8 +273,8 @@ TEST(ObjectTransformLayerTest, Main) {
// Make sure that ObjectTransformLayer implements the object layer concept
// correctly by sandwitching one between an ObjectLinkingLayer and an
// IRCompileLayer, verifying that it compiles if we have a call to the
- // IRComileLayer's addModuleSet that should call the transform layer's
- // addObjectSet, and also calling the other public transform layer methods
+ // IRComileLayer's addModule that should call the transform layer's
+ // addObject, and also calling the other public transform layer methods
// directly to make sure the methods they intend to forward to exist on
// the ObjectLinkingLayer.
@@ -309,31 +295,34 @@ TEST(ObjectTransformLayerTest, Main) {
};
// Construct the jit layers.
- RTDyldObjectLinkingLayer<> BaseLayer;
- auto IdentityTransform = [](
- std::unique_ptr<llvm::object::OwningBinary<llvm::object::ObjectFile>>
- Obj) { return Obj; };
+ RTDyldObjectLinkingLayer BaseLayer;
+ auto IdentityTransform =
+ [](std::shared_ptr<llvm::object::OwningBinary<llvm::object::ObjectFile>>
+ Obj) {
+ return Obj;
+ };
ObjectTransformLayer<decltype(BaseLayer), decltype(IdentityTransform)>
TransformLayer(BaseLayer, IdentityTransform);
auto NullCompiler = [](llvm::Module &) {
- return llvm::object::OwningBinary<llvm::object::ObjectFile>();
+ return llvm::object::OwningBinary<llvm::object::ObjectFile>(nullptr,
+ nullptr);
};
- IRCompileLayer<decltype(TransformLayer)> CompileLayer(TransformLayer,
- NullCompiler);
+ IRCompileLayer<decltype(TransformLayer), decltype(NullCompiler)>
+ CompileLayer(TransformLayer, NullCompiler);
// Make sure that the calls from IRCompileLayer to ObjectTransformLayer
// compile.
NullResolver Resolver;
NullManager Manager;
- CompileLayer.addModuleSet(std::vector<llvm::Module *>(), &Manager, &Resolver);
+ CompileLayer.addModule(std::shared_ptr<llvm::Module>(), &Manager, &Resolver);
// Make sure that the calls from ObjectTransformLayer to ObjectLinkingLayer
// compile.
- decltype(TransformLayer)::ObjSetHandleT ObjSet;
- TransformLayer.emitAndFinalize(ObjSet);
- TransformLayer.findSymbolIn(ObjSet, Name, false);
+ decltype(TransformLayer)::ObjHandleT H2;
+ TransformLayer.emitAndFinalize(H2);
+ TransformLayer.findSymbolIn(H2, Name, false);
TransformLayer.findSymbol(Name, true);
- TransformLayer.mapSectionAddress(ObjSet, nullptr, 0);
- TransformLayer.removeObjectSet(ObjSet);
+ TransformLayer.mapSectionAddress(H2, nullptr, 0);
+ TransformLayer.removeObject(H2);
}
}
diff --git a/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
index e8ba16a472b77..2900a9c927669 100644
--- a/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
+++ b/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
@@ -65,8 +65,9 @@ protected:
CompileContext *CCtx = static_cast<CompileContext*>(Ctx);
auto *ET = CCtx->APIExecTest;
CCtx->M = ET->createTestModule(ET->TM->getTargetTriple());
- CCtx->H = LLVMOrcAddEagerlyCompiledIR(JITStack, wrap(CCtx->M.get()),
- myResolver, nullptr);
+ LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(CCtx->M.release()));
+ CCtx->H = LLVMOrcAddEagerlyCompiledIR(JITStack, SM, myResolver, nullptr);
+ LLVMOrcDisposeSharedModuleRef(SM);
CCtx->Compiled = true;
LLVMOrcTargetAddress MainAddr = LLVMOrcGetSymbolAddress(JITStack, "main");
LLVMOrcSetIndirectStubPointer(JITStack, "foo", MainAddr);
@@ -87,8 +88,10 @@ TEST_F(OrcCAPIExecutionTest, TestEagerIRCompilation) {
LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");
+ LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(M.release()));
LLVMOrcModuleHandle H =
- LLVMOrcAddEagerlyCompiledIR(JIT, wrap(M.get()), myResolver, nullptr);
+ LLVMOrcAddEagerlyCompiledIR(JIT, SM, myResolver, nullptr);
+ LLVMOrcDisposeSharedModuleRef(SM);
MainFnTy MainFn = (MainFnTy)LLVMOrcGetSymbolAddress(JIT, "main");
int Result = MainFn();
EXPECT_EQ(Result, 42)
@@ -111,8 +114,10 @@ TEST_F(OrcCAPIExecutionTest, TestLazyIRCompilation) {
LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");
+ LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(M.release()));
LLVMOrcModuleHandle H =
- LLVMOrcAddLazilyCompiledIR(JIT, wrap(M.get()), myResolver, nullptr);
+ LLVMOrcAddLazilyCompiledIR(JIT, SM, myResolver, nullptr);
+ LLVMOrcDisposeSharedModuleRef(SM);
MainFnTy MainFn = (MainFnTy)LLVMOrcGetSymbolAddress(JIT, "main");
int Result = MainFn();
EXPECT_EQ(Result, 42)
diff --git a/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index 24320034a17a9..d7049ef00e6d1 100644
--- a/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -106,65 +106,65 @@ public:
};
template <typename HandleT,
- typename AddModuleSetFtor,
- typename RemoveModuleSetFtor,
+ typename AddModuleFtor,
+ typename RemoveModuleFtor,
typename FindSymbolFtor,
typename FindSymbolInFtor>
class MockBaseLayer {
public:
- typedef HandleT ModuleSetHandleT;
+ typedef HandleT ModuleHandleT;
- MockBaseLayer(AddModuleSetFtor &&AddModuleSet,
- RemoveModuleSetFtor &&RemoveModuleSet,
+ MockBaseLayer(AddModuleFtor &&AddModule,
+ RemoveModuleFtor &&RemoveModule,
FindSymbolFtor &&FindSymbol,
FindSymbolInFtor &&FindSymbolIn)
- : AddModuleSet(AddModuleSet), RemoveModuleSet(RemoveModuleSet),
+ : AddModule(AddModule), RemoveModule(RemoveModule),
FindSymbol(FindSymbol), FindSymbolIn(FindSymbolIn)
{}
- template <typename ModuleSetT, typename MemoryManagerPtrT,
+ template <typename ModuleT, typename MemoryManagerPtrT,
typename SymbolResolverPtrT>
- ModuleSetHandleT addModuleSet(ModuleSetT Ms, MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
- return AddModuleSet(std::move(Ms), std::move(MemMgr), std::move(Resolver));
+ ModuleHandleT addModule(ModuleT Ms, MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
+ return AddModule(std::move(Ms), std::move(MemMgr), std::move(Resolver));
}
- void removeModuleSet(ModuleSetHandleT H) {
- RemoveModuleSet(H);
+ void removeModule(ModuleHandleT H) {
+ RemoveModule(H);
}
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
return FindSymbol(Name, ExportedSymbolsOnly);
}
- JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
+ JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
return FindSymbolIn(H, Name, ExportedSymbolsOnly);
}
private:
- AddModuleSetFtor AddModuleSet;
- RemoveModuleSetFtor RemoveModuleSet;
+ AddModuleFtor AddModule;
+ RemoveModuleFtor RemoveModule;
FindSymbolFtor FindSymbol;
FindSymbolInFtor FindSymbolIn;
};
-template <typename ModuleSetHandleT,
- typename AddModuleSetFtor,
- typename RemoveModuleSetFtor,
+template <typename ModuleHandleT,
+ typename AddModuleFtor,
+ typename RemoveModuleFtor,
typename FindSymbolFtor,
typename FindSymbolInFtor>
-MockBaseLayer<ModuleSetHandleT, AddModuleSetFtor, RemoveModuleSetFtor,
+MockBaseLayer<ModuleHandleT, AddModuleFtor, RemoveModuleFtor,
FindSymbolFtor, FindSymbolInFtor>
-createMockBaseLayer(AddModuleSetFtor &&AddModuleSet,
- RemoveModuleSetFtor &&RemoveModuleSet,
+createMockBaseLayer(AddModuleFtor &&AddModule,
+ RemoveModuleFtor &&RemoveModule,
FindSymbolFtor &&FindSymbol,
FindSymbolInFtor &&FindSymbolIn) {
- return MockBaseLayer<ModuleSetHandleT, AddModuleSetFtor, RemoveModuleSetFtor,
+ return MockBaseLayer<ModuleHandleT, AddModuleFtor, RemoveModuleFtor,
FindSymbolFtor, FindSymbolInFtor>(
- std::forward<AddModuleSetFtor>(AddModuleSet),
- std::forward<RemoveModuleSetFtor>(RemoveModuleSet),
+ std::forward<AddModuleFtor>(AddModule),
+ std::forward<RemoveModuleFtor>(RemoveModule),
std::forward<FindSymbolFtor>(FindSymbol),
std::forward<FindSymbolInFtor>(FindSymbolIn));
}
diff --git a/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index 8878451bdec2e..7c821bc2c34b3 100644
--- a/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -63,7 +63,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
bool &DebugSeen;
};
- RTDyldObjectLinkingLayer<> ObjLayer;
+ RTDyldObjectLinkingLayer ObjLayer;
LLVMContext Context;
auto M = llvm::make_unique<Module>("", Context);
@@ -85,9 +85,9 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
if (!TM)
return;
- auto OwningObj = SimpleCompiler(*TM)(*M);
- std::vector<object::ObjectFile*> Objs;
- Objs.push_back(OwningObj.getBinary());
+ auto Obj =
+ std::make_shared<object::OwningBinary<object::ObjectFile>>(
+ SimpleCompiler(*TM)(*M));
bool DebugSectionSeen = false;
auto SMMW =
@@ -103,21 +103,21 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
{
// Test with ProcessAllSections = false (the default).
- auto H = ObjLayer.addObjectSet(Objs, SMMW, &*Resolver);
+ auto H = ObjLayer.addObject(Obj, SMMW, &*Resolver);
ObjLayer.emitAndFinalize(H);
EXPECT_EQ(DebugSectionSeen, false)
<< "Unexpected debug info section";
- ObjLayer.removeObjectSet(H);
+ ObjLayer.removeObject(H);
}
{
// Test with ProcessAllSections = true.
ObjLayer.setProcessAllSections(true);
- auto H = ObjLayer.addObjectSet(Objs, SMMW, &*Resolver);
+ auto H = ObjLayer.addObject(Obj, SMMW, &*Resolver);
ObjLayer.emitAndFinalize(H);
EXPECT_EQ(DebugSectionSeen, true)
<< "Expected debug info section not seen";
- ObjLayer.removeObjectSet(H);
+ ObjLayer.removeObject(H);
}
}
@@ -125,7 +125,7 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
if (!TM)
return;
- RTDyldObjectLinkingLayer<> ObjLayer;
+ RTDyldObjectLinkingLayer ObjLayer;
SimpleCompiler Compile(*TM);
// Create a pair of modules that will trigger recursive finalization:
@@ -151,9 +151,9 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
Builder.CreateRet(FourtyTwo);
}
- auto Obj1 = Compile(*MB1.getModule());
- std::vector<object::ObjectFile*> Obj1Set;
- Obj1Set.push_back(Obj1.getBinary());
+ auto Obj1 =
+ std::make_shared<object::OwningBinary<object::ObjectFile>>(
+ Compile(*MB1.getModule()));
ModuleBuilder MB2(Context, "", "dummy");
{
@@ -164,9 +164,9 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
IRBuilder<> Builder(FooEntry);
Builder.CreateRet(Builder.CreateCall(BarDecl));
}
- auto Obj2 = Compile(*MB2.getModule());
- std::vector<object::ObjectFile*> Obj2Set;
- Obj2Set.push_back(Obj2.getBinary());
+ auto Obj2 =
+ std::make_shared<object::OwningBinary<object::ObjectFile>>(
+ Compile(*MB2.getModule()));
auto Resolver =
createLambdaResolver(
@@ -180,10 +180,10 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
});
auto SMMW = std::make_shared<SectionMemoryManagerWrapper>();
- ObjLayer.addObjectSet(std::move(Obj1Set), SMMW, &*Resolver);
- auto H = ObjLayer.addObjectSet(std::move(Obj2Set), SMMW, &*Resolver);
+ ObjLayer.addObject(std::move(Obj1), SMMW, &*Resolver);
+ auto H = ObjLayer.addObject(std::move(Obj2), SMMW, &*Resolver);
ObjLayer.emitAndFinalize(H);
- ObjLayer.removeObjectSet(H);
+ ObjLayer.removeObject(H);
// Finalization of module 2 should trigger finalization of module 1.
// Verify that finalize on SMMW is only called once.
@@ -195,7 +195,7 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
if (!TM)
return;
- RTDyldObjectLinkingLayer<> ObjLayer;
+ RTDyldObjectLinkingLayer ObjLayer;
SimpleCompiler Compile(*TM);
// Create a pair of unrelated modules:
@@ -222,9 +222,9 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
Builder.CreateRet(FourtyTwo);
}
- auto Obj1 = Compile(*MB1.getModule());
- std::vector<object::ObjectFile*> Obj1Set;
- Obj1Set.push_back(Obj1.getBinary());
+ auto Obj1 =
+ std::make_shared<object::OwningBinary<object::ObjectFile>>(
+ Compile(*MB1.getModule()));
ModuleBuilder MB2(Context, "", "dummy");
{
@@ -236,16 +236,16 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
Value *Seven = ConstantInt::getSigned(Int32Ty, 7);
Builder.CreateRet(Seven);
}
- auto Obj2 = Compile(*MB2.getModule());
- std::vector<object::ObjectFile*> Obj2Set;
- Obj2Set.push_back(Obj2.getBinary());
+ auto Obj2 =
+ std::make_shared<object::OwningBinary<object::ObjectFile>>(
+ Compile(*MB2.getModule()));
auto SMMW = std::make_shared<SectionMemoryManagerWrapper>();
NullResolver NR;
- auto H = ObjLayer.addObjectSet(std::move(Obj1Set), SMMW, &NR);
- ObjLayer.addObjectSet(std::move(Obj2Set), SMMW, &NR);
+ auto H = ObjLayer.addObject(std::move(Obj1), SMMW, &NR);
+ ObjLayer.addObject(std::move(Obj2), SMMW, &NR);
ObjLayer.emitAndFinalize(H);
- ObjLayer.removeObjectSet(H);
+ ObjLayer.removeObject(H);
// Only one call to needsToReserveAllocationSpace should have been made.
EXPECT_EQ(SMMW->NeedsToReserveAllocationSpaceCount, 1)