[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
This commit is contained in:
Quentin Colombet 2016-09-23 18:38:06 +00:00
parent 1acb55e67c
commit d4c02437c1
1 changed files with 11 additions and 0 deletions

View 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"
@ -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;