Improvement of devirtualization based on metatypes.

Swift SVN r25927
This commit is contained in:
Roman Levenstein
2015-03-10 16:19:42 +00:00
parent e29b7ca52a
commit 1b6cf90da8
2 changed files with 31 additions and 3 deletions

View File

@@ -360,8 +360,15 @@ static bool insertInlineCaches(ApplyInst *AI, ClassHierarchyAnalysis *CHA) {
if (ClassInstance.getType() != InstanceType) {
// The implementation of a method to be invoked may actually
// be defined by one of the superclasses.
if (!ClassInstance.getType().isSuperclassOf(InstanceType))
return false;
if (ClassInstance.getType().getAs<MetatypeType>()) {
auto &Module = AI->getModule();
if (!ClassInstance.getType().getMetatypeInstanceType(Module).
isSuperclassOf(InstanceType.getMetatypeInstanceType(Module)))
return false;
} else {
if (!ClassInstance.getType().isSuperclassOf(InstanceType))
return false;
}
// ClassInstance and InstanceType should match for
// devirtualizeClassMethod to work.
ClassInstance = ClassInstance.stripUpCasts();