Skip to content

Commit ef7ddda

Browse files
authored
Make -sil-print-only-function take comma separated values (swiftlang#29433)
1 parent 2da9601 commit ef7ddda

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/SILOptimizer/PassManager/PassManager.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ llvm::cl::opt<std::string> SILBreakOnPass(
5858
"sil-break-on-pass", llvm::cl::init(""),
5959
llvm::cl::desc("Break before running a particular function pass"));
6060

61-
llvm::cl::opt<std::string>
62-
SILPrintOnlyFun("sil-print-only-function", llvm::cl::init(""),
61+
llvm::cl::list<std::string>
62+
SILPrintOnlyFun("sil-print-only-function", llvm::cl::CommaSeparated,
6363
llvm::cl::desc("Only print out the sil for this function"));
6464

6565
llvm::cl::opt<std::string>
@@ -144,7 +144,8 @@ static llvm::cl::opt<DebugOnlyPassNumberOpt, true,
144144
llvm::cl::ValueRequired);
145145

146146
static bool doPrintBefore(SILTransform *T, SILFunction *F) {
147-
if (!SILPrintOnlyFun.empty() && F && F->getName() != SILPrintOnlyFun)
147+
if (!SILPrintOnlyFun.empty() && F && SILPrintOnlyFun.end() ==
148+
std::find(SILPrintOnlyFun.begin(), SILPrintOnlyFun.end(), F->getName()))
148149
return false;
149150

150151
if (!SILPrintOnlyFuns.empty() && F &&
@@ -168,7 +169,8 @@ static bool doPrintBefore(SILTransform *T, SILFunction *F) {
168169
}
169170

170171
static bool doPrintAfter(SILTransform *T, SILFunction *F, bool Default) {
171-
if (!SILPrintOnlyFun.empty() && F && F->getName() != SILPrintOnlyFun)
172+
if (!SILPrintOnlyFun.empty() && F && SILPrintOnlyFun.end() ==
173+
std::find(SILPrintOnlyFun.begin(), SILPrintOnlyFun.end(), F->getName()))
172174
return false;
173175

174176
if (!SILPrintOnlyFuns.empty() && F &&
@@ -207,7 +209,8 @@ static void printModule(SILModule *Mod, bool EmitVerboseSIL) {
207209
return;
208210
}
209211
for (auto &F : *Mod) {
210-
if (!SILPrintOnlyFun.empty() && F.getName().str() == SILPrintOnlyFun)
212+
if (!SILPrintOnlyFun.empty() && SILPrintOnlyFun.end() !=
213+
std::find(SILPrintOnlyFun.begin(), SILPrintOnlyFun.end(), F.getName()))
211214
F.dump(EmitVerboseSIL);
212215

213216
if (!SILPrintOnlyFuns.empty() &&

0 commit comments

Comments
 (0)