Add a viewCFGOnly function for debugging purposes.

This commit is contained in:
Gogul Balakrishnan
2018-07-10 12:32:36 -07:00
parent 7c0ff47487
commit f48091745c
2 changed files with 18 additions and 4 deletions

View File

@@ -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<SILFunction *>(this), "cfg" + getName().str());
ViewGraph(const_cast<SILFunction *>(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();