[llvm] r273625 - [LCG] Make the name of an SCC include more of the functions in it.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 15:51:15 PDT 2016


Author: chandlerc
Date: Thu Jun 23 17:51:14 2016
New Revision: 273625

URL: http://llvm.org/viewvc/llvm-project?rev=273625&view=rev
Log:
[LCG] Make the name of an SCC include more of the functions in it.

This makes it much easier to debug issues when the logging contains the
name of the SCC. It requires to create a temporary string, but for
logging and debugging uses that seems fine. I've added logic to try to
output all the function names with an elipsis if there are too many.
This was helpful fro me in debugging issues with the new pass manager.

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

Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=273625&r1=273624&r2=273625&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Thu Jun 23 17:51:14 2016
@@ -377,7 +377,23 @@ public:
     ///
     /// We use the name of the first function in the SCC to name the SCC for
     /// the purposes of debugging and logging.
-    StringRef getName() const { return begin()->getFunction().getName(); }
+    std::string getName() const {
+      std::string Name;
+      int i = 0;
+      for (Node &N : *this) {
+        if (i > 0)
+          Name += ", ";
+        // Elide the inner elements if there are too many.
+        if (i > 8) {
+          Name += "..., ";
+          Name += Nodes.back()->getFunction().getName().str();
+          break;
+        }
+        Name += N.getFunction().getName().str();
+        ++i;
+      }
+      return Name;
+    }
   };
 
   /// A RefSCC of the call graph.




More information about the llvm-commits mailing list