]> granicus.if.org Git - llvm/commitdiff
[RegisterBankInfo] Add statistics for dynamic partial mappings.
authorQuentin Colombet <qcolombet@apple.com>
Fri, 23 Sep 2016 18:38:06 +0000 (18:38 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Fri, 23 Sep 2016 18:38:06 +0000 (18:38 +0000)
Collect statistics about the number of partial mappings dynamically
allocated and accessed. Ultimately, when the whole TableGen
infrastructure is set, those numbers should be zero.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282274 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalISel/RegisterBankInfo.cpp

index 88e47f6fb89132de2e80b9e9324f3de2f0eada71..b52e098539860da00bbc4c1f8eeba12eebbf5802 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/CodeGen/GlobalISel/RegisterBank.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 
 using namespace llvm;
 
+STATISTIC(NumPartialMappingsCreated,
+          "Number of partial mappings dynamically created");
+STATISTIC(NumPartialMappingsAccessed,
+          "Number of partial mappings dynamically accessed");
+
 const unsigned RegisterBankInfo::DefaultMappingID = UINT_MAX;
 const unsigned RegisterBankInfo::InvalidMappingID = UINT_MAX - 1;
 
@@ -309,10 +315,15 @@ RegisterBankInfo::getInstrMappingImpl(const MachineInstr &MI) const {
 const RegisterBankInfo::PartialMapping &
 RegisterBankInfo::getPartialMapping(unsigned StartIdx, unsigned Length,
                                     const RegisterBank &RegBank) const {
+  ++NumPartialMappingsAccessed;
+
   hash_code Hash = hash_combine(StartIdx, Length, RegBank.getID());
   const auto &It = MapOfPartialMappings.find(Hash);
   if (It != MapOfPartialMappings.end())
     return It->second;
+
+  ++NumPartialMappingsCreated;
+
   PartialMapping &PartMapping = MapOfPartialMappings[Hash];
   PartMapping = PartialMapping{StartIdx, Length, RegBank};
   return PartMapping;