本文整理汇总了C++中IRGenFunction::isConditionalDominancePoint方法的典型用法代码示例。如果您正苦于以下问题:C++ IRGenFunction::isConditionalDominancePoint方法的具体用法?C++ IRGenFunction::isConditionalDominancePoint怎么用?C++ IRGenFunction::isConditionalDominancePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRGenFunction
的用法示例。
在下文中一共展示了IRGenFunction::isConditionalDominancePoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CanType
void LocalTypeDataCache::
addAbstractForFulfillments(IRGenFunction &IGF, FulfillmentMap &&fulfillments,
llvm::function_ref<AbstractSource()> createSource) {
// Add the source lazily.
Optional<unsigned> sourceIndex;
auto getSourceIndex = [&]() -> unsigned {
if (!sourceIndex) {
AbstractSources.emplace_back(createSource());
sourceIndex = AbstractSources.size() - 1;
}
return *sourceIndex;
};
for (auto &fulfillment : fulfillments) {
CanType type = CanType(fulfillment.first.first);
LocalTypeDataKind localDataKind;
// For now, ignore witness-table fulfillments when they're not for
// archetypes.
if (ProtocolDecl *protocol = fulfillment.first.second) {
if (auto archetype = dyn_cast<ArchetypeType>(type)) {
auto conformsTo = archetype->getConformsTo();
auto it = std::find(conformsTo.begin(), conformsTo.end(), protocol);
if (it == conformsTo.end()) continue;
localDataKind = LocalTypeDataKind::forAbstractProtocolWitnessTable(*it);
} else {
continue;
}
} else {
// Ignore type metadata fulfillments for non-dependent types that
// we can produce very cheaply. We don't want to end up emitting
// the type metadata for Int by chasing through N layers of metadata
// just because that path happens to be in the cache.
if (!type->hasArchetype() &&
isTypeMetadataAccessTrivial(IGF.IGM, type)) {
continue;
}
localDataKind = LocalTypeDataKind::forTypeMetadata();
}
// Find the chain for the key.
auto key = getKey(type, localDataKind);
auto &chain = Map[key];
// Check whether there's already an entry that's at least as good as the
// fulfillment.
Optional<unsigned> fulfillmentCost;
auto getFulfillmentCost = [&]() -> unsigned {
if (!fulfillmentCost)
fulfillmentCost = fulfillment.second.Path.cost();
return *fulfillmentCost;
};
bool isConditional = IGF.isConditionalDominancePoint();
bool foundBetter = false;
for (CacheEntry *cur = chain.Root, *last = nullptr; cur;
last = cur, cur = cur->getNext()) {
// Ensure the entry is acceptable.
if (!IGF.isActiveDominancePointDominatedBy(cur->DefinitionPoint))
continue;
// Ensure that the entry isn't better than the fulfillment.
auto curCost = cur->cost();
if (curCost == 0 || curCost <= getFulfillmentCost()) {
foundBetter = true;
break;
}
// If the entry is defined at the current point, (1) we know there
// won't be a better entry and (2) we should remove it.
if (cur->DefinitionPoint == IGF.getActiveDominancePoint() &&
!isConditional) {
// Splice it out of the chain.
assert(!cur->isConditional());
chain.eraseEntry(last, cur);
break;
}
}
if (foundBetter) continue;
// Okay, make a new entry.
// Register with the conditional dominance scope if necessary.
if (isConditional) {
IGF.registerConditionalLocalTypeDataKey(key);
}
// Allocate the new entry.
auto newEntry = new AbstractCacheEntry(IGF.getActiveDominancePoint(),
isConditional,
getSourceIndex(),
std::move(fulfillment.second.Path));
// Add it to the front of the chain.
chain.push_front(newEntry);
}
}