Skip to content

Commit abe703a

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 635eef2 + a728b26 commit abe703a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/SILOptimizer/UtilityPasses/CFGPrinter.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,37 @@ using namespace swift;
2929
// Options
3030
//===----------------------------------------------------------------------===//
3131

32+
llvm::cl::opt<std::string> SILViewCFGOnlyFun(
33+
"sil-view-cfg-only-function", llvm::cl::init(""),
34+
llvm::cl::desc("Only produce a graphviz file for this function"));
35+
36+
llvm::cl::opt<std::string> SILViewCFGOnlyFuns(
37+
"sil-view-cfg-only-functions", llvm::cl::init(""),
38+
llvm::cl::desc("Only produce a graphviz file for the sil for the functions "
39+
"whose name contains this substring"));
40+
3241
//===----------------------------------------------------------------------===//
3342
// Top Level Driver
3443
//===----------------------------------------------------------------------===//
3544

3645
namespace {
46+
3747
class SILCFGPrinter : public SILFunctionTransform {
3848
/// The entry point to the transformation.
3949
void run() override {
4050
SILFunction *F = getFunction();
4151

52+
// If we are not supposed to dump view this cfg, return.
53+
if (!SILViewCFGOnlyFun.empty() && F && F->getName() != SILViewCFGOnlyFun)
54+
return;
55+
if (!SILViewCFGOnlyFuns.empty() && F &&
56+
F->getName().find(SILViewCFGOnlyFuns, 0) == StringRef::npos)
57+
return;
58+
4259
F->viewCFG();
4360
}
4461
};
62+
4563
} // end anonymous namespace
4664

4765
SILTransform *swift::createCFGPrinter() {

0 commit comments

Comments
 (0)