Skip to content

Commit 63bda7b

Browse files
authored
Merge pull request #14486 from atrick/print-all
2 parents 54a3597 + 3a15cee commit 63bda7b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

include/swift/SILOptimizer/PassManager/PassManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class SILPassManager {
155155
CompletedPassesMap.clear();
156156
}
157157

158+
/// \brief Notify the pass manager of a newly create function for tracing.
159+
void notifyOfNewFunction(SILFunction *F, SILTransform *T);
160+
158161
/// \brief Add the function \p F to the function pass worklist.
159162
/// If not null, the function \p DerivedFrom is the function from which \p F
160163
/// is derived. This is used to avoid an infinite amount of functions pushed
@@ -291,6 +294,9 @@ class SILPassManager {
291294
/// Return true if all analyses are unlocked.
292295
bool analysesUnlocked();
293296

297+
/// Dumps information about the pass with index \p TransIdx to llvm::dbgs().
298+
void dumpPassInfo(const char *Title, SILTransform *Tr, SILFunction *F);
299+
294300
/// Dumps information about the pass with index \p TransIdx to llvm::dbgs().
295301
void dumpPassInfo(const char *Title, unsigned TransIdx,
296302
SILFunction *F = nullptr);

include/swift/SILOptimizer/PassManager/Transforms.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ namespace swift {
114114
/// The number should be small anyway, but bugs in optimizations could cause
115115
/// an infinite loop in the passmanager.
116116
void notifyAddFunction(SILFunction *F, SILFunction *DerivedFrom) {
117+
PM->notifyOfNewFunction(F, this);
117118
PM->addFunctionToWorklist(F, DerivedFrom);
118119
PM->notifyAnalysisOfFunction(F);
119120
}
@@ -171,6 +172,7 @@ namespace swift {
171172

172173
/// Inform the pass manager of an added function.
173174
void notifyAddFunction(SILFunction *F) {
175+
PM->notifyOfNewFunction(F, this);
174176
PM->notifyAnalysisOfFunction(F);
175177
}
176178
};

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ static bool breakBeforeRunning(StringRef fnName, SILFunctionTransform *SFT) {
283283
&& (SFT->getID() == SILBreakOnPass || SFT->getTag() == SILBreakOnPass);
284284
}
285285

286+
void SILPassManager::dumpPassInfo(const char *Title, SILTransform *Tr,
287+
SILFunction *F) {
288+
llvm::dbgs() << " " << Title << " #" << NumPassesRun << ", stage "
289+
<< StageName << ", pass : " << Tr->getID()
290+
<< " (" << Tr->getTag() << ")";
291+
if (F)
292+
llvm::dbgs() << ", Function: " << F->getName();
293+
llvm::dbgs() << '\n';
294+
}
295+
286296
void SILPassManager::dumpPassInfo(const char *Title, unsigned TransIdx,
287297
SILFunction *F) {
288298
SILTransform *Tr = Transformations[TransIdx];
@@ -541,6 +551,13 @@ SILPassManager::~SILPassManager() {
541551
}
542552
}
543553

554+
void SILPassManager::notifyOfNewFunction(SILFunction *F, SILTransform *T) {
555+
if (doPrintAfter(T, F, SILPrintAll)) {
556+
dumpPassInfo("*** New SIL function in ", T, F);
557+
F->dump(getOptions().EmitVerboseSIL);
558+
}
559+
}
560+
544561
void SILPassManager::addFunctionToWorklist(SILFunction *F,
545562
SILFunction *DerivedFrom) {
546563
assert(F && F->isDefinition() && (isMandatoryPipeline || F->shouldOptimize())

0 commit comments

Comments
 (0)