[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Reader.cpp Reader.h

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 3 17:19:34 PDT 2004



Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.11 -> 1.12
Reader.cpp updated: 1.121 -> 1.122
Reader.h updated: 1.10 -> 1.11
---
Log message:

Make getGlobalTableValue not use getTypeSlot, this speeds up the bc reader
by 5% on eon


---
Diffs of the changes:  (+34 -32)

Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.11 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.12
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.11	Sat Jul 17 19:10:36 2004
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp	Tue Aug  3 19:19:23 2004
@@ -218,14 +218,10 @@
               << " is " << Ty->getDescription() << "\n"; 
   }
 
-  virtual void handleCompactionTableValue( 
-    unsigned i, 
-    unsigned TypSlot,
-    unsigned ValSlot, 
-    const Type* Ty ) { 
+  virtual void handleCompactionTableValue(unsigned i, unsigned TypSlot,
+                                          unsigned ValSlot) { 
     dump << "          Value: " << i << " TypSlot: " << TypSlot 
-         << " ValSlot:" << ValSlot << " is " << Ty->getDescription() 
-         << "\n";
+         << " ValSlot:" << ValSlot << "\n";
   }
 
   virtual void handleCompactionTableEnd() { 


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.121 llvm/lib/Bytecode/Reader/Reader.cpp:1.122
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.121	Tue Aug  3 18:41:28 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Tue Aug  3 19:19:23 2004
@@ -439,23 +439,31 @@
 /// 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 
 /// supported.
-Value* BytecodeReader::getGlobalTableValue(const Type *Ty, unsigned SlotNo) {
-  // FIXME: getTypeSlot is inefficient!
-  unsigned TyID = getGlobalTableTypeSlot(Ty);
-  
-  if (TyID != Type::LabelTyID) {
-    if (SlotNo == 0)
-      return Constant::getNullValue(Ty);
-    --SlotNo;
+Value* BytecodeReader::getGlobalTableValue(unsigned TyID, unsigned SlotNo) {
+  if (SlotNo == 0)
+    return Constant::getNullValue(getType(TyID));
+
+  if (!CompactionTypes.empty() && TyID >= Type::FirstDerivedTyID) {
+    TyID -= Type::FirstDerivedTyID;
+    if (TyID >= CompactionTypes.size())
+      error("Type ID out of range for compaction table!");
+    TyID = CompactionTypes[TyID].second;
   }
 
+  --SlotNo;
+
   if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 ||
       SlotNo >= ModuleValues[TyID]->size()) {
-    error("Corrupt compaction table entry!"
-        + utostr(TyID) + ", " + utostr(SlotNo) + ": " 
-        + utostr(ModuleValues.size()) + ", "
-        + utohexstr(intptr_t((void*)ModuleValues[TyID])) + ", "
-        + utostr(ModuleValues[TyID]->size()));
+    if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0)
+      error("Corrupt compaction table entry!"
+            + utostr(TyID) + ", " + utostr(SlotNo) + ": " 
+            + utostr(ModuleValues.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);
 }
@@ -1096,30 +1104,27 @@
     if (isTypeType) {
       ParseCompactionTypes(NumEntries);
     } else {
-      // Make sure we have enough room  for the plane 
+      // Make sure we have enough room for the plane.
       if (Ty >= CompactionValues.size())
         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())
         error("Compaction table plane contains multiple entries!");
 
-      // Notify handler about the plane
+      // Notify handler about the plane.
       if (Handler) Handler->handleCompactionTablePlane(Ty, NumEntries);
 
-      // Convert the type slot to a type
-      const Type *Typ = getType(Ty);
-
-      // Push the implicit zero
-      CompactionValues[Ty].push_back(Constant::getNullValue(Typ));
+      // Push the implicit zero.
+      CompactionValues[Ty].push_back(Constant::getNullValue(getType(Ty)));
 
       // Read in each of the entries, put them in the compaction table
       // and notify the handler that we have a new compaction table value.
       for (unsigned i = 0; i != NumEntries; ++i) {
         unsigned ValSlot = read_vbr_uint();
-        Value *V = getGlobalTableValue(Typ, ValSlot);
+        Value *V = getGlobalTableValue(Ty, ValSlot);
         CompactionValues[Ty].push_back(V);
-        if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot, Typ);
+        if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot);
       }
     }
   }


Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.10 llvm/lib/Bytecode/Reader/Reader.h:1.11
--- llvm/lib/Bytecode/Reader/Reader.h:1.10	Tue Aug  3 18:41:28 2004
+++ llvm/lib/Bytecode/Reader/Reader.h	Tue Aug  3 19:19:23 2004
@@ -395,8 +395,9 @@
   /// @brief Get a value from its typeid and slot number
   Value* getValue(unsigned TypeID, unsigned num, bool Create = true);
 
-  /// @brief Get a value from its type and slot number, ignoring compaction tables.
-  Value *getGlobalTableValue(const Type *Ty, unsigned SlotNo);
+  /// @brief Get a value from its type and slot number, ignoring compaction
+  /// tables.
+  Value *getGlobalTableValue(unsigned TyID, unsigned SlotNo);
 
   /// @brief Get a basic block for current function
   BasicBlock *getBasicBlock(unsigned ID);






More information about the llvm-commits mailing list