aboutsummaryrefslogtreecommitdiff
path: root/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
commit13dc07c7dc9ca99634fe8342ec4748536b31d88f (patch)
tree2a58d5f322bf63fdd0192c7da60910c785e92ee5 /lib/Bytecode/Writer/SlotCalculator.h
parenta76b1febd4fd258e8054395adedcbd477668d956 (diff)
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
Diffstat (limited to 'lib/Bytecode/Writer/SlotCalculator.h')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index d39635b107..e20bc62a24 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/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