Skip to content

Commit 4e2cffb

Browse files
committed
AliasAnalysis: speed up canApplyDecrementRefCount() for large functions.
This is a workaround for some quadratic complexity in ARCSequenceOpt which calls canApplyDecrementRefCount very frequently. rdar://problem/56268570
1 parent fd6c26e commit 4e2cffb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/SILOptimizer/Analysis/AliasAnalysis.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,16 @@ AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
661661
}
662662

663663
bool AliasAnalysis::canApplyDecrementRefCount(FullApplySite FAS, SILValue Ptr) {
664+
// If the connection graph is invalid due to a very large function, we also
665+
// skip all other tests, which might take significant time for a very large
666+
// function.
667+
// This is a workaround for some quadratic complexity in ARCSequenceOpt.
668+
// TODO: remove this check once ARCSequenceOpt is retired or the quadratic
669+
// behavior is fixed.
670+
auto *conGraph = EA->getConnectionGraph(FAS.getFunction());
671+
if (!conGraph->isValid())
672+
return true;
673+
664674
// Treat applications of no-return functions as decrementing ref counts. This
665675
// causes the apply to become a sink barrier for ref count increments.
666676
if (FAS.isCalleeNoReturn())

0 commit comments

Comments
 (0)