[llvm-branch-commits] [llvm-branch] r134600 - /llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp

Chris Lattner sabre at nondot.org
Wed Jul 6 22:20:36 PDT 2011


Author: lattner
Date: Thu Jul  7 00:20:36 2011
New Revision: 134600

URL: http://llvm.org/viewvc/llvm-project?rev=134600&view=rev
Log:
don't count a forward ref of a struct type to be a definition of the struct type.

This fixes reading an LLVM 2.9 bc file of Olden/tsp.

Modified:
    llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134600&r1=134599&r2=134600&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp Thu Jul  7 00:20:36 2011
@@ -796,6 +796,16 @@
         ResultTy = StructType::createNamed(Context, "");
       break;
     case bitc::TYPE_CODE_STRUCT_OLD: {// STRUCT_OLD
+      if (NextTypeID >= TypeList.size()) break;
+      // If we already read it, don't reprocess.
+      if (TypeList[NextTypeID] &&
+          !cast<StructType>(TypeList[NextTypeID])->isOpaque())
+        break;
+
+      // Set a type.
+      if (TypeList[NextTypeID] == 0)
+        TypeList[NextTypeID] = StructType::createNamed(Context, "");
+
       std::vector<Type*> EltTys;
       for (unsigned i = 1, e = Record.size(); i != e; ++i) {
         if (Type *Elt = getTypeByIDOrNull(Record[i]))
@@ -803,19 +813,13 @@
         else
           break;
       }
+
+      if (EltTys.size() != Record.size()-1)
+        break;      // Not all elements are ready.
       
-      if (NextTypeID >= TypeList.size()) break;
-      
-      if (EltTys.size() != Record.size()-1) {
-        if (TypeList[NextTypeID] == 0)
-          ResultTy = StructType::createNamed(Context, "");
-        break;
-      }
-      
-      if (TypeList[NextTypeID] == 0)
-        ResultTy = StructType::createNamed(Context, "", EltTys, Record[0]);
-      else if (cast<StructType>(TypeList[NextTypeID])->isOpaque())
-        cast<StructType>(TypeList[NextTypeID])->setBody(EltTys, Record[0]);
+      cast<StructType>(TypeList[NextTypeID])->setBody(EltTys, Record[0]);
+      ResultTy = TypeList[NextTypeID];
+      TypeList[NextTypeID] = 0;
       break;
     }
     case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or





More information about the llvm-branch-commits mailing list