Skip to content

Commit 253c0ac

Browse files
committed
SIL: Generalize some explicit requiresClass() checks to use layout constraints
1 parent a6fbc59 commit 253c0ac

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,6 @@ namespace {
421421

422422
RetTy visitArchetypeType(CanArchetypeType type,
423423
AbstractionPattern origType) {
424-
if (type->requiresClass()) {
425-
return asImpl().handleReference(type);
426-
}
427-
428424
auto LayoutInfo = type->getLayoutConstraint();
429425
if (LayoutInfo) {
430426
if (LayoutInfo->isFixedSizeTrivial()) {

lib/SILOptimizer/Transforms/CSE.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,6 @@ bool llvm::DenseMapInfo<SimpleValue>::isEqual(SimpleValue LHS,
428428
return false;
429429

430430
// ... and other constraints are equal.
431-
if (LHSArchetypeTy->requiresClass() != RHSArchetypeTy->requiresClass())
432-
return false;
433-
434431
if (LHSArchetypeTy->getSuperclass().getPointer() !=
435432
RHSArchetypeTy->getSuperclass().getPointer())
436433
return false;

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,20 @@ static bool isCallerAndCalleeLayoutConstraintsCompatible(FullApplySite AI) {
622622
// The generic parameter has a layout constraint.
623623
// Check that the substitution has the same constraint.
624624
auto AIReplacement = Type(Param).subst(AISubs);
625-
auto AIArchetype = AIReplacement->getAs<ArchetypeType>();
626-
if (!AIArchetype)
627-
return false;
628-
auto AILayout = AIArchetype->getLayoutConstraint();
629-
if (!AILayout)
630-
return false;
631-
if (AILayout != Layout)
632-
return false;
625+
626+
if (Layout->isClass()) {
627+
if (!AIReplacement->satisfiesClassConstraint())
628+
return false;
629+
} else {
630+
auto AIArchetype = AIReplacement->getAs<ArchetypeType>();
631+
if (!AIArchetype)
632+
return false;
633+
auto AILayout = AIArchetype->getLayoutConstraint();
634+
if (!AILayout)
635+
return false;
636+
if (AILayout != Layout)
637+
return false;
638+
}
633639
}
634640
return true;
635641
}

0 commit comments

Comments
 (0)