ExistentialTransform fixes for swiftpm bugs and enable existential-specializer in sil-opt

This commit is contained in:
Raj Barik
2018-11-15 18:25:03 -08:00
parent 25c6c16064
commit c4df82baa8
4 changed files with 241 additions and 27 deletions

View File

@@ -101,7 +101,8 @@ static bool findConcreteType(ApplySite AI, int ArgIdx, CanType &ConcreteType) {
SILValue InitExistential =
findInitExistentialFromGlobalAddrAndApply(GAI, AI, ArgIdx);
/// If the Arg is already init_existential, return the concrete type.
if (findConcreteTypeFromInitExistential(InitExistential, ConcreteType)) {
if (InitExistential &&
findConcreteTypeFromInitExistential(InitExistential, ConcreteType)) {
return true;
}
}
@@ -257,6 +258,12 @@ bool ExistentialSpecializer::canSpecializeCalleeFunction(ApplySite &Apply) {
if (Callee->getInlineStrategy() == Inline_t::AlwaysInline)
return false;
/// Ignore externally linked functions with public_external or higher
/// linkage.
if (isAvailableExternally(Callee->getLinkage())) {
return false;
}
/// Only choose a select few function representations for specialization.
switch (Callee->getRepresentation()) {
case SILFunctionTypeRepresentation::ObjCMethod: