mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Make getGlobalTableValue not use getTypeSlot, this speeds up the bc reader
by 5% on eon llvm-svn: 15452
This commit is contained in:
parent
ee276368a4
commit
21a0243ceb
@ -218,14 +218,10 @@ public:
|
|||||||
<< " is " << Ty->getDescription() << "\n";
|
<< " is " << Ty->getDescription() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void handleCompactionTableValue(
|
virtual void handleCompactionTableValue(unsigned i, unsigned TypSlot,
|
||||||
unsigned i,
|
unsigned ValSlot) {
|
||||||
unsigned TypSlot,
|
|
||||||
unsigned ValSlot,
|
|
||||||
const Type* Ty ) {
|
|
||||||
dump << " Value: " << i << " TypSlot: " << TypSlot
|
dump << " Value: " << i << " TypSlot: " << TypSlot
|
||||||
<< " ValSlot:" << ValSlot << " is " << Ty->getDescription()
|
<< " ValSlot:" << ValSlot << "\n";
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void handleCompactionTableEnd() {
|
virtual void handleCompactionTableEnd() {
|
||||||
|
@ -439,23 +439,31 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
|
|||||||
/// This is just like getValue, but when a compaction table is in use, it
|
/// This is just like getValue, but when a compaction table is in use, it
|
||||||
/// is ignored. Also, no forward references or other fancy features are
|
/// is ignored. Also, no forward references or other fancy features are
|
||||||
/// supported.
|
/// supported.
|
||||||
Value* BytecodeReader::getGlobalTableValue(const Type *Ty, unsigned SlotNo) {
|
Value* BytecodeReader::getGlobalTableValue(unsigned TyID, unsigned SlotNo) {
|
||||||
// FIXME: getTypeSlot is inefficient!
|
if (SlotNo == 0)
|
||||||
unsigned TyID = getGlobalTableTypeSlot(Ty);
|
return Constant::getNullValue(getType(TyID));
|
||||||
|
|
||||||
if (TyID != Type::LabelTyID) {
|
if (!CompactionTypes.empty() && TyID >= Type::FirstDerivedTyID) {
|
||||||
if (SlotNo == 0)
|
TyID -= Type::FirstDerivedTyID;
|
||||||
return Constant::getNullValue(Ty);
|
if (TyID >= CompactionTypes.size())
|
||||||
--SlotNo;
|
error("Type ID out of range for compaction table!");
|
||||||
|
TyID = CompactionTypes[TyID].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--SlotNo;
|
||||||
|
|
||||||
if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 ||
|
if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 ||
|
||||||
SlotNo >= ModuleValues[TyID]->size()) {
|
SlotNo >= ModuleValues[TyID]->size()) {
|
||||||
error("Corrupt compaction table entry!"
|
if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0)
|
||||||
+ utostr(TyID) + ", " + utostr(SlotNo) + ": "
|
error("Corrupt compaction table entry!"
|
||||||
+ utostr(ModuleValues.size()) + ", "
|
+ utostr(TyID) + ", " + utostr(SlotNo) + ": "
|
||||||
+ utohexstr(intptr_t((void*)ModuleValues[TyID])) + ", "
|
+ utostr(ModuleValues.size()));
|
||||||
+ utostr(ModuleValues[TyID]->size()));
|
else
|
||||||
|
error("Corrupt compaction table entry!"
|
||||||
|
+ utostr(TyID) + ", " + utostr(SlotNo) + ": "
|
||||||
|
+ utostr(ModuleValues.size()) + ", "
|
||||||
|
+ utohexstr(intptr_t((void*)ModuleValues[TyID])) + ", "
|
||||||
|
+ utostr(ModuleValues[TyID]->size()));
|
||||||
}
|
}
|
||||||
return ModuleValues[TyID]->getOperand(SlotNo);
|
return ModuleValues[TyID]->getOperand(SlotNo);
|
||||||
}
|
}
|
||||||
@ -1096,30 +1104,27 @@ void BytecodeReader::ParseCompactionTable() {
|
|||||||
if (isTypeType) {
|
if (isTypeType) {
|
||||||
ParseCompactionTypes(NumEntries);
|
ParseCompactionTypes(NumEntries);
|
||||||
} else {
|
} else {
|
||||||
// Make sure we have enough room for the plane
|
// Make sure we have enough room for the plane.
|
||||||
if (Ty >= CompactionValues.size())
|
if (Ty >= CompactionValues.size())
|
||||||
CompactionValues.resize(Ty+1);
|
CompactionValues.resize(Ty+1);
|
||||||
|
|
||||||
// Make sure the plane is empty or we have some kind of error
|
// Make sure the plane is empty or we have some kind of error.
|
||||||
if (!CompactionValues[Ty].empty())
|
if (!CompactionValues[Ty].empty())
|
||||||
error("Compaction table plane contains multiple entries!");
|
error("Compaction table plane contains multiple entries!");
|
||||||
|
|
||||||
// Notify handler about the plane
|
// Notify handler about the plane.
|
||||||
if (Handler) Handler->handleCompactionTablePlane(Ty, NumEntries);
|
if (Handler) Handler->handleCompactionTablePlane(Ty, NumEntries);
|
||||||
|
|
||||||
// Convert the type slot to a type
|
// Push the implicit zero.
|
||||||
const Type *Typ = getType(Ty);
|
CompactionValues[Ty].push_back(Constant::getNullValue(getType(Ty)));
|
||||||
|
|
||||||
// Push the implicit zero
|
|
||||||
CompactionValues[Ty].push_back(Constant::getNullValue(Typ));
|
|
||||||
|
|
||||||
// Read in each of the entries, put them in the compaction table
|
// Read in each of the entries, put them in the compaction table
|
||||||
// and notify the handler that we have a new compaction table value.
|
// and notify the handler that we have a new compaction table value.
|
||||||
for (unsigned i = 0; i != NumEntries; ++i) {
|
for (unsigned i = 0; i != NumEntries; ++i) {
|
||||||
unsigned ValSlot = read_vbr_uint();
|
unsigned ValSlot = read_vbr_uint();
|
||||||
Value *V = getGlobalTableValue(Typ, ValSlot);
|
Value *V = getGlobalTableValue(Ty, ValSlot);
|
||||||
CompactionValues[Ty].push_back(V);
|
CompactionValues[Ty].push_back(V);
|
||||||
if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot, Typ);
|
if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,8 +395,9 @@ private:
|
|||||||
/// @brief Get a value from its typeid and slot number
|
/// @brief Get a value from its typeid and slot number
|
||||||
Value* getValue(unsigned TypeID, unsigned num, bool Create = true);
|
Value* getValue(unsigned TypeID, unsigned num, bool Create = true);
|
||||||
|
|
||||||
/// @brief Get a value from its type and slot number, ignoring compaction tables.
|
/// @brief Get a value from its type and slot number, ignoring compaction
|
||||||
Value *getGlobalTableValue(const Type *Ty, unsigned SlotNo);
|
/// tables.
|
||||||
|
Value *getGlobalTableValue(unsigned TyID, unsigned SlotNo);
|
||||||
|
|
||||||
/// @brief Get a basic block for current function
|
/// @brief Get a basic block for current function
|
||||||
BasicBlock *getBasicBlock(unsigned ID);
|
BasicBlock *getBasicBlock(unsigned ID);
|
||||||
|
Loading…
Reference in New Issue
Block a user