[llvm] r243881 - Allow derived DOTViewers to choose the functions to illustrate

Tobias Grosser tobias at grosser.es
Mon Aug 3 09:37:12 PDT 2015


Author: grosser
Date: Mon Aug  3 11:37:12 2015
New Revision: 243881

URL: http://llvm.org/viewvc/llvm-project?rev=243881&view=rev
Log:
Allow derived DOTViewers to choose the functions to illustrate

Instead of always showing/printing all functions, a class derived from
the DOTViewer class can overwrite the set of functions that will be
processed.

This will be used (and tested) by Polly's scop viewers, but other users
can be imagined as well.

Modified:
    llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h

Modified: llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h?rev=243881&r1=243880&r2=243881&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h (original)
+++ llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h Mon Aug  3 11:37:12 2015
@@ -36,7 +36,18 @@ public:
   DOTGraphTraitsViewer(StringRef GraphName, char &ID)
       : FunctionPass(ID), Name(GraphName) {}
 
+  /// @brief Return true if this function should be processed.
+  ///
+  /// An implementation of this class my override this function to indicate that
+  /// only certain functions should be viewed.
+  virtual bool processFunction(Function &F) {
+    return true;
+  }
+
   bool runOnFunction(Function &F) override {
+    if (!processFunction(F))
+      return false;
+
     GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
     std::string GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
     std::string Title = GraphName + " for '" + F.getName().str() + "' function";
@@ -63,7 +74,18 @@ public:
   DOTGraphTraitsPrinter(StringRef GraphName, char &ID)
       : FunctionPass(ID), Name(GraphName) {}
 
+  /// @brief Return true if this function should be processed.
+  ///
+  /// An implementation of this class my override this function to indicate that
+  /// only certain functions should be printed.
+  virtual bool processFunction(Function &F) {
+    return true;
+  }
+
   bool runOnFunction(Function &F) override {
+    if (!processFunction(F))
+      return false;
+
     GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
     std::string Filename = Name + "." + F.getName().str() + ".dot";
     std::error_code EC;





More information about the llvm-commits mailing list