From d4c02437c16b52d49f6b2ead97c8b716c81de64b Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Fri, 23 Sep 2016 18:38:06 +0000 Subject: [PATCH] [RegisterBankInfo] Add statistics for dynamic partial mappings. 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. llvm-svn: 282274 --- llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index 88e47f6fb891..b52e09853986 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -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" @@ -32,6 +33,11 @@ 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;