mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Do not do a linear std::find to reconstruct information we had, but later threw
away. This speeds up by .bc reader by 30% in a profile build on 252.eon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15450 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -26,7 +26,6 @@
|
|||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
#include "Support/StringExtras.h"
|
#include "Support/StringExtras.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -294,7 +293,7 @@ const Type *BytecodeReader::getType(unsigned ID) {
|
|||||||
if (!CompactionTypes.empty()) {
|
if (!CompactionTypes.empty()) {
|
||||||
if (ID >= CompactionTypes.size())
|
if (ID >= CompactionTypes.size())
|
||||||
error("Type ID out of range for compaction table!");
|
error("Type ID out of range for compaction table!");
|
||||||
return CompactionTypes[ID];
|
return CompactionTypes[ID].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it a module-level type?
|
// Is it a module-level type?
|
||||||
@@ -337,12 +336,11 @@ unsigned BytecodeReader::getTypeSlot(const Type *Ty) {
|
|||||||
|
|
||||||
// Scan the compaction table for the type if needed.
|
// Scan the compaction table for the type if needed.
|
||||||
if (!CompactionTypes.empty()) {
|
if (!CompactionTypes.empty()) {
|
||||||
std::vector<const Type*>::const_iterator I =
|
for (unsigned i = 0, e = CompactionTypes.size(); i != e; ++i)
|
||||||
find(CompactionTypes.begin(), CompactionTypes.end(), Ty);
|
if (CompactionTypes[i].first == Ty)
|
||||||
|
return Type::FirstDerivedTyID + i;
|
||||||
|
|
||||||
if (I == CompactionTypes.end())
|
error("Couldn't find type specified in compaction table!");
|
||||||
error("Couldn't find type specified in compaction table!");
|
|
||||||
return Type::FirstDerivedTyID + (&*I - &CompactionTypes[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the function level types first...
|
// Check the function level types first...
|
||||||
@@ -403,15 +401,10 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
|
|||||||
// By default, the global type id is the type id passed in
|
// By default, the global type id is the type id passed in
|
||||||
unsigned GlobalTyID = type;
|
unsigned GlobalTyID = type;
|
||||||
|
|
||||||
// If the type plane was compactified, figure out the global type ID
|
// If the type plane was compactified, figure out the global type ID by
|
||||||
// by adding the derived type ids and the distance.
|
// adding the derived type ids and the distance.
|
||||||
if (!CompactionTypes.empty() && type >= Type::FirstDerivedTyID) {
|
if (!CompactionTypes.empty() && type >= Type::FirstDerivedTyID)
|
||||||
const Type *Ty = CompactionTypes[type-Type::FirstDerivedTyID];
|
GlobalTyID = CompactionTypes[type-Type::FirstDerivedTyID].second;
|
||||||
TypeListTy::iterator I =
|
|
||||||
find(ModuleTypes.begin(), ModuleTypes.end(), Ty);
|
|
||||||
assert(I != ModuleTypes.end());
|
|
||||||
GlobalTyID = Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasImplicitNull(GlobalTyID)) {
|
if (hasImplicitNull(GlobalTyID)) {
|
||||||
if (Num == 0)
|
if (Num == 0)
|
||||||
@@ -1053,7 +1046,7 @@ void BytecodeReader::ParseCompactionTypes(unsigned NumEntries) {
|
|||||||
if (read_typeid(TypeSlot))
|
if (read_typeid(TypeSlot))
|
||||||
error("Invalid type in compaction table: type type");
|
error("Invalid type in compaction table: type type");
|
||||||
const Type *Typ = getGlobalTableType(TypeSlot);
|
const Type *Typ = getGlobalTableType(TypeSlot);
|
||||||
CompactionTypes.push_back(Typ);
|
CompactionTypes.push_back(std::make_pair(Typ, TypeSlot));
|
||||||
if (Handler) Handler->handleCompactionTableType(i, TypeSlot, Typ);
|
if (Handler) Handler->handleCompactionTableType(i, TypeSlot, Typ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -193,7 +193,7 @@ protected:
|
|||||||
void ParseFunctionBody(Function* Func);
|
void ParseFunctionBody(Function* Func);
|
||||||
|
|
||||||
/// @brief Parse the type list portion of a compaction table
|
/// @brief Parse the type list portion of a compaction table
|
||||||
void BytecodeReader::ParseCompactionTypes( unsigned NumEntries );
|
void ParseCompactionTypes(unsigned NumEntries);
|
||||||
|
|
||||||
/// @brief Parse a compaction table
|
/// @brief Parse a compaction table
|
||||||
void ParseCompactionTable();
|
void ParseCompactionTable();
|
||||||
@@ -243,12 +243,13 @@ private:
|
|||||||
BufPtr At; ///< Where we're currently parsing at
|
BufPtr At; ///< Where we're currently parsing at
|
||||||
|
|
||||||
/// Information about the module, extracted from the bytecode revision number.
|
/// Information about the module, extracted from the bytecode revision number.
|
||||||
|
///
|
||||||
unsigned char RevisionNum; // The rev # itself
|
unsigned char RevisionNum; // The rev # itself
|
||||||
|
|
||||||
/// Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0)
|
/// Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0)
|
||||||
|
|
||||||
/// Revision #0 had an explicit alignment of data only for the ModuleGlobalInfo
|
/// Revision #0 had an explicit alignment of data only for the
|
||||||
/// block. This was fixed to be like all other blocks in 1.2
|
/// ModuleGlobalInfo block. This was fixed to be like all other blocks in 1.2
|
||||||
bool hasInconsistentModuleGlobalInfo;
|
bool hasInconsistentModuleGlobalInfo;
|
||||||
|
|
||||||
/// Revision #0 also explicitly encoded zero values for primitive types like
|
/// Revision #0 also explicitly encoded zero values for primitive types like
|
||||||
@@ -270,12 +271,12 @@ private:
|
|||||||
bool hasTypeDerivedFromValue;
|
bool hasTypeDerivedFromValue;
|
||||||
|
|
||||||
/// LLVM 1.2 and earlier encoded block headers as two uint (8 bytes), one for
|
/// LLVM 1.2 and earlier encoded block headers as two uint (8 bytes), one for
|
||||||
/// the size and one for the type. This is a bit wasteful, especially for small
|
/// the size and one for the type. This is a bit wasteful, especially for
|
||||||
/// files where the 8 bytes per block is a large fraction of the total block
|
/// small files where the 8 bytes per block is a large fraction of the total
|
||||||
/// size. In LLVM 1.3, the block type and length are encoded into a single
|
/// block size. In LLVM 1.3, the block type and length are encoded into a
|
||||||
/// uint32 by restricting the number of block types (limit 31) and the maximum
|
/// single uint32 by restricting the number of block types (limit 31) and the
|
||||||
/// size of a block (limit 2^27-1=134,217,727). Note that the module block
|
/// maximum size of a block (limit 2^27-1=134,217,727). Note that the module
|
||||||
/// still uses the 8-byte format so the maximum size of a file can be
|
/// block still uses the 8-byte format so the maximum size of a file can be
|
||||||
/// 2^32-1 bytes long.
|
/// 2^32-1 bytes long.
|
||||||
bool hasLongBlockHeaders;
|
bool hasLongBlockHeaders;
|
||||||
|
|
||||||
@@ -295,9 +296,10 @@ private:
|
|||||||
/// LLVM 1.2 and earlier encoded the file version as part of the module block
|
/// LLVM 1.2 and earlier encoded the file version as part of the module block
|
||||||
/// but this information may be needed to
|
/// but this information may be needed to
|
||||||
|
|
||||||
/// CompactionTable - If a compaction table is active in the current function,
|
/// CompactionTypes - If a compaction table is active in the current function,
|
||||||
/// this is the mapping that it contains.
|
/// this is the mapping that it contains. We keep track of what resolved type
|
||||||
std::vector<const Type*> CompactionTypes;
|
/// it is as well as what global type entry it is.
|
||||||
|
std::vector<std::pair<const Type*, unsigned> > CompactionTypes;
|
||||||
|
|
||||||
/// @brief If a compaction table is active in the current function,
|
/// @brief If a compaction table is active in the current function,
|
||||||
/// this is the mapping that it contains.
|
/// this is the mapping that it contains.
|
||||||
|
Reference in New Issue
Block a user