[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

Michael Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 11:11:25 PDT 2019


hliao created this revision.
hliao added reviewers: tra, sfantao, echristo.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hliao added a comment.

this patch enables the dumping of actions in the hierarchy or tree. In most cases, it's a linear list but, for offload compilation, a tree representation is more intuitive. Even though there are cross-subtree edges, they are rare and also noted in the corresponding actions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69124

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1806,7 +1806,8 @@
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-                              std::map<Action *, unsigned> &Ids) {
+                              std::map<Action *, unsigned> &Ids,
+                              unsigned Ident = 0) {
   if (Ids.count(A)) // A was already visited.
     return Ids[A];
 
@@ -1818,7 +1819,7 @@
     os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast<BindArchAction>(A)) {
     os << '"' << BIA->getArchName() << '"' << ", {"
-       << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+       << PrintActions1(C, *BIA->input_begin(), Ids, Ident + 1) << "}";
   } else if (OffloadAction *OA = dyn_cast<OffloadAction>(A)) {
     bool IsFirst = true;
     OA->doOnEachDependence(
@@ -1841,7 +1842,7 @@
             os << ":" << BoundArch;
           os << ")";
           os << '"';
-          os << " {" << PrintActions1(C, A, Ids) << "}";
+          os << " {" << PrintActions1(C, A, Ids, Ident + 1) << "}";
           IsFirst = false;
         });
   } else {
@@ -1850,7 +1851,7 @@
     if (AL->size()) {
       const char *Prefix = "{";
       for (Action *PreRequisite : *AL) {
-        os << Prefix << PrintActions1(C, PreRequisite, Ids);
+        os << Prefix << PrintActions1(C, PreRequisite, Ids, Ident + 1);
         Prefix = ", ";
       }
       os << "}";
@@ -1874,8 +1875,9 @@
 
   unsigned Id = Ids.size();
   Ids[A] = Id;
-  llvm::errs() << Id << ": " << os.str() << ", "
-               << types::getTypeName(A->getType()) << offload_os.str() << "\n";
+  llvm::errs().indent(Ident)
+      << Id << ": " << os.str() << ", " << types::getTypeName(A->getType())
+      << offload_os.str() << "\n";
 
   return Id;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69124.225472.patch
Type: text/x-patch
Size: 2046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191017/e600b81a/attachment.bin>


More information about the cfe-commits mailing list