Skip to content

Commit a86c86a

Browse files
authored
Merge pull request #70116 from eeckstein/print-function-option
SILPassManager: make `-sil-print-function` more convenient
2 parents 1deff49 + 57b3450 commit a86c86a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,21 @@ static llvm::cl::opt<DebugOnlyPassNumberOpt, true,
178178
llvm::cl::location(DebugOnlyPassNumberOptLoc),
179179
llvm::cl::ValueRequired);
180180

181+
static bool isInPrintFunctionList(SILFunction *F) {
182+
for (const std::string &printFnName : SILPrintFunction) {
183+
if (printFnName == F->getName())
184+
return true;
185+
if (!printFnName.empty() && printFnName[0] != '$' &&
186+
!F->getName().empty() && F->getName()[0] == '$' &&
187+
printFnName == F->getName().drop_front()) {
188+
return true;
189+
}
190+
}
191+
return false;
192+
}
193+
181194
bool isFunctionSelectedForPrinting(SILFunction *F) {
182-
if (!SILPrintFunction.empty() && SILPrintFunction.end() ==
183-
std::find(SILPrintFunction.begin(), SILPrintFunction.end(), F->getName()))
195+
if (!SILPrintFunction.empty() && !isInPrintFunctionList(F))
184196
return false;
185197

186198
if (!F->getName().contains(SILPrintFunctions))

0 commit comments

Comments
 (0)