Lines Matching +full:partition +full:-

1 //===----- CompileOnDemandLayer.cpp - Lazily emit IR on first call --------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
41 assert(Aliasee->hasName() && "Anonymous aliasee"); in extractSubModule()
48 F->setName(AliasName); in extractSubModule()
54 G->setName(AliasName); in extractSubModule()
122 void CompileOnDemandLayer::setPartitionFunction(PartitionFunction Partition) { in setPartitionFunction() argument
123 this->Partition = std::move(Partition); in setPartitionFunction()
127 this->AliaseeImpls = Imp; in setImplMap()
135 // Sort the callables and non-callables, build re-exports and lodge the in emit()
137 auto &PDR = getPerDylibResources(R->getTargetJITDylib()); in emit()
146 for (auto &KV : R->getSymbols()) { in emit()
161 R->failMaterialization(); in emit()
167 R->replace(reexports(PDR.getImplDylib(), std::move(NonCallables), in emit()
170 R->failMaterialization(); in emit()
174 if (auto Err = R->replace( in emit()
178 R->failMaterialization(); in emit()
201 "non-exported symbol"); in getPerDylibResources()
211 return I->second; in getPerDylibResources()
227 void CompileOnDemandLayer::expandPartition(GlobalValueSet &Partition) { in expandPartition() argument
228 // Expands the partition to ensure the following rules hold: in expandPartition()
229 // (1) If any alias is in the partition, its aliasee is also in the partition. in expandPartition()
230 // (2) If any aliasee is in the partition, its aliases are also in the in expandPartition()
232 // (3) If any global variable is in the partition then all global variables in expandPartition()
233 // are in the partition. in expandPartition()
234 assert(!Partition.empty() && "Unexpected empty partition"); in expandPartition()
236 const Module &M = *(*Partition.begin())->getParent(); in expandPartition()
240 for (const auto *GV : Partition) in expandPartition()
243 cast<GlobalValue>(cast<GlobalAlias>(GV)->getAliasee())); in expandPartition()
248 if (Partition.count(cast<GlobalValue>(A.getAliasee()))) in expandPartition()
256 Partition.insert(GV); in expandPartition()
263 // FIXME: Need a 'notify lazy-extracting/emitting' callback to tie the in emitPartition()
270 for (auto &Name : R->getRequestedSymbols()) { in emitPartition()
271 if (Name == R->getInitializerSymbol()) in emitPartition()
282 /// Perform partitioning with the context lock held, since the partition in emitPartition()
283 /// function is allowed to access the globals to compute the partition. in emitPartition()
285 TSM.withModuleDo([&](Module &M) { return Partition(RequestedGVs); }); in emitPartition()
287 // Take a 'None' partition to mean the whole module (as opposed to an empty in emitPartition()
288 // partition, which means "materialize nothing"). Emit the whole module in emitPartition()
296 // If the partition is empty, return the whole module to the symbol table. in emitPartition()
297 if (GVsToExtract->empty()) { in emitPartition()
299 R->replace(std::make_unique<PartitioningIRMaterializationUnit>( in emitPartition()
301 MaterializationUnit::Interface(R->getSymbols(), in emitPartition()
302 R->getInitializerSymbol()), in emitPartition()
305 R->failMaterialization(); in emitPartition()
311 // Ok -- we actually need to partition the symbols. Promote the symbol in emitPartition()
312 // linkages/names, expand the partition to include any required symbols in emitPartition()
313 // (i.e. symbols that can't be separated from our partition), and in emitPartition()
314 // then extract the partition. in emitPartition()
319 TSM.withModuleDo([&](Module &M) -> Expected<ThreadSafeModule> { in emitPartition()
328 if (auto Err = R->defineMaterializing(SymbolFlags)) in emitPartition()
338 HashGVs.reserve(GVsToExtract->size()); in emitPartition()
342 return LHS->getName() < RHS->getName(); in emitPartition()
346 assert(GV->hasName() && "All GVs to extract should be named by now"); in emitPartition()
347 auto GVName = GV->getName(); in emitPartition()
359 auto ShouldExtract = [&](const GlobalValue &GV) -> bool { in emitPartition()
360 return GVsToExtract->count(&GV); in emitPartition()
368 R->failMaterialization(); in emitPartition()
372 if (auto Err = R->replace(std::make_unique<PartitioningIRMaterializationUnit>( in emitPartition()
375 R->failMaterialization(); in emitPartition()