mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Eliminate the old LateResolveValues data structure, replacing it with a
new, simpler, ForwardReferences data structure. This is just the first simple replacement, subsequent changes will improve the code more. This simple change improves the performance of loading a file from HDF5 (contributed by Bill) from 2.36s to 1.93s, a 22% improvement. This presumably has to do with the fact that we only create ONE placeholder for a particular forward referenced values, and also may be because the data structure is much simpler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8979 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -128,8 +128,14 @@ Value *BytecodeParser::getValue(unsigned type, unsigned oNum, bool Create) {
|
|||||||
|
|
||||||
if (!Create) return 0; // Do not create a placeholder?
|
if (!Create) return 0; // Do not create a placeholder?
|
||||||
|
|
||||||
|
std::pair<unsigned,unsigned> KeyValue(type, oNum);
|
||||||
|
std::map<std::pair<unsigned,unsigned>, Value*>::iterator I =
|
||||||
|
ForwardReferences.lower_bound(KeyValue);
|
||||||
|
if (I != ForwardReferences.end() && I->first == KeyValue)
|
||||||
|
return I->second; // We have already created this placeholder
|
||||||
|
|
||||||
Value *Val = new ValPHolder(getType(type), oNum);
|
Value *Val = new ValPHolder(getType(type), oNum);
|
||||||
if (insertValue(Val, LateResolveValues) == -1) return 0;
|
ForwardReferences.insert(I, std::make_pair(KeyValue, Val));
|
||||||
return Val;
|
return Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,31 +383,27 @@ void BytecodeParser::materializeFunction(Function* F) {
|
|||||||
ParsedBasicBlocks.clear();
|
ParsedBasicBlocks.clear();
|
||||||
|
|
||||||
|
|
||||||
// Check for unresolvable references
|
// Resolve forward references
|
||||||
while (!LateResolveValues.empty()) {
|
while (!ForwardReferences.empty()) {
|
||||||
ValueList &VL = *LateResolveValues.back();
|
std::map<std::pair<unsigned,unsigned>, Value*>::iterator I = ForwardReferences.begin();
|
||||||
LateResolveValues.pop_back();
|
unsigned type = I->first.first;
|
||||||
|
unsigned Slot = I->first.second;
|
||||||
|
Value *PlaceHolder = I->second;
|
||||||
|
ForwardReferences.erase(I);
|
||||||
|
|
||||||
while (!VL.empty()) {
|
Value *NewVal = getValue(type, Slot, false);
|
||||||
Value *V = VL.back();
|
if (NewVal == 0)
|
||||||
unsigned IDNumber = getValueIDNumberFromPlaceHolder(V);
|
throw std::string("Unresolvable reference found: <" +
|
||||||
VL.pop_back();
|
PlaceHolder->getType()->getDescription() + ">:" +
|
||||||
|
utostr(Slot) + ".");
|
||||||
|
|
||||||
Value *NewVal = getValue(V->getType(), IDNumber, false);
|
// Fixup all of the uses of this placeholder def...
|
||||||
if (NewVal == 0)
|
PlaceHolder->replaceAllUsesWith(NewVal);
|
||||||
throw std::string("Unresolvable reference found: <" +
|
|
||||||
V->getType()->getDescription() + ">:" +
|
|
||||||
utostr(IDNumber) + ".");
|
|
||||||
|
|
||||||
// Fixup all of the uses of this placeholder def...
|
|
||||||
V->replaceAllUsesWith(NewVal);
|
|
||||||
|
|
||||||
// Now that all the uses are gone, delete the placeholder...
|
// Now that all the uses are gone, delete the placeholder...
|
||||||
// If we couldn't find a def (error case), then leak a little
|
// If we couldn't find a def (error case), then leak a little
|
||||||
// memory, because otherwise we can't remove all uses!
|
// memory, because otherwise we can't remove all uses!
|
||||||
delete V;
|
delete PlaceHolder;
|
||||||
}
|
|
||||||
delete &VL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear out function-level types...
|
// Clear out function-level types...
|
||||||
|
@ -57,7 +57,6 @@ public:
|
|||||||
}
|
}
|
||||||
void freeState() {
|
void freeState() {
|
||||||
freeTable(Values);
|
freeTable(Values);
|
||||||
freeTable(LateResolveValues);
|
|
||||||
freeTable(ModuleValues);
|
freeTable(ModuleValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +99,9 @@ private:
|
|||||||
bool hasInternalMarkerOnly; // Only types of linkage are intern/external
|
bool hasInternalMarkerOnly; // Only types of linkage are intern/external
|
||||||
|
|
||||||
typedef std::vector<ValueList*> ValueTable;
|
typedef std::vector<ValueList*> ValueTable;
|
||||||
ValueTable Values, LateResolveValues;
|
ValueTable Values;
|
||||||
ValueTable ModuleValues;
|
ValueTable ModuleValues;
|
||||||
|
std::map<std::pair<unsigned,unsigned>, Value*> ForwardReferences;
|
||||||
|
|
||||||
std::vector<BasicBlock*> ParsedBasicBlocks;
|
std::vector<BasicBlock*> ParsedBasicBlocks;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user