mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-09 22:13:07 +00:00
Remove potentially N^2 algorithm from symbol table reader. No speedup
in practice though git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8985 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
927b185c17
commit
9073613d0c
@ -219,6 +219,9 @@ void BytecodeParser::ParseSymbolTable(const unsigned char *&Buf,
|
||||
BCR_TRACE(3, "Plane Type: '" << *Ty << "' with " << NumEntries <<
|
||||
" entries\n");
|
||||
|
||||
Function::iterator BlockIterator;
|
||||
unsigned CurBlockIteratorIdx = ~0;
|
||||
|
||||
for (unsigned i = 0; i < NumEntries; ++i) {
|
||||
// Symtab entry: [def slot #][name]
|
||||
unsigned slot;
|
||||
@ -231,12 +234,17 @@ void BytecodeParser::ParseSymbolTable(const unsigned char *&Buf,
|
||||
if (Typ == Type::TypeTyID)
|
||||
V = (Value*)getType(slot);
|
||||
else if (Typ == Type::LabelTyID) {
|
||||
if (CurrentFunction) {
|
||||
// FIXME: THIS IS N^2!!!
|
||||
Function::iterator BlockIterator = CurrentFunction->begin();
|
||||
std::advance(BlockIterator, slot);
|
||||
V = BlockIterator;
|
||||
if (!CurrentFunction)
|
||||
throw std::string("Basic blocks don't exist at global scope!");
|
||||
|
||||
if (slot < CurBlockIteratorIdx) {
|
||||
CurBlockIteratorIdx = 0;
|
||||
BlockIterator = CurrentFunction->begin();
|
||||
}
|
||||
|
||||
std::advance(BlockIterator, slot-CurBlockIteratorIdx);
|
||||
CurBlockIteratorIdx = slot;
|
||||
V = BlockIterator;
|
||||
} else
|
||||
V = getValue(Typ, slot, false); // Find mapping...
|
||||
if (V == 0) throw std::string("Failed value look-up.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user