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

Chris Lattner lattner at cs.uiuc.edu
Sat Apr 3 19:52:03 PST 2004


Changes in directory llvm/lib/Bytecode/Reader:

InstructionReader.cpp updated: 1.68 -> 1.69
Reader.cpp updated: 1.104 -> 1.105
ReaderInternals.h updated: 1.77 -> 1.78

---
Log message:

Remove a bunch of cruft that was used to be backwards compatible with the last 
prerelease format for LLVM bytecode files.  Now we only are compatible with 
LLVM 1.0+.


---
Diffs of the changes:  (+24 -93)

Index: llvm/lib/Bytecode/Reader/InstructionReader.cpp
diff -u llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.68 llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.69
--- llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.68	Thu Mar 11 23:51:49 2004
+++ llvm/lib/Bytecode/Reader/InstructionReader.cpp	Sat Apr  3 17:43:42 2004
@@ -124,34 +124,7 @@
     Result = new VAArgInst(getValue(RI.Type, Args[0]), getType(Args[1]));
     break;
   case Instruction::VANext:
-    if (!hasOldStyleVarargs) {
-      Result = new VANextInst(getValue(RI.Type, Args[0]), getType(Args[1]));
-    } else {
-      // In the old-style varargs scheme, this was the "va_arg" instruction.
-      // Emit emulation code now.
-      if (!usesOldStyleVarargs) {
-        usesOldStyleVarargs = true;
-        std::cerr << "WARNING: this bytecode file uses obsolete features.  "
-                  << "Disassemble and assemble to update it.\n";
-      }
-
-      Value *VAListPtr = getValue(RI.Type, Args[0]);
-      const Type *ArgTy = getType(Args[1]);
-
-      // First, load the valist...
-      Instruction *CurVAList = new LoadInst(VAListPtr, "");
-      BB->getInstList().push_back(CurVAList);
-      
-      // Construct the vaarg
-      Result = new VAArgInst(CurVAList, ArgTy);
-      
-      // Now we must advance the pointer and update it in memory.
-      Instruction *TheVANext = new VANextInst(CurVAList, ArgTy);
-      BB->getInstList().push_back(TheVANext);
-      
-      BB->getInstList().push_back(new StoreInst(TheVANext, VAListPtr));
-    }
-
+    Result = new VANextInst(getValue(RI.Type, Args[0]), getType(Args[1]));
     break;
   case Instruction::Cast:
     Result = new CastInst(getValue(RI.Type, Args[0]), getType(Args[1]));
@@ -234,21 +207,17 @@
       if (It != FTy->param_end())
         throw std::string("Invalid call instruction!");
     } else {
-      Args.erase(Args.begin(), Args.begin()+1+hasVarArgCallPadding);
+      Args.erase(Args.begin(), Args.begin()+1);
 
       unsigned FirstVariableOperand;
-      if (!hasVarArgCallPadding) {
-        if (Args.size() < FTy->getNumParams())
-          throw std::string("Call instruction missing operands!");
-
-        // Read all of the fixed arguments
-        for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
-          Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Args[i]));
-
-        FirstVariableOperand = FTy->getNumParams();
-      } else {
-        FirstVariableOperand = 0;
-      }
+      if (Args.size() < FTy->getNumParams())
+        throw std::string("Call instruction missing operands!");
+
+      // Read all of the fixed arguments
+      for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
+        Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Args[i]));
+      
+      FirstVariableOperand = FTy->getNumParams();
 
       if ((Args.size()-FirstVariableOperand) & 1) // Must be pairs of type/value
         throw std::string("Invalid call instruction!");
@@ -286,28 +255,16 @@
       if (It != FTy->param_end())
         throw std::string("Invalid invoke instruction!");
     } else {
-      Args.erase(Args.begin(), Args.begin()+1+hasVarArgCallPadding);
-
-      unsigned FirstVariableArgument;
-      if (!hasVarArgCallPadding) {
-        Normal = getBasicBlock(Args[0]);
-        Except = getBasicBlock(Args[1]);
-
-        FirstVariableArgument = FTy->getNumParams()+2;
-        for (unsigned i = 2; i != FirstVariableArgument; ++i)
-          Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)),
-                                    Args[i]));
-          
-      } else {
-        if (Args.size() < 4) throw std::string("Invalid invoke instruction!");
-        if (Args[0] != Type::LabelTyID || Args[2] != Type::LabelTyID)
-          throw std::string("Invalid invoke instruction!");
-        Normal = getBasicBlock(Args[1]);
-        Except = getBasicBlock(Args[3]);
-
-        FirstVariableArgument = 4;
-      }
+      Args.erase(Args.begin(), Args.begin()+1);
 
+      Normal = getBasicBlock(Args[0]);
+      Except = getBasicBlock(Args[1]);
+      
+      unsigned FirstVariableArgument = FTy->getNumParams()+2;
+      for (unsigned i = 2; i != FirstVariableArgument; ++i)
+        Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)),
+                                  Args[i]));
+      
       if (Args.size()-FirstVariableArgument & 1)  // Must be pairs of type/value
         throw std::string("Invalid invoke instruction!");
 


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.104 llvm/lib/Bytecode/Reader/Reader.cpp:1.105
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.104	Sun Mar 28 18:16:01 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Sat Apr  3 17:43:42 2004
@@ -353,8 +353,7 @@
   GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage;
 
   unsigned LinkageType = read_vbr_uint(Buf, EndBuf);
-  if ((!hasExtendedLinkageSpecs && LinkageType > 3) ||
-      ( hasExtendedLinkageSpecs && LinkageType > 4))
+  if (LinkageType > 4)
     throw std::string("Invalid linkage type for Function.");
   switch (LinkageType) {
   case 0: Linkage = GlobalValue::ExternalLinkage; break;
@@ -553,21 +552,12 @@
   // Read global variables...
   unsigned VarType = read_vbr_uint(Buf, End);
   while (VarType != Type::VoidTyID) { // List is terminated by Void
-    unsigned SlotNo;
+    // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 =
+    // Linkage, bit4+ = slot#
+    unsigned SlotNo = VarType >> 5;
+    unsigned LinkageID = (VarType >> 2) & 7;
     GlobalValue::LinkageTypes Linkage;
 
-    unsigned LinkageID;
-    if (hasExtendedLinkageSpecs) {
-      // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
-      // bit2,3,4 = Linkage, bit4+ = slot#
-      SlotNo = VarType >> 5;
-      LinkageID = (VarType >> 2) & 7;
-    } else {
-      // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
-      // bit2,3 = Linkage, bit4+ = slot#
-      SlotNo = VarType >> 4;
-      LinkageID = (VarType >> 2) & 3;
-    }
     switch (LinkageID) {
     default: assert(0 && "Unknown linkage type!");
     case 0: Linkage = GlobalValue::ExternalLinkage;  break;
@@ -655,20 +645,10 @@
   RevisionNum = Version >> 4;
 
   // Default values for the current bytecode version
-  hasExtendedLinkageSpecs = true;
-  hasOldStyleVarargs = false;
-  hasVarArgCallPadding = false;
   hasInconsistentModuleGlobalInfo = false;
   hasExplicitPrimitiveZeros = false;
 
   switch (RevisionNum) {
-  case 2:               // LLVM pre-1.0 release: will be deleted on the next rev
-    // Version #2 only supported 4 linkage types.  It didn't support weak
-    // linkage.
-    hasExtendedLinkageSpecs = false;
-    hasOldStyleVarargs = true;
-    hasVarArgCallPadding = true;
-    // FALL THROUGH
   case 0:               //  LLVM 1.0, 1.1 release version
     // Compared to rev #2, we added support for weak linkage, a more dense
     // encoding, and better varargs support.
@@ -789,7 +769,6 @@
 
   TheModule = new Module(ModuleID);
   try { 
-    usesOldStyleVarargs = false;
     ParseModule(Buf, EndBuf);
   } catch (std::string &Error) {
     freeState();       // Must destroy handles before deleting module!


Index: llvm/lib/Bytecode/Reader/ReaderInternals.h
diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.77 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.78
--- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.77	Wed Jan 21 16:55:34 2004
+++ llvm/lib/Bytecode/Reader/ReaderInternals.h	Sat Apr  3 17:43:42 2004
@@ -97,11 +97,6 @@
 
   // Information about the module, extracted from the bytecode revision number.
   unsigned char RevisionNum;        // The rev # itself
-  bool hasExtendedLinkageSpecs;     // Supports more than 4 linkage types
-  bool hasOldStyleVarargs;          // Has old version of varargs intrinsics?
-  bool hasVarArgCallPadding;        // Bytecode has extra padding in vararg call
-
-  bool usesOldStyleVarargs;         // Does this module USE old style varargs?
 
   // Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0)
 





More information about the llvm-commits mailing list