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

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 8 16:52:01 PDT 2003


Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.67 -> 1.68
ReaderInternals.h updated: 1.48 -> 1.49

---
Log message:

Inline the postResolveValues method.  It was poorly named anyway


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

Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.67 llvm/lib/Bytecode/Reader/Reader.cpp:1.68
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.67	Wed Oct  8 16:18:57 2003
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Wed Oct  8 16:51:46 2003
@@ -176,33 +176,6 @@
 }
 
 
-void BytecodeParser::postResolveValues(ValueTable &ValTab) {
-  while (!ValTab.empty()) {
-    ValueList &VL = *ValTab.back();
-    ValTab.pop_back();    
-
-    while (!VL.empty()) {
-      Value *V = VL.back();
-      unsigned IDNumber = getValueIDNumberFromPlaceHolder(V);
-      VL.pop_back();
-
-      Value *NewVal = getValue(V->getType(), IDNumber, false);
-      if (NewVal == 0)
-        throw std::string("Unresolvable reference found: <" +
-                          V->getType()->getDescription() + ">:" + 
-                          utostr(IDNumber) + ".");
-
-      // Fixup all of the uses of this placeholder def...
-      V->replaceAllUsesWith(NewVal);
-      
-      // Now that all the uses are gone, delete the placeholder...
-      // If we couldn't find a def (error case), then leak a little
-      delete V;  // memory, 'cause otherwise we can't remove all uses!
-    }
-    delete &VL;
-  }
-}
-
 std::auto_ptr<BasicBlock>
 BytecodeParser::ParseBasicBlock(const unsigned char *&Buf,
                                 const unsigned char *EndBuf) {
@@ -381,9 +354,31 @@
   }
 
   // Check for unresolvable references
-  postResolveValues(LateResolveValues);
+  while (!LateResolveValues.empty()) {
+    ValueList &VL = *LateResolveValues.back();
+    LateResolveValues.pop_back();    
+
+    while (!VL.empty()) {
+      Value *V = VL.back();
+      unsigned IDNumber = getValueIDNumberFromPlaceHolder(V);
+      VL.pop_back();
+
+      Value *NewVal = getValue(V->getType(), IDNumber, false);
+      if (NewVal == 0)
+        throw std::string("Unresolvable reference found: <" +
+                          V->getType()->getDescription() + ">:" + 
+                          utostr(IDNumber) + ".");
 
-  //ResolveReferencesToValue(F, FunctionSlot);
+      // Fixup all of the uses of this placeholder def...
+      V->replaceAllUsesWith(NewVal);
+      
+      // Now that all the uses are gone, delete the placeholder...
+      // If we couldn't find a def (error case), then leak a little
+      // memory, because otherwise we can't remove all uses!
+      delete V;
+    }
+    delete &VL;
+  }
 
   // Clear out function-level types...
   FunctionTypeValues.clear();


Index: llvm/lib/Bytecode/Reader/ReaderInternals.h
diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.48 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.49
--- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.48	Wed Oct  8 16:18:57 2003
+++ llvm/lib/Bytecode/Reader/ReaderInternals.h	Wed Oct  8 16:51:46 2003
@@ -77,11 +77,9 @@
     std::cerr << "BytecodeParser instance!\n";
   }
 
-private:          // All of this data is transient across calls to ParseBytecode
+private:
   struct ValueList : public User {
-    ValueList() : User(Type::TypeTy, Value::TypeVal) {
-    }
-    ~ValueList() {}
+    ValueList() : User(Type::TypeTy, Value::TypeVal) {}
 
     // vector compatibility methods
     unsigned size() const { return getNumOperands(); }
@@ -185,7 +183,6 @@
 
   int insertValue(Value *V, ValueTable &Table);  // -1 = Failure
   void setValueTo(ValueTable &D, unsigned Slot, Value *V);
-  void postResolveValues(ValueTable &ValTab);
 
   unsigned getTypeSlot(const Type *Ty);
 





More information about the llvm-commits mailing list