[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Oct 9 15:31:01 PDT 2003
Changes in directory llvm/lib/Bytecode/Reader:
Reader.cpp updated: 1.74 -> 1.75
---
Log message:
Remove potentially N^2 algorithm from symbol table reader. No speedup
in practice though
---
Diffs of the changes: (+13 -5)
Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.74 llvm/lib/Bytecode/Reader/Reader.cpp:1.75
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.74 Thu Oct 9 15:22:47 2003
+++ llvm/lib/Bytecode/Reader/Reader.cpp Thu Oct 9 15:30:04 2003
@@ -219,6 +219,9 @@
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 @@
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.");
More information about the llvm-commits
mailing list