mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
[ORC] Rename MaterializationResponsibility::delegate to replace and add a new
delegate method (and unit test). The name 'replace' better captures what the old delegate method did: it returned materialization responsibility for a set of symbols to the VSO. The new delegate method delegates responsibility for a set of symbols to a new MaterializationResponsibility instance. This can be used to split responsibility between multiple threads, or multiple materialization methods. llvm-svn: 336603
This commit is contained in:
parent
5059eb5048
commit
d22df6ec79
@ -149,7 +149,12 @@ public:
|
||||
/// materializers to break up work based on run-time information (e.g.
|
||||
/// by introspecting which symbols have actually been looked up and
|
||||
/// materializing only those).
|
||||
void delegate(std::unique_ptr<MaterializationUnit> MU);
|
||||
void replace(std::unique_ptr<MaterializationUnit> MU);
|
||||
|
||||
/// Delegates responsibility for the given symbols to the returned
|
||||
/// materialization responsibility. Useful for breaking up work between
|
||||
/// threads, or different kinds of materialization processes.
|
||||
MaterializationResponsibility delegate(const SymbolNameSet &Symbols);
|
||||
|
||||
/// Add dependencies for the symbols in this dylib.
|
||||
void addDependencies(const SymbolDependenceMap &Dependencies);
|
||||
|
@ -68,7 +68,7 @@ static void extractAliases(MaterializationResponsibility &R, Module &M,
|
||||
}
|
||||
}
|
||||
|
||||
R.delegate(symbolAliases(std::move(Aliases)));
|
||||
R.replace(symbolAliases(std::move(Aliases)));
|
||||
}
|
||||
|
||||
static std::unique_ptr<Module>
|
||||
@ -199,7 +199,7 @@ private:
|
||||
DelegatedSymbolToDefinition.size() &&
|
||||
"SymbolFlags and SymbolToDefinition should have the same number "
|
||||
"of entries");
|
||||
R.delegate(llvm::make_unique<ExtractingIRMaterializationUnit>(
|
||||
R.replace(llvm::make_unique<ExtractingIRMaterializationUnit>(
|
||||
std::move(M), std::move(DelegatedSymbolFlags),
|
||||
std::move(DelegatedSymbolToDefinition), Parent, BackingResolver));
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void MaterializationResponsibility::failMaterialization() {
|
||||
SymbolFlags.clear();
|
||||
}
|
||||
|
||||
void MaterializationResponsibility::delegate(
|
||||
void MaterializationResponsibility::replace(
|
||||
std::unique_ptr<MaterializationUnit> MU) {
|
||||
for (auto &KV : MU->getSymbols())
|
||||
SymbolFlags.erase(KV.first);
|
||||
@ -317,6 +317,23 @@ void MaterializationResponsibility::delegate(
|
||||
V.replace(std::move(MU));
|
||||
}
|
||||
|
||||
MaterializationResponsibility
|
||||
MaterializationResponsibility::delegate(const SymbolNameSet &Symbols) {
|
||||
SymbolFlagsMap DelegatedFlags;
|
||||
|
||||
for (auto &Name : Symbols) {
|
||||
auto I = SymbolFlags.find(Name);
|
||||
assert(I != SymbolFlags.end() &&
|
||||
"Symbol is not tracked by this MaterializationResponsibility "
|
||||
"instance");
|
||||
|
||||
DelegatedFlags[Name] = std::move(I->second);
|
||||
SymbolFlags.erase(I);
|
||||
}
|
||||
|
||||
return MaterializationResponsibility(V, std::move(DelegatedFlags));
|
||||
}
|
||||
|
||||
void MaterializationResponsibility::addDependencies(
|
||||
const SymbolDependenceMap &Dependencies) {
|
||||
V.addDependencies(SymbolFlags, Dependencies);
|
||||
|
@ -834,7 +834,7 @@ TEST(CoreAPIsTest, TestLookupWithThreadedMaterialization) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(CoreAPIsTest, TestGetRequestedSymbolsAndDelegate) {
|
||||
TEST(CoreAPIsTest, TestGetRequestedSymbolsAndReplace) {
|
||||
ExecutionSession ES;
|
||||
auto Foo = ES.getSymbolStringPool().intern("foo");
|
||||
auto Bar = ES.getSymbolStringPool().intern("bar");
|
||||
@ -862,7 +862,7 @@ TEST(CoreAPIsTest, TestGetRequestedSymbolsAndDelegate) {
|
||||
BarMaterialized = true;
|
||||
});
|
||||
|
||||
R.delegate(std::move(NewMU));
|
||||
R.replace(std::move(NewMU));
|
||||
|
||||
R.resolve(SymbolMap({{Foo, FooSym}}));
|
||||
R.finalize();
|
||||
@ -890,6 +890,40 @@ TEST(CoreAPIsTest, TestGetRequestedSymbolsAndDelegate) {
|
||||
EXPECT_TRUE(BarMaterialized) << "Bar should be materialized now";
|
||||
}
|
||||
|
||||
TEST(CoreAPIsTest, TestMaterializationResponsibilityDelegation) {
|
||||
ExecutionSession ES;
|
||||
|
||||
auto Foo = ES.getSymbolStringPool().intern("Foo");
|
||||
auto Bar = ES.getSymbolStringPool().intern("Bar");
|
||||
|
||||
JITEvaluatedSymbol FooSym(0xdeadbeef, JITSymbolFlags::Exported);
|
||||
JITEvaluatedSymbol BarSym(0xcafef00d, JITSymbolFlags::Exported);
|
||||
|
||||
auto MU = llvm::make_unique<SimpleMaterializationUnit>(
|
||||
SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
|
||||
[&](MaterializationResponsibility R) {
|
||||
auto R2 = R.delegate({Bar});
|
||||
|
||||
R.resolve({{Foo, FooSym}});
|
||||
R.finalize();
|
||||
R2.resolve({{Bar, BarSym}});
|
||||
R2.finalize();
|
||||
});
|
||||
|
||||
auto &V = ES.createVSO("V");
|
||||
cantFail(V.define(MU));
|
||||
|
||||
auto Result = lookup({&V}, {Foo, Bar});
|
||||
|
||||
EXPECT_TRUE(!!Result) << "Result should be a success value";
|
||||
EXPECT_EQ(Result->count(Foo), 1U) << "\"Foo\" entry missing";
|
||||
EXPECT_EQ(Result->count(Bar), 1U) << "\"Bar\" entry missing";
|
||||
EXPECT_EQ((*Result)[Foo].getAddress(), FooSym.getAddress())
|
||||
<< "Address mismatch for \"Foo\"";
|
||||
EXPECT_EQ((*Result)[Bar].getAddress(), BarSym.getAddress())
|
||||
<< "Address mismatch for \"Bar\"";
|
||||
}
|
||||
|
||||
TEST(CoreAPIsTest, TestMaterializeWeakSymbol) {
|
||||
// Confirm that once a weak definition is selected for materialization it is
|
||||
// treated as strong.
|
||||
|
Loading…
Reference in New Issue
Block a user