Skip to content

Commit c929cec

Browse files
committed
Revert "[PassManager] Process the function in a bottom-up order."
This reverts commit da70b97 as it looks like this broke the array_mutable_assertonly.swift test in some configurations.
1 parent 8869548 commit c929cec

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

lib/SILPasses/PassManager/PassManager.cpp

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "swift/SILPasses/Transforms.h"
2020
#include "llvm/ADT/Statistic.h"
2121
#include "llvm/ADT/StringSwitch.h"
22-
#include "swift/SILAnalysis/FunctionOrder.h"
2322
#include "llvm/Support/CommandLine.h"
2423
#include "llvm/Support/Debug.h"
2524
#include "llvm/Support/TimeValue.h"
@@ -160,30 +159,20 @@ SILPassManager::SILPassManager(SILModule *M, llvm::StringRef Stage) :
160159
bool SILPassManager::runFunctionPasses(PassList FuncTransforms) {
161160
const SILOptions &Options = getOptions();
162161

163-
BasicCalleeAnalysis *BCA = getAnalysis<BasicCalleeAnalysis>();
164-
BottomUpFunctionOrder BottomUpOrder(*Mod, BCA);
165-
auto BottomUpFunctions = BottomUpOrder.getFunctions();
166-
167-
for (auto I = BottomUpFunctions.rbegin(),
168-
E = BottomUpFunctions.rend();
169-
I != E; ++I) {
170-
SILFunction *F = *I;
171-
172-
if (F->empty())
162+
for (auto &F : *Mod) {
163+
if (F.empty())
173164
continue;
174165

175166
// Don't optimize functions that are marked with the opt.never attribute.
176-
if (!F->shouldOptimize())
167+
if (!F.shouldOptimize())
177168
continue;
178169

179-
CompletedPasses &completedPasses = CompletedPassesMap[F];
180-
181-
170+
CompletedPasses &completedPasses = CompletedPassesMap[&F];
182171

183172
for (auto SFT : FuncTransforms) {
184173
PrettyStackTraceSILFunctionTransform X(SFT);
185174
SFT->injectPassManager(this);
186-
SFT->injectFunction(F);
175+
SFT->injectFunction(&F);
187176

188177
// If nothing changed since the last run of this pass, we can skip this
189178
// pass.
@@ -198,13 +187,13 @@ bool SILPassManager::runFunctionPasses(PassList FuncTransforms) {
198187
if (SILPrintPassName)
199188
llvm::dbgs() << "#" << NumPassesRun << " Stage: " << StageName
200189
<< " Pass: " << SFT->getName()
201-
<< ", Function: " << F->getName() << "\n";
190+
<< ", Function: " << F.getName() << "\n";
202191

203-
if (doPrintBefore(SFT, F)) {
192+
if (doPrintBefore(SFT, &F)) {
204193
llvm::dbgs() << "*** SIL function before " << StageName << " "
205194
<< SFT->getName() << " (" << NumOptimizationIterations
206195
<< ") ***\n";
207-
F->dump(Options.EmitVerboseSIL);
196+
F.dump(Options.EmitVerboseSIL);
208197
}
209198

210199
llvm::sys::TimeValue StartTime = llvm::sys::TimeValue::now();
@@ -213,17 +202,17 @@ bool SILPassManager::runFunctionPasses(PassList FuncTransforms) {
213202
if (SILPrintPassTime) {
214203
auto Delta = llvm::sys::TimeValue::now().nanoseconds() -
215204
StartTime.nanoseconds();
216-
llvm::dbgs() << Delta << " (" << SFT->getName() << "," << F->getName()
205+
llvm::dbgs() << Delta << " (" << SFT->getName() << "," << F.getName()
217206
<< ")\n";
218207
}
219208

220209
// If this pass invalidated anything, print and verify.
221-
if (doPrintAfter(SFT, F,
210+
if (doPrintAfter(SFT, &F,
222211
currentPassHasInvalidated && SILPrintAll)) {
223212
llvm::dbgs() << "*** SIL function after " << StageName << " "
224213
<< SFT->getName() << " (" << NumOptimizationIterations
225214
<< ") ***\n";
226-
F->dump(Options.EmitVerboseSIL);
215+
F.dump(Options.EmitVerboseSIL);
227216
}
228217

229218
// Remember if this pass didn't change anything.
@@ -232,8 +221,8 @@ bool SILPassManager::runFunctionPasses(PassList FuncTransforms) {
232221

233222
if (Options.VerifyAll &&
234223
(currentPassHasInvalidated || SILVerifyWithoutInvalidation)) {
235-
F->verify();
236-
verifyAnalyses(F);
224+
F.verify();
225+
verifyAnalyses(&F);
237226
}
238227

239228
++NumPassesRun;

0 commit comments

Comments
 (0)