diff --git a/include/swift/SIL/SILFunction.h b/include/swift/SIL/SILFunction.h index 59f867c16c3..e05e7e3a5c7 100644 --- a/include/swift/SIL/SILFunction.h +++ b/include/swift/SIL/SILFunction.h @@ -900,6 +900,9 @@ public: /// block inside. This depends on there being a 'dot' and 'gv' program in /// your path. void viewCFG() const; + // Like the ViewCFG, but the graph does not show the basic block contents. + void viewCFGOnly() const; + }; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, diff --git a/lib/SIL/SILFunction.cpp b/lib/SIL/SILFunction.cpp index 0dc2e143390..cdd6065fc74 100644 --- a/lib/SIL/SILFunction.cpp +++ b/lib/SIL/SILFunction.cpp @@ -405,17 +405,28 @@ TargetFunction("view-cfg-only-for-function", llvm::cl::init(""), llvm::cl::desc("Only print out the cfg for this function")); #endif - -void SILFunction::viewCFG() const { +namespace { +void viewCFGHelper(const SILFunction* F, bool skipBBContents) { /// When asserts are disabled, this should be a NoOp. #ifndef NDEBUG // If we have a target function, only print that function out. - if (!TargetFunction.empty() && !(getName().str() == TargetFunction)) + if (!TargetFunction.empty() && !(F->getName().str() == TargetFunction)) return; - ViewGraph(const_cast(this), "cfg" + getName().str()); + ViewGraph(const_cast(F), "cfg" + F->getName().str(), + /*shortNames=*/skipBBContents); #endif } +} // namespace + +void SILFunction::viewCFG() const { + viewCFGHelper(this, /*skipBBContents=*/false); +} + +void SILFunction::viewCFGOnly() const { + viewCFGHelper(this, /*skipBBContents=*/true); +} + bool SILFunction::hasSelfMetadataParam() const { auto paramTypes = getConventions().getParameterSILTypes();