Avoid calling getTypeSlot more
authorChris Lattner <sabre@nondot.org>
Mon, 13 Oct 2003 14:34:59 +0000 (14:34 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Oct 2003 14:34:59 +0000 (14:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9077 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/ConstantReader.cpp
lib/Bytecode/Reader/Reader.cpp
lib/Bytecode/Reader/ReaderInternals.h

index 2689362fea6fbd77b7f4679e4764e0646f019d99..71afaf6ea6164be035e2c8a7acbdba3ae286bbf0 100644 (file)
@@ -350,7 +350,7 @@ void BytecodeParser::ParseConstantPool(const unsigned char *&Buf,
         Constant *C = parseConstantValue(Buf, EndBuf, Ty);
         assert(C && "parseConstantValue returned NULL!");
         BCR_TRACE(4, "Read Constant: '" << *C << "'\n");
-        unsigned Slot = insertValue(C, Tab);
+        unsigned Slot = insertValue(C, Typ, Tab);
 
         // If we are reading a function constant table, make sure that we adjust
         // the slot number to be the real global constant number.
index e735564acbd7df4f18ae96cc2370f79be00a6b0f..8713855b271070f4596c1386a49f854be34ed237 100644 (file)
@@ -75,11 +75,15 @@ const Type *BytecodeParser::getType(unsigned ID) {
 }
 
 unsigned BytecodeParser::insertValue(Value *Val, ValueTable &ValueTab) {
+  return insertValue(Val, getTypeSlot(Val->getType()), ValueTab);
+}
+
+unsigned BytecodeParser::insertValue(Value *Val, unsigned type,
+                                     ValueTable &ValueTab) {
   assert((!HasImplicitZeroInitializer || !isa<Constant>(Val) ||
           Val->getType()->isPrimitiveType() ||
           !cast<Constant>(Val)->isNullValue()) &&
          "Cannot read null values from bytecode!");
-  unsigned type = getTypeSlot(Val->getType());
   assert(type != Type::TypeTyID && "Types should never be insertValue'd!");
  
   if (ValueTab.size() <= type) {
@@ -452,7 +456,7 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
     GlobalVariable *GV = new GlobalVariable(ElTy, VarType & 1, Linkage,
                                             0, "", TheModule);
     BCR_TRACE(2, "Global Variable of type: " << *Ty << "\n");
-    ResolveReferencesToValue(GV, insertValue(GV, ModuleValues));
+    ResolveReferencesToValue(GV, insertValue(GV, SlotNo, ModuleValues));
 
     if (VarType & 2) { // Does it have an initializer?
       unsigned InitSlot;
@@ -483,7 +487,7 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
     // Insert the placeholder...
     Function *Func = new Function(cast<FunctionType>(Ty),
                                   GlobalValue::InternalLinkage, "", TheModule);
-    unsigned DestSlot = insertValue(Func, ModuleValues);
+    unsigned DestSlot = insertValue(Func, FnSignature, ModuleValues);
     ResolveReferencesToValue(Func, DestSlot);
 
     // Keep track of this information in a list that is emptied as functions are
index 61e6fa9bd76d56624ac9aa242b5ec5ff6c0b7bde..7f921d7913d2ce58746aa0e78de95e0be4a12fd3 100644 (file)
@@ -170,6 +170,7 @@ private:
   Constant   *getConstantValue(const Type *Ty, unsigned num);
 
   unsigned insertValue(Value *V, ValueTable &Table);
+  unsigned insertValue(Value *V, unsigned Type, ValueTable &Table);
 
   unsigned getTypeSlot(const Type *Ty);