@@ -40,49 +40,9 @@ namespace swift {
40
40
// / In addition of caller information this analysis also provides information
41
41
// / about partial applies of a function.
42
42
class CallerAnalysis : public SILAnalysis {
43
-
44
43
public:
44
+ class FunctionInfo ;
45
45
46
- // / NOTE: this can be extended to contain the callsites of the function.
47
- class FunctionInfo {
48
- friend class CallerAnalysis ;
49
-
50
- // / A list of all the functions this function calls or partially applies.
51
- llvm::SetVector<SILFunction *> Callees;
52
- // / A list of all the callers this function has.
53
- llvm::SmallSet<SILFunction *, 4 > Callers;
54
-
55
- // / The number of partial applied arguments of this function.
56
- // /
57
- // / Specifically, it stores the minimum number of partial applied arguments
58
- // / of each function which contain one or multiple partial_applys of this
59
- // / function.
60
- // / This is a little bit off-topic because a partial_apply is not really
61
- // / a "call" of this function.
62
- llvm::DenseMap<SILFunction *, int > PartialAppliers;
63
-
64
- public:
65
- // / Returns true if this function has at least one caller.
66
- bool hasCaller () const {
67
- return !Callers.empty ();
68
- }
69
-
70
- // / Returns non zero if this function is partially applied anywhere.
71
- // /
72
- // / The return value is the minimum number of partially applied arguments.
73
- // / Usually all partial applies of a function partially apply the same
74
- // / number of arguments anyway.
75
- int getMinPartialAppliedArgs () const {
76
- int minArgs = 0 ;
77
- for (auto Iter : PartialAppliers) {
78
- int numArgs = Iter.second ;
79
- if (minArgs == 0 || numArgs < minArgs)
80
- minArgs = numArgs;
81
- }
82
- return minArgs;
83
- }
84
- };
85
-
86
46
private:
87
47
// / Current module we are analyzing.
88
48
SILModule &Mod;
@@ -167,6 +127,44 @@ class CallerAnalysis : public SILAnalysis {
167
127
}
168
128
};
169
129
130
+ // / NOTE: this can be extended to contain the callsites of the function.
131
+ class CallerAnalysis ::FunctionInfo {
132
+ friend class CallerAnalysis ;
133
+
134
+ // / A list of all the functions this function calls or partially applies.
135
+ llvm::SetVector<SILFunction *> Callees;
136
+ // / A list of all the callers this function has.
137
+ llvm::SmallSet<SILFunction *, 4 > Callers;
138
+
139
+ // / The number of partial applied arguments of this function.
140
+ // /
141
+ // / Specifically, it stores the minimum number of partial applied arguments
142
+ // / of each function which contain one or multiple partial_applys of this
143
+ // / function.
144
+ // / This is a little bit off-topic because a partial_apply is not really
145
+ // / a "call" of this function.
146
+ llvm::DenseMap<SILFunction *, int > PartialAppliers;
147
+
148
+ public:
149
+ // / Returns true if this function has at least one caller.
150
+ bool hasCaller () const { return !Callers.empty (); }
151
+
152
+ // / Returns non zero if this function is partially applied anywhere.
153
+ // /
154
+ // / The return value is the minimum number of partially applied arguments.
155
+ // / Usually all partial applies of a function partially apply the same
156
+ // / number of arguments anyway.
157
+ int getMinPartialAppliedArgs () const {
158
+ int minArgs = 0 ;
159
+ for (auto Iter : PartialAppliers) {
160
+ int numArgs = Iter.second ;
161
+ if (minArgs == 0 || numArgs < minArgs)
162
+ minArgs = numArgs;
163
+ }
164
+ return minArgs;
165
+ }
166
+ };
167
+
170
168
} // end namespace swift
171
169
172
170
#endif
0 commit comments