summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer/SlotCalculator.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-10 06:38:19 +0000
committerChris Lattner <sabre@nondot.org>2007-02-10 06:38:19 +0000
commitcdde9ce28be872d1ae9560f08ca90fa21b7a1869 (patch)
treecc06a99dd0626dfa5494ef73508c64d1bcd18500 /llvm/lib/Bytecode/Writer/SlotCalculator.h
parentd0a27bc995017d4bcc511525b1d8d9f528bba96e (diff)
downloadbcm5719-llvm-cdde9ce28be872d1ae9560f08ca90fa21b7a1869.tar.gz
bcm5719-llvm-cdde9ce28be872d1ae9560f08ca90fa21b7a1869.zip
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. llvm-svn: 34135
Diffstat (limited to 'llvm/lib/Bytecode/Writer/SlotCalculator.h')
-rw-r--r--llvm/lib/Bytecode/Writer/SlotCalculator.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Writer/SlotCalculator.h b/llvm/lib/Bytecode/Writer/SlotCalculator.h
index d39635b1076..e20bc62a24f 100644
--- a/llvm/lib/Bytecode/Writer/SlotCalculator.h
+++ b/llvm/lib/Bytecode/Writer/SlotCalculator.h
@@ -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
OpenPOWER on IntegriCloud