Skip to content

Commit 7fbf22c

Browse files
committed
[NFC] SIL: Add hook to print after every subpass.
1 parent e53da29 commit 7fbf22c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ static llvm::cl::opt<DebugOnlyPassNumberOpt, true,
204204
llvm::cl::location(DebugOnlyPassNumberOptLoc),
205205
llvm::cl::ValueRequired);
206206

207+
static llvm::cl::opt<bool> SILPrintEverySubpass(
208+
"sil-print-every-subpass", llvm::cl::init(false),
209+
llvm::cl::desc("Print the function before every subpass run of passes that "
210+
"have multiple subpasses"));
211+
207212
static bool isInPrintFunctionList(SILFunction *F) {
208213
for (const std::string &printFnName : SILPrintFunction) {
209214
if (printFnName == F->getName())
@@ -478,13 +483,22 @@ bool SILPassManager::continueTransforming() {
478483
bool SILPassManager::continueWithNextSubpassRun(SILInstruction *forInst,
479484
SILFunction *function,
480485
SILTransform *trans) {
486+
unsigned subPass = numSubpassesRun++;
487+
488+
if (forInst && isFunctionSelectedForPrinting(function) &&
489+
SILPrintEverySubpass) {
490+
dumpPassInfo("*** SIL function before ", trans, function);
491+
if (forInst) {
492+
llvm::dbgs() << " *** sub-pass " << subPass << " for " << *forInst;
493+
}
494+
function->dump(getOptions().EmitVerboseSIL);
495+
}
496+
481497
if (isMandatory)
482498
return true;
483499
if (NumPassesRun != maxNumPassesToRun - 1)
484500
return true;
485501

486-
unsigned subPass = numSubpassesRun++;
487-
488502
if (subPass == maxNumSubpassesToRun - 1 && SILPrintLast) {
489503
dumpPassInfo("*** SIL function before ", trans, function);
490504
if (forInst) {

0 commit comments

Comments
 (0)