Skip to content

Commit f8143bb

Browse files
committed
Clean and document the PassManager's runFunctionPasses.
1 parent 45308f6 commit f8143bb

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

include/swift/SILPasses/PassManager.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ class SILPassManager {
154154
#define PASS(ID, NAME, DESCRIPTION) void add##ID();
155155
#include "Passes.def"
156156

157-
protected:
158-
bool runFunctionPasses(
159-
llvm::ArrayRef<SILFunctionTransform *> FuncTransforms);
157+
typedef llvm::ArrayRef<SILFunctionTransform *> PassList;
158+
private:
159+
/// Run the passes in \p FuncTransforms. Return true
160+
/// if the pass manager requested to stop the execution
161+
/// of the optimization cycle (this is a debug feature).
162+
bool runFunctionPasses(PassList FuncTransforms);
160163
};
161164

162165
} // end namespace swift

lib/SILPasses/PassManager/PassManager.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ SILPassManager::SILPassManager(SILModule *M, llvm::StringRef Stage) :
156156
}
157157
}
158158

159-
bool SILPassManager::
160-
runFunctionPasses(llvm::ArrayRef<SILFunctionTransform*> FuncTransforms) {
159+
bool SILPassManager::runFunctionPasses(PassList FuncTransforms) {
161160
const SILOptions &Options = getOptions();
162161

163162
for (auto &F : *Mod) {
@@ -227,13 +226,14 @@ runFunctionPasses(llvm::ArrayRef<SILFunctionTransform*> FuncTransforms) {
227226
}
228227

229228
++NumPassesRun;
229+
// Request that we stop this optimization phase.
230230
if (Mod->getStage() == SILStage::Canonical
231231
&& NumPassesRun >= SILNumOptPassesToRun)
232-
return false;
232+
return true;
233233
}
234234
}
235235

236-
return true;
236+
return false;
237237
}
238238

239239
void SILPassManager::runOneIteration() {
@@ -267,9 +267,11 @@ void SILPassManager::runOneIteration() {
267267

268268
// Run module transformations on the module.
269269
if (SILModuleTransform *SMT = llvm::dyn_cast<SILModuleTransform>(ST)) {
270-
// Run all function passes that we've seen since the last module pass. If
271-
// one of the passes asked us to stop the pass pipeline, return false.
272-
if (!runFunctionPasses(PendingFuncTransforms))
270+
// Run all function passes that we've seen since the last module pass.
271+
// Stop stop this optimization phase if one of the passes requested to
272+
// stop.
273+
bool NeedToStop = runFunctionPasses(PendingFuncTransforms);
274+
if (NeedToStop)
273275
return;
274276

275277
PendingFuncTransforms.clear();

0 commit comments

Comments
 (0)