[llvm] r334657 - Reland: [Timers] Use the pass argument name for JSON keys in time-passes

Francis Visoiu Mistrih via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 13 14:03:57 PDT 2018


Author: thegameg
Date: Wed Jun 13 14:03:56 2018
New Revision: 334657

URL: http://llvm.org/viewvc/llvm-project?rev=334657&view=rev
Log:
Reland: [Timers] Use the pass argument name for JSON keys in time-passes

When using clang --save-stats -mllvm -time-passes, both timers and stats
end up in the same json file.

We could end up with things like:

{
  "asm-printer.EmittedInsts": 1,
  "time.pass.Virtual Register Map.wall": 2.9015541076660156e-04,
  "time.pass.Virtual Register Map.user": 2.0500000000000379e-04,
  "time.pass.Virtual Register Map.sys": 8.5000000000001741e-05,
}

This patch makes use of the pass argument name (if available) in the
JSON key to end up with things like:

{
  "asm-printer.EmittedInsts": 1,
  "time.pass.virtregmap.wall": 2.9015541076660156e-04,
  "time.pass.virtregmap.user": 2.0500000000000379e-04,
  "time.pass.virtregmap.sys": 8.5000000000001741e-05,
}

This also helps avoiding to write another JSON printer to handle all the
cases that we could have in our pass names.

Fixed test instead of adding a new one originally from r334649.

Differential Revision: https://reviews.llvm.org/D48109

Modified:
    llvm/trunk/lib/IR/LegacyPassManager.cpp
    llvm/trunk/test/Other/statistic.ll

Modified: llvm/trunk/lib/IR/LegacyPassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LegacyPassManager.cpp?rev=334657&r1=334656&r2=334657&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LegacyPassManager.cpp (original)
+++ llvm/trunk/lib/IR/LegacyPassManager.cpp Wed Jun 13 14:03:56 2018
@@ -545,7 +545,11 @@ public:
     Timer *&T = TimingData[P];
     if (!T) {
       StringRef PassName = P->getPassName();
-      T = new Timer(PassName, PassName, TG);
+      StringRef PassArgument;
+      if (const PassInfo *PI = Pass::lookupPassInfo(P->getPassID()))
+        PassArgument = PI->getPassArgument();
+      T = new Timer(PassArgument.empty() ? PassName : PassArgument, PassName,
+                    TG);
     }
     return T;
   }

Modified: llvm/trunk/test/Other/statistic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/statistic.ll?rev=334657&r1=334656&r2=334657&view=diff
==============================================================================
--- llvm/trunk/test/Other/statistic.ll (original)
+++ llvm/trunk/test/Other/statistic.ll Wed Jun 13 14:03:56 2018
@@ -8,9 +8,9 @@
 
 ; JSON: {
 ; JSON-DAG:   "instsimplify.NumSimplified": 1
-; JSONTIME-DAG:   "time.pass.Remove redundant instructions.wall"
-; JSONTIME-DAG:   "time.pass.Remove redundant instructions.user"
-; JSONTIME-DAG:   "time.pass.Remove redundant instructions.sys"
+; JSONTIME-DAG:   "time.pass.instsimplify.wall"
+; JSONTIME-DAG:   "time.pass.instsimplify.user"
+; JSONTIME-DAG:   "time.pass.instsimplify.sys"
 ; JSON: }
 
 ; DEFAULT: 1 instsimplify - Number of redundant instructions removed




More information about the llvm-commits mailing list