Skip to content

Commit 17e6c58

Browse files
authored
Merge pull request #17741 from gottesmm/pr-3d27189510d71b29a13afc5f09196a78637eb8ac
2 parents ed7b660 + e1bb2ad commit 17e6c58

File tree

1 file changed

+39
-41
lines changed

1 file changed

+39
-41
lines changed

include/swift/SILOptimizer/Analysis/CallerAnalysis.h

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,9 @@ namespace swift {
4040
/// In addition of caller information this analysis also provides information
4141
/// about partial applies of a function.
4242
class CallerAnalysis : public SILAnalysis {
43-
4443
public:
44+
class FunctionInfo;
4545

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-
8646
private:
8747
/// Current module we are analyzing.
8848
SILModule &Mod;
@@ -167,6 +127,44 @@ class CallerAnalysis : public SILAnalysis {
167127
}
168128
};
169129

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+
170168
} // end namespace swift
171169

172170
#endif

0 commit comments

Comments
 (0)