mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
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:
@ -180,9 +180,7 @@ void SlotCalculator::processModule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NumModuleTypes = getNumPlanes();
|
||||||
// Initialize the ModuleLevel entries.
|
|
||||||
ModuleLevel.resize(getNumPlanes(), -1);
|
|
||||||
|
|
||||||
SC_DEBUG("end processModule!\n");
|
SC_DEBUG("end processModule!\n");
|
||||||
}
|
}
|
||||||
@ -300,20 +298,17 @@ void SlotCalculator::incorporateFunction(const Function *F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SlotCalculator::purgeFunction() {
|
void SlotCalculator::purgeFunction() {
|
||||||
unsigned NumModuleTypes = ModuleLevel.size();
|
|
||||||
|
|
||||||
SC_DEBUG("begin purgeFunction!\n");
|
SC_DEBUG("begin purgeFunction!\n");
|
||||||
|
|
||||||
// Next, remove values from existing type planes
|
// Next, remove values from existing type planes
|
||||||
for (unsigned i = 0; i != NumModuleTypes; ++i) {
|
for (DenseMap<unsigned,unsigned,
|
||||||
// If this type is not used by this function, ignore it.
|
ModuleLevelDenseMapKeyInfo>::iterator I = ModuleLevel.begin(),
|
||||||
int ModuleLev = ModuleLevel[i];
|
E = ModuleLevel.end(); I != E; ++I) {
|
||||||
if (ModuleLev == -1) continue;
|
unsigned PlaneNo = I->first;
|
||||||
|
unsigned ModuleLev = I->second;
|
||||||
ModuleLevel[i] = -1; // Reset for next function.
|
|
||||||
|
|
||||||
// Pop all function-local values in this type-plane off of Table.
|
// Pop all function-local values in this type-plane off of Table.
|
||||||
TypePlane &Plane = getPlane(i);
|
TypePlane &Plane = getPlane(PlaneNo);
|
||||||
assert(ModuleLev < Plane.size() && "module levels higher than elements?");
|
assert(ModuleLev < Plane.size() && "module levels higher than elements?");
|
||||||
for (unsigned i = ModuleLev, e = Plane.size(); i != e; ++i) {
|
for (unsigned i = ModuleLev, e = Plane.size(); i != e; ++i) {
|
||||||
NodeMap.erase(Plane.back()); // Erase from nodemap
|
NodeMap.erase(Plane.back()); // Erase from nodemap
|
||||||
@ -321,6 +316,8 @@ void SlotCalculator::purgeFunction() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModuleLevel.clear();
|
||||||
|
|
||||||
// Finally, remove any type planes defined by the function...
|
// Finally, remove any type planes defined by the function...
|
||||||
while (Table.size() > NumModuleTypes) {
|
while (Table.size() > NumModuleTypes) {
|
||||||
TypePlane &Plane = Table.back();
|
TypePlane &Plane = Table.back();
|
||||||
@ -349,8 +346,8 @@ void SlotCalculator::CreateFunctionValueSlot(const Value *V) {
|
|||||||
// If this is the first value noticed of this type within this function,
|
// If this is the first value noticed of this type within this function,
|
||||||
// remember the module level for this type plane in ModuleLevel. This reminds
|
// remember the module level for this type plane in ModuleLevel. This reminds
|
||||||
// us to remove the values in purgeFunction and tells us how many to remove.
|
// us to remove the values in purgeFunction and tells us how many to remove.
|
||||||
if (TyPlane < ModuleLevel.size() && ModuleLevel[TyPlane] == -1)
|
if (TyPlane < NumModuleTypes)
|
||||||
ModuleLevel[TyPlane] = Table[TyPlane].size();
|
ModuleLevel.insert(std::make_pair(TyPlane, Table[TyPlane].size()));
|
||||||
|
|
||||||
// If this is the first value to get inserted into the type plane, make sure
|
// If this is the first value to get inserted into the type plane, make sure
|
||||||
// to insert the implicit null value.
|
// to insert the implicit null value.
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#ifndef LLVM_ANALYSIS_SLOTCALCULATOR_H
|
#ifndef LLVM_ANALYSIS_SLOTCALCULATOR_H
|
||||||
#define LLVM_ANALYSIS_SLOTCALCULATOR_H
|
#define LLVM_ANALYSIS_SLOTCALCULATOR_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -34,6 +35,14 @@ class TypeSymbolTable;
|
|||||||
class ValueSymbolTable;
|
class ValueSymbolTable;
|
||||||
class ConstantArray;
|
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 {
|
class SlotCalculator {
|
||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
|
|
||||||
@ -54,8 +63,8 @@ class SlotCalculator {
|
|||||||
/// ModuleLevel - Used to keep track of which values belong to the module,
|
/// ModuleLevel - Used to keep track of which values belong to the module,
|
||||||
/// and which values belong to the currently incorporated function.
|
/// and which values belong to the currently incorporated function.
|
||||||
///
|
///
|
||||||
std::vector<int> ModuleLevel;
|
DenseMap<unsigned,unsigned,ModuleLevelDenseMapKeyInfo> ModuleLevel;
|
||||||
unsigned ModuleTypeLevel;
|
unsigned NumModuleTypes;
|
||||||
|
|
||||||
SlotCalculator(const SlotCalculator &); // DO NOT IMPLEMENT
|
SlotCalculator(const SlotCalculator &); // DO NOT IMPLEMENT
|
||||||
void operator=(const SlotCalculator &); // DO NOT IMPLEMENT
|
void operator=(const SlotCalculator &); // DO NOT IMPLEMENT
|
||||||
|
Reference in New Issue
Block a user