mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "Hoist more early returns as early as possible."
This reverts commit r25943. It may have broken a test that was missing a FileCheck. Swift SVN r25947
This commit is contained in:
@@ -347,25 +347,17 @@ static bool insertInlineCaches(ApplyInst *AI, ClassHierarchyAnalysis *CHA) {
|
|||||||
// actual dynamic type.
|
// actual dynamic type.
|
||||||
auto SubTypeValue = ClassInstance.stripUpCasts();
|
auto SubTypeValue = ClassInstance.stripUpCasts();
|
||||||
SILType SubType = SubTypeValue.getType();
|
SILType SubType = SubTypeValue.getType();
|
||||||
|
|
||||||
// Bail if any generic types parameters of the class instance type are
|
|
||||||
// unbound.
|
|
||||||
// We cannot devirtualize unbound generic calls yet.
|
|
||||||
if (isClassWithUnboundGenericParameters(SubType, AI->getModule()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ClassDecl *CD = SubType.getClassOrBoundGenericClass();
|
ClassDecl *CD = SubType.getClassOrBoundGenericClass();
|
||||||
|
|
||||||
// Check if it is legal to insert inline caches.
|
|
||||||
if (!CD)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (auto *VMTI = dyn_cast<ValueMetatypeInst>(SubTypeValue)) {
|
if (auto *VMTI = dyn_cast<ValueMetatypeInst>(SubTypeValue)) {
|
||||||
CanType InstTy = VMTI->getType().castTo<MetatypeType>().getInstanceType();
|
CanType InstTy = VMTI->getType().castTo<MetatypeType>().getInstanceType();
|
||||||
CD = InstTy.getClassOrBoundGenericClass();
|
CD = InstTy.getClassOrBoundGenericClass();
|
||||||
assert(CD && "Non-class type for instance type of class metatype?!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if it is legal to insert inline caches.
|
||||||
|
if (!CD)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (ClassInstance != SubTypeValue) {
|
if (ClassInstance != SubTypeValue) {
|
||||||
// The implementation of a method to be invoked may actually
|
// The implementation of a method to be invoked may actually
|
||||||
// be defined by one of the superclasses.
|
// be defined by one of the superclasses.
|
||||||
@@ -380,6 +372,12 @@ static bool insertInlineCaches(ApplyInst *AI, ClassHierarchyAnalysis *CHA) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bail if any generic types parameters of the class instance type are
|
||||||
|
// unbound.
|
||||||
|
// We cannot devirtualize unbound generic calls yet.
|
||||||
|
if (isClassWithUnboundGenericParameters(SubType, AI->getModule()))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!CHA->hasKnownDirectSubclasses(CD)) {
|
if (!CHA->hasKnownDirectSubclasses(CD)) {
|
||||||
// If there is only one possible alternative for this method,
|
// If there is only one possible alternative for this method,
|
||||||
// try to devirtualize it completely.
|
// try to devirtualize it completely.
|
||||||
|
|||||||
Reference in New Issue
Block a user