@@ -71,12 +71,8 @@ class CallerAnalysis : public SILAnalysis {
71
71
// / A map between all the functions and their callsites in the module.
72
72
llvm::DenseMap<SILFunction *, CallerAnalysisFunctionInfo> CallInfo;
73
73
74
- // / A set of functions that needs to be recomputed. This is used to make sure
75
- // / a function is not pushed to the RecomputeFunctionList more than once.
76
- llvm::DenseSet<SILFunction *> RecomputeFunctionSet;
77
-
78
74
// / A list of functions that needs to be recomputed.
79
- llvm::SmallVector <SILFunction *, 16 > RecomputeFunctionList;
75
+ llvm::SetVector <SILFunction *> RecomputeFunctionList;
80
76
81
77
// / Iterate over all the call sites in the function and update
82
78
// / CallInfo.
@@ -91,15 +87,13 @@ class CallerAnalysis : public SILAnalysis {
91
87
processFunctionCallSites (F);
92
88
}
93
89
RecomputeFunctionList.clear ();
94
- RecomputeFunctionSet.clear ();
95
90
}
96
91
97
92
public:
98
93
CallerAnalysis (SILModule *M) : SILAnalysis(AnalysisKind::Caller), Mod(*M) {
99
94
// Make sure we compute everything first time called.
100
95
for (auto &F : Mod) {
101
- RecomputeFunctionSet.insert (&F);
102
- RecomputeFunctionList.push_back (&F);
96
+ RecomputeFunctionList.insert (&F);
103
97
}
104
98
}
105
99
@@ -108,11 +102,7 @@ class CallerAnalysis : public SILAnalysis {
108
102
}
109
103
110
104
virtual void notifyAnalysisOfFunction (SILFunction *F) {
111
- // This is not a new function.
112
- if (RecomputeFunctionSet.find (F) != RecomputeFunctionSet.end ())
113
- return ;
114
- RecomputeFunctionSet.insert (F);
115
- RecomputeFunctionList.push_back (F);
105
+ RecomputeFunctionList.insert (F);
116
106
}
117
107
118
108
virtual void invalidate (SILFunction *F, InvalidationKind K) {
@@ -124,15 +114,13 @@ class CallerAnalysis : public SILAnalysis {
124
114
// This function has become "unknown" to us. Invalidate any callsite
125
115
// information related to this function.
126
116
invalidateExistingCalleeRelation (F);
127
- if (RecomputeFunctionSet.find (F) != RecomputeFunctionSet.end ())
128
- return ;
129
117
// Make sure this function is recomputed next time.
130
- RecomputeFunctionSet.insert (F);
131
- RecomputeFunctionList.push_back (F);
118
+ RecomputeFunctionList.insert (F);
132
119
}
133
120
134
121
virtual void invalidateForDeadFunction (SILFunction *F, InvalidationKind K) {
135
122
invalidateExistingCalleeRelation (F);
123
+ RecomputeFunctionList.remove (F);
136
124
}
137
125
138
126
virtual void invalidate (InvalidationKind K) {
@@ -143,10 +131,8 @@ class CallerAnalysis : public SILAnalysis {
143
131
144
132
CallInfo.clear ();
145
133
RecomputeFunctionList.clear ();
146
- RecomputeFunctionSet.clear ();
147
134
for (auto &F : Mod) {
148
- RecomputeFunctionSet.insert (&F);
149
- RecomputeFunctionList.push_back (&F);
135
+ RecomputeFunctionList.insert (&F);
150
136
}
151
137
}
152
138
0 commit comments