Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Differential D70259 Diff 230140 llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
Changeset View
Changeset View
Standalone View
Standalone View
llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | TEST(LegacyRTDyldObjectLinkingLayerTest, TestSetProcessAllSections) { | ||||
if (!TM) | if (!TM) | ||||
return; | return; | ||||
auto Obj = SimpleCompiler(*TM)(*M); | auto Obj = SimpleCompiler(*TM)(*M); | ||||
{ | { | ||||
// Test with ProcessAllSections = false (the default). | // Test with ProcessAllSections = false (the default). | ||||
auto K = ES.allocateVModule(); | auto K = ES.allocateVModule(); | ||||
cantFail(ObjLayer.addObject( | llvm_cantFail(ObjLayer.addObject( | ||||
K, MemoryBuffer::getMemBufferCopy(Obj->getBuffer()))); | K, MemoryBuffer::getMemBufferCopy(Obj->getBuffer()))); | ||||
cantFail(ObjLayer.emitAndFinalize(K)); | llvm_cantFail(ObjLayer.emitAndFinalize(K)); | ||||
EXPECT_EQ(DebugSectionSeen, false) | EXPECT_EQ(DebugSectionSeen, false) | ||||
<< "Unexpected debug info section"; | << "Unexpected debug info section"; | ||||
cantFail(ObjLayer.removeObject(K)); | llvm_cantFail(ObjLayer.removeObject(K)); | ||||
} | } | ||||
{ | { | ||||
// Test with ProcessAllSections = true. | // Test with ProcessAllSections = true. | ||||
ObjLayer.setProcessAllSections(true); | ObjLayer.setProcessAllSections(true); | ||||
auto K = ES.allocateVModule(); | auto K = ES.allocateVModule(); | ||||
cantFail(ObjLayer.addObject(K, std::move(Obj))); | llvm_cantFail(ObjLayer.addObject(K, std::move(Obj))); | ||||
cantFail(ObjLayer.emitAndFinalize(K)); | llvm_cantFail(ObjLayer.emitAndFinalize(K)); | ||||
EXPECT_EQ(DebugSectionSeen, true) | EXPECT_EQ(DebugSectionSeen, true) | ||||
<< "Expected debug info section not seen"; | << "Expected debug info section not seen"; | ||||
cantFail(ObjLayer.removeObject(K)); | llvm_cantFail(ObjLayer.removeObject(K)); | ||||
} | } | ||||
} | } | ||||
TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { | TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { | ||||
if (!SupportsJIT) | if (!SupportsJIT) | ||||
return; | return; | ||||
Type *Int32Ty = IntegerType::get(Context, 32); | Type *Int32Ty = IntegerType::get(Context, 32); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | ModuleBuilder MB2(Context, "", "dummy"); | ||||
BasicBlock *FooEntry = BasicBlock::Create(Context, "entry", FooImpl); | BasicBlock *FooEntry = BasicBlock::Create(Context, "entry", FooImpl); | ||||
IRBuilder<> Builder(FooEntry); | IRBuilder<> Builder(FooEntry); | ||||
Builder.CreateRet(Builder.CreateCall(BarDecl)); | Builder.CreateRet(Builder.CreateCall(BarDecl)); | ||||
} | } | ||||
auto Obj2 = Compile(*MB2.getModule()); | auto Obj2 = Compile(*MB2.getModule()); | ||||
auto K1 = ES.allocateVModule(); | auto K1 = ES.allocateVModule(); | ||||
Resolvers[K1] = std::make_shared<NullResolver>(); | Resolvers[K1] = std::make_shared<NullResolver>(); | ||||
cantFail(ObjLayer.addObject(K1, std::move(Obj1))); | llvm_cantFail(ObjLayer.addObject(K1, std::move(Obj1))); | ||||
auto K2 = ES.allocateVModule(); | auto K2 = ES.allocateVModule(); | ||||
auto LegacyLookup = [&](const std::string &Name) { | auto LegacyLookup = [&](const std::string &Name) { | ||||
return ObjLayer.findSymbol(Name, true); | return ObjLayer.findSymbol(Name, true); | ||||
}; | }; | ||||
Resolvers[K2] = createSymbolResolver( | Resolvers[K2] = createSymbolResolver( | ||||
[&](const SymbolNameSet &Symbols) { | [&](const SymbolNameSet &Symbols) { | ||||
return cantFail( | return llvm_cantFail( | ||||
getResponsibilitySetWithLegacyFn(Symbols, LegacyLookup)); | getResponsibilitySetWithLegacyFn(Symbols, LegacyLookup)); | ||||
}, | }, | ||||
[&](std::shared_ptr<AsynchronousSymbolQuery> Query, | [&](std::shared_ptr<AsynchronousSymbolQuery> Query, | ||||
const SymbolNameSet &Symbols) { | const SymbolNameSet &Symbols) { | ||||
return lookupWithLegacyFn(ES, *Query, Symbols, LegacyLookup); | return lookupWithLegacyFn(ES, *Query, Symbols, LegacyLookup); | ||||
}); | }); | ||||
cantFail(ObjLayer.addObject(K2, std::move(Obj2))); | llvm_cantFail(ObjLayer.addObject(K2, std::move(Obj2))); | ||||
cantFail(ObjLayer.emitAndFinalize(K2)); | llvm_cantFail(ObjLayer.emitAndFinalize(K2)); | ||||
cantFail(ObjLayer.removeObject(K2)); | llvm_cantFail(ObjLayer.removeObject(K2)); | ||||
// Finalization of module 2 should trigger finalization of module 1. | // Finalization of module 2 should trigger finalization of module 1. | ||||
// Verify that finalize on SMMW is only called once. | // Verify that finalize on SMMW is only called once. | ||||
EXPECT_EQ(MM->FinalizationCount, 1) | EXPECT_EQ(MM->FinalizationCount, 1) | ||||
<< "Extra call to finalize"; | << "Extra call to finalize"; | ||||
} | } | ||||
TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) { | TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) { | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | ModuleBuilder MB2(Context, "", "dummy"); | ||||
IRBuilder<> Builder(BarEntry); | IRBuilder<> Builder(BarEntry); | ||||
IntegerType *Int32Ty = IntegerType::get(Context, 32); | IntegerType *Int32Ty = IntegerType::get(Context, 32); | ||||
Value *Seven = ConstantInt::getSigned(Int32Ty, 7); | Value *Seven = ConstantInt::getSigned(Int32Ty, 7); | ||||
Builder.CreateRet(Seven); | Builder.CreateRet(Seven); | ||||
} | } | ||||
auto Obj2 = Compile(*MB2.getModule()); | auto Obj2 = Compile(*MB2.getModule()); | ||||
auto K = ES.allocateVModule(); | auto K = ES.allocateVModule(); | ||||
cantFail(ObjLayer.addObject(K, std::move(Obj1))); | llvm_cantFail(ObjLayer.addObject(K, std::move(Obj1))); | ||||
cantFail(ObjLayer.addObject(ES.allocateVModule(), std::move(Obj2))); | llvm_cantFail(ObjLayer.addObject(ES.allocateVModule(), std::move(Obj2))); | ||||
cantFail(ObjLayer.emitAndFinalize(K)); | llvm_cantFail(ObjLayer.emitAndFinalize(K)); | ||||
cantFail(ObjLayer.removeObject(K)); | llvm_cantFail(ObjLayer.removeObject(K)); | ||||
// Only one call to needsToReserveAllocationSpace should have been made. | // Only one call to needsToReserveAllocationSpace should have been made. | ||||
EXPECT_EQ(MM->NeedsToReserveAllocationSpaceCount, 1) | EXPECT_EQ(MM->NeedsToReserveAllocationSpaceCount, 1) | ||||
<< "More than one call to needsToReserveAllocationSpace " | << "More than one call to needsToReserveAllocationSpace " | ||||
"(multiple unrelated objects loaded prior to finalization)"; | "(multiple unrelated objects loaded prior to finalization)"; | ||||
} | } | ||||
TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) { | TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) { | ||||
Show All 12 Lines |