[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu May 5 15:21:36 PDT 2005



Changes in directory llvm/lib/Bytecode/Writer:

SlotCalculator.cpp updated: 1.69 -> 1.70
Writer.cpp updated: 1.97 -> 1.98
---
Log message:

add support for undef values of opaque type, addressing PR541: http://llvm.cs.uiuc.edu/PR541 


---
Diffs of the changes:  (+13 -12)

 SlotCalculator.cpp |   19 ++++++++++---------
 Writer.cpp         |    6 +++---
 2 files changed, 13 insertions(+), 12 deletions(-)


Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.69 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.70
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.69	Thu Apr 21 22:57:48 2005
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp	Thu May  5 17:21:19 2005
@@ -121,8 +121,8 @@
 
   // Add all of the global variables to the value table...
   //
-  for (Module::const_global_iterator I = TheModule->global_begin(), E = TheModule->global_end();
-       I != E; ++I)
+  for (Module::const_global_iterator I = TheModule->global_begin(),
+         E = TheModule->global_end(); I != E; ++I)
     getOrCreateSlot(I);
 
   // Scavenge the types out of the functions, then add the functions themselves
@@ -134,8 +134,8 @@
 
   // Add all of the module level constants used as initializers
   //
-  for (Module::const_global_iterator I = TheModule->global_begin(), E = TheModule->global_end();
-       I != E; ++I)
+  for (Module::const_global_iterator I = TheModule->global_begin(),
+         E = TheModule->global_end(); I != E; ++I)
     if (I->hasInitializer())
       getOrCreateSlot(I->getInitializer());
 
@@ -388,8 +388,8 @@
   SC_DEBUG("end purgeFunction!\n");
 }
 
-static inline bool hasNullValue(unsigned TyID) {
-  return TyID != Type::LabelTyID && TyID != Type::VoidTyID;
+static inline bool hasNullValue(const Type *Ty) {
+  return Ty != Type::LabelTy && Ty != Type::VoidTy && !isa<OpaqueType>(Ty);
 }
 
 /// getOrCreateCompactionTableSlot - This method is used to build up the initial
@@ -413,7 +413,7 @@
 
   // Make sure to insert the null entry if the thing we are inserting is not a
   // null constant.
-  if (TyPlane.empty() && hasNullValue(V->getType()->getTypeID())) {
+  if (TyPlane.empty() && hasNullValue(V->getType())) {
     Value *ZeroInitializer = Constant::getNullValue(V->getType());
     if (V != ZeroInitializer) {
       TyPlane.push_back(ZeroInitializer);
@@ -461,7 +461,8 @@
   }
 
   // Next, include any types used by function arguments.
-  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
+  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
+       I != E; ++I)
     getOrCreateCompactionTableSlot(I->getType());
 
   // Next, find all of the types and values that are referred to by the
@@ -829,7 +830,7 @@
 
   // If this is the first value to get inserted into the type plane, make sure
   // to insert the implicit null value...
-  if (Table[Ty].empty() &&  hasNullValue(Ty)) {
+  if (Table[Ty].empty() && hasNullValue(Typ)) {
     Value *ZeroInitializer = Constant::getNullValue(Typ);
 
     // If we are pushing zeroinit, it will be handled below.


Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.97 llvm/lib/Bytecode/Writer/Writer.cpp:1.98
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.97	Thu Apr 21 16:48:46 2005
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Thu May  5 17:21:19 2005
@@ -843,8 +843,8 @@
   }
 }
 
-static inline bool hasNullValue(unsigned TyID) {
-  return TyID != Type::LabelTyID && TyID != Type::VoidTyID;
+static inline bool hasNullValue(const Type *Ty) {
+  return Ty != Type::LabelTy && Ty != Type::VoidTy && !isa<OpaqueType>(Ty);
 }
 
 void BytecodeWriter::outputConstants(bool isFunction) {
@@ -867,7 +867,7 @@
       if (isFunction)                  // Don't re-emit module constants
         ValNo += Table.getModuleLevel(pno);
 
-      if (hasNullValue(pno)) {
+      if (hasNullValue(Plane[0]->getType())) {
         // Skip zero initializer
         if (ValNo == 0)
           ValNo = 1;






More information about the llvm-commits mailing list