The ModuleLevel vector is often quite sparse. Switch it to a DenseMap. This

speeds up bcwriting of 447.dealII by 40%, from 4.63s to 3.32s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34135 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-02-10 06:38:19 +00:00
parent a76b1febd4
commit 13dc07c7dc
2 changed files with 24 additions and 18 deletions

View File

@@ -20,6 +20,7 @@
#ifndef LLVM_ANALYSIS_SLOTCALCULATOR_H
#define LLVM_ANALYSIS_SLOTCALCULATOR_H
#include "llvm/ADT/DenseMap.h"
#include <vector>
#include <map>
@@ -34,6 +35,14 @@ class TypeSymbolTable;
class ValueSymbolTable;
class ConstantArray;
struct ModuleLevelDenseMapKeyInfo {
static inline unsigned getEmptyKey() { return ~0U; }
static inline unsigned getTombstoneKey() { return ~1U; }
static unsigned getHashValue(unsigned Val) { return Val ^ Val >> 4; }
static bool isPod() { return true; }
};
class SlotCalculator {
const Module *TheModule;
@@ -54,8 +63,8 @@ class SlotCalculator {
/// ModuleLevel - Used to keep track of which values belong to the module,
/// and which values belong to the currently incorporated function.
///
std::vector<int> ModuleLevel;
unsigned ModuleTypeLevel;
DenseMap<unsigned,unsigned,ModuleLevelDenseMapKeyInfo> ModuleLevel;
unsigned NumModuleTypes;
SlotCalculator(const SlotCalculator &); // DO NOT IMPLEMENT
void operator=(const SlotCalculator &); // DO NOT IMPLEMENT