diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-06-13 20:09:59 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-06-13 20:09:59 +0000 |
commit | a9ac180f032890c5770a1997af4f0a8af3e5443e (patch) | |
tree | 24bf2db94ffc357b25c73e4bd5976f1d6fe8204f | |
parent | eadd795fa316542c78a7d47709326e10c850f516 (diff) |
[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.
Differential Revision: https://reviews.llvm.org/D48109
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334649 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/IR/LegacyPassManager.cpp | 6 | ||||
-rw-r--r-- | test/CodeGen/X86/time-passes-json-stats.ll | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp index b04787cb30e..46bfba7f5a0 100644 --- a/lib/IR/LegacyPassManager.cpp +++ b/lib/IR/LegacyPassManager.cpp @@ -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; } diff --git a/test/CodeGen/X86/time-passes-json-stats.ll b/test/CodeGen/X86/time-passes-json-stats.ll new file mode 100644 index 00000000000..70049b2363e --- /dev/null +++ b/test/CodeGen/X86/time-passes-json-stats.ll @@ -0,0 +1,14 @@ +; RUN: llc -mtriple=x86_64-- -stats-json=true -stats -time-passes %s -o /dev/null 2>&1 | FileCheck %s + +; Verify that we use the argument pass name instead of the full name as a json +; key for timers. +; +; CHECK: { +; CHECK-NEXT: "asm-printer.EmittedInsts": +; CHECK-NOT: Virtual Register Map +; CHECK: "time.pass.virtregmap.wall": +; CHECK: "time.pass.virtregmap.user": +; CHECK: "time.pass.virtregmap.sys": +; CHECK: Virtual Register Map + +define void @test_stats() { ret void } |