Skip to content

Commit 991fc1a

Browse files
committed
Add comments on how CallerAnalysis work
1 parent 50c048d commit 991fc1a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/swift/SILOptimizer/Analysis/CallerAnalysis.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ class CallerAnalysisFunctionInfo {
5151
friend class CallerAnalysis;
5252
};
5353

54+
/// CallerAnalysis relies on keeping the Caller/Callee relation up-to-date
55+
/// lazily. i.e. when a function is invalidated, instead of recomputing the
56+
/// function it calls right away, its kept in a recompute list and
57+
/// CallerAnalysis recomputes and empty the recompute list before any query.
58+
///
59+
/// We also considered the possibility of keeping a computed list, instead of
60+
/// recompute Every time we need to complete the computed list (i.e. we want
61+
/// to the computed list to contain every function in the module). We need to
62+
/// walk through every function in the module. This leads to O(n) And we need
63+
/// to run every function through the a sequence of function passes which might
64+
/// invalidate the functions and make the computed list incomplete. So
65+
/// O(n) * O(n) = O(n^2).
5466
class CallerAnalysis : public SILAnalysis {
5567

5668
/// Current module we are analyzing.

0 commit comments

Comments
 (0)