Convert to SymbolTable's new iteration interface.
authorReid Spencer <rspencer@reidspencer.com>
Tue, 25 May 2004 08:53:40 +0000 (08:53 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Tue, 25 May 2004 08:53:40 +0000 (08:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13754 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Writer/SlotCalculator.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp
lib/Transforms/IPO/DeadTypeElimination.cpp
lib/Transforms/IPO/MutateStructTypes.cpp
lib/Transforms/Utils/CloneModule.cpp
lib/VMCore/AsmWriter.cpp
lib/VMCore/SlotCalculator.cpp
tools/bugpoint/CrashDebugger.cpp

index 354905327955bc1f4c2b8ac3fcb4189c28b68300..ec5a837cf901f7a74e6986b5a680bf8c1df09f0e 100644 (file)
@@ -248,18 +248,32 @@ void SlotCalculator::processModule() {
 // into the values table...
 //
 void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
-  for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I)
-    for (SymbolTable::type_const_iterator TI = I->second.begin(), 
-          TE = I->second.end(); TI != TE; ++TI)
-      getOrCreateSlot(TI->second);
+  // Do the types first.
+  for (SymbolTable::type_const_iterator TI = ST->type_begin(),
+       TE = ST->type_end(); TI != TE; ++TI )
+    getOrCreateSlot(TI->second);
+
+  // Now do the values.
+  for (SymbolTable::plane_const_iterator PI = ST->plane_begin(), 
+       PE = ST->plane_end(); PI != PE; ++PI)
+    for (SymbolTable::value_const_iterator VI = PI->second.begin(),
+          VE = PI->second.end(); VI != VE; ++VI)
+      getOrCreateSlot(VI->second);
 }
 
 void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
-  for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I)
-    for (SymbolTable::type_const_iterator TI = I->second.begin(), 
-          TE = I->second.end(); TI != TE; ++TI)
-      if (isa<Constant>(TI->second) || isa<Type>(TI->second))
-       getOrCreateSlot(TI->second);
+  // Do the types first
+  for (SymbolTable::type_const_iterator TI = ST->type_begin(),
+       TE = ST->type_end(); TI != TE; ++TI )
+    getOrCreateSlot(TI->second);
+
+  // Now do the constant values in all planes
+  for (SymbolTable::plane_const_iterator PI = ST->plane_begin(), 
+       PE = ST->plane_end(); PI != PE; ++PI)
+    for (SymbolTable::value_const_iterator VI = PI->second.begin(),
+          VE = PI->second.end(); VI != VE; ++VI)
+      if (isa<Constant>(VI->second))
+       getOrCreateSlot(VI->second);
 }
 
 
@@ -452,13 +466,19 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
       getOrCreateCompactionTableSlot(VAN->getArgType());
   }
 
+  // Do the types in the symbol table
   const SymbolTable &ST = F->getSymbolTable();
-  for (SymbolTable::const_iterator I = ST.begin(), E = ST.end(); I != E; ++I)
-    for (SymbolTable::type_const_iterator TI = I->second.begin(), 
-          TE = I->second.end(); TI != TE; ++TI)
-      if (isa<Constant>(TI->second) || isa<Type>(TI->second) ||
-          isa<GlobalValue>(TI->second))
-       getOrCreateCompactionTableSlot(TI->second);
+  for (SymbolTable::type_const_iterator TI = ST.type_begin(),
+       TE = ST.type_end(); TI != TE; ++TI)
+    getOrCreateCompactionTableSlot(TI->second);
+
+  // Now do the constants and global values
+  for (SymbolTable::plane_const_iterator PI = ST.plane_begin(), 
+       PE = ST.plane_end(); PI != PE; ++PI)
+    for (SymbolTable::value_const_iterator VI = PI->second.begin(),
+          VE = PI->second.end(); VI != VE; ++VI)
+      if (isa<Constant>(VI->second) || isa<GlobalValue>(VI->second))
+       getOrCreateCompactionTableSlot(VI->second);
 
   // Now that we have all of the values in the table, and know what types are
   // referenced, make sure that there is at least the zero initializer in any
index 222fc82d197286159408917f0bc51a8992e878b3..dd133c9cbf973908e84d671054677a4eda82a711 100644 (file)
@@ -219,19 +219,18 @@ bool CBackendNameAllUsedStructs::run(Module &M) {
   // already named, and removing names for structure types that are not used.
   //
   SymbolTable &MST = M.getSymbolTable();
-  if (MST.find(Type::TypeTy) != MST.end())
-    for (SymbolTable::type_iterator I = MST.type_begin(Type::TypeTy),
-           E = MST.type_end(Type::TypeTy); I != E; ) {
-      SymbolTable::type_iterator It = I++;
-      if (StructType *STy = dyn_cast<StructType>(It->second)) {
-        // If this is not used, remove it from the symbol table.
-        std::set<const Type *>::iterator UTI = UT.find(STy);
-        if (UTI == UT.end())
-          MST.remove(It->first, It->second);
-        else
-          UT.erase(UTI);
-      }
+  for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
+       TI != TE; ) {
+    SymbolTable::type_iterator I = TI++;
+    if (StructType *STy = dyn_cast<StructType>(I->second)) {
+      // If this is not used, remove it from the symbol table.
+      std::set<const Type *>::iterator UTI = UT.find(STy);
+      if (UTI == UT.end())
+        MST.remove(I->first, I->second);
+      else
+        UT.erase(UTI);
     }
+  }
 
   // UT now contains types that are not named.  Loop over it, naming
   // structure types.
@@ -291,7 +290,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
     }
     if (MTy->isVarArg()) {
       if (MTy->getNumParams()) 
-       FunctionInnards << ", ...";
+        FunctionInnards << ", ...";
     } else if (!MTy->getNumParams()) {
       FunctionInnards << "void";
     }
@@ -865,12 +864,12 @@ void CWriter::printFloatingPointConstants(Function &F) {
 ///
 void CWriter::printModuleTypes(const SymbolTable &ST) {
   // If there are no type names, exit early.
-  if (ST.find(Type::TypeTy) == ST.end())
+  if ( ! ST.hasTypes() )
     return;
 
   // We are only interested in the type plane of the symbol table...
-  SymbolTable::type_const_iterator I   = ST.type_begin(Type::TypeTy);
-  SymbolTable::type_const_iterator End = ST.type_end(Type::TypeTy);
+  SymbolTable::type_const_iterator I   = ST.type_begin();
+  SymbolTable::type_const_iterator End = ST.type_end();
   
   // Print out forward declarations for structure types before anything else!
   Out << "/* Structure forward decls */\n";
@@ -885,7 +884,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
 
   // Now we can print out typedefs...
   Out << "/* Typedefs */\n";
-  for (I = ST.type_begin(Type::TypeTy); I != End; ++I) {
+  for (I = ST.type_begin(); I != End; ++I) {
     const Type *Ty = cast<Type>(I->second);
     std::string Name = "l_" + Mangler::makeNameProper(I->first);
     Out << "typedef ";
@@ -902,7 +901,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
   // printed in the correct order.
   //
   Out << "/* Structure contents */\n";
-  for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
+  for (I = ST.type_begin(); I != End; ++I)
     if (const StructType *STy = dyn_cast<StructType>(I->second))
       // Only print out used types!
       printContainedStructs(STy, StructPrinted);
@@ -969,7 +968,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
   } else {
     // Loop over the arguments, printing them...
     for (FunctionType::param_iterator I = FT->param_begin(),
-          E = FT->param_end(); I != E; ++I) {
+           E = FT->param_end(); I != E; ++I) {
       if (I != FT->param_begin()) FunctionInnards << ", ";
       printType(FunctionInnards, *I);
     }
@@ -1510,3 +1509,5 @@ TargetMachine *llvm::allocateCTargetMachine(const Module &M,
                                             IntrinsicLowering *IL) {
   return new CTargetMachine(M, IL);
 }
+
+// vim: sw=2
index 222fc82d197286159408917f0bc51a8992e878b3..dd133c9cbf973908e84d671054677a4eda82a711 100644 (file)
@@ -219,19 +219,18 @@ bool CBackendNameAllUsedStructs::run(Module &M) {
   // already named, and removing names for structure types that are not used.
   //
   SymbolTable &MST = M.getSymbolTable();
-  if (MST.find(Type::TypeTy) != MST.end())
-    for (SymbolTable::type_iterator I = MST.type_begin(Type::TypeTy),
-           E = MST.type_end(Type::TypeTy); I != E; ) {
-      SymbolTable::type_iterator It = I++;
-      if (StructType *STy = dyn_cast<StructType>(It->second)) {
-        // If this is not used, remove it from the symbol table.
-        std::set<const Type *>::iterator UTI = UT.find(STy);
-        if (UTI == UT.end())
-          MST.remove(It->first, It->second);
-        else
-          UT.erase(UTI);
-      }
+  for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
+       TI != TE; ) {
+    SymbolTable::type_iterator I = TI++;
+    if (StructType *STy = dyn_cast<StructType>(I->second)) {
+      // If this is not used, remove it from the symbol table.
+      std::set<const Type *>::iterator UTI = UT.find(STy);
+      if (UTI == UT.end())
+        MST.remove(I->first, I->second);
+      else
+        UT.erase(UTI);
     }
+  }
 
   // UT now contains types that are not named.  Loop over it, naming
   // structure types.
@@ -291,7 +290,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
     }
     if (MTy->isVarArg()) {
       if (MTy->getNumParams()) 
-       FunctionInnards << ", ...";
+        FunctionInnards << ", ...";
     } else if (!MTy->getNumParams()) {
       FunctionInnards << "void";
     }
@@ -865,12 +864,12 @@ void CWriter::printFloatingPointConstants(Function &F) {
 ///
 void CWriter::printModuleTypes(const SymbolTable &ST) {
   // If there are no type names, exit early.
-  if (ST.find(Type::TypeTy) == ST.end())
+  if ( ! ST.hasTypes() )
     return;
 
   // We are only interested in the type plane of the symbol table...
-  SymbolTable::type_const_iterator I   = ST.type_begin(Type::TypeTy);
-  SymbolTable::type_const_iterator End = ST.type_end(Type::TypeTy);
+  SymbolTable::type_const_iterator I   = ST.type_begin();
+  SymbolTable::type_const_iterator End = ST.type_end();
   
   // Print out forward declarations for structure types before anything else!
   Out << "/* Structure forward decls */\n";
@@ -885,7 +884,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
 
   // Now we can print out typedefs...
   Out << "/* Typedefs */\n";
-  for (I = ST.type_begin(Type::TypeTy); I != End; ++I) {
+  for (I = ST.type_begin(); I != End; ++I) {
     const Type *Ty = cast<Type>(I->second);
     std::string Name = "l_" + Mangler::makeNameProper(I->first);
     Out << "typedef ";
@@ -902,7 +901,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
   // printed in the correct order.
   //
   Out << "/* Structure contents */\n";
-  for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
+  for (I = ST.type_begin(); I != End; ++I)
     if (const StructType *STy = dyn_cast<StructType>(I->second))
       // Only print out used types!
       printContainedStructs(STy, StructPrinted);
@@ -969,7 +968,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
   } else {
     // Loop over the arguments, printing them...
     for (FunctionType::param_iterator I = FT->param_begin(),
-          E = FT->param_end(); I != E; ++I) {
+           E = FT->param_end(); I != E; ++I) {
       if (I != FT->param_begin()) FunctionInnards << ", ";
       printType(FunctionInnards, *I);
     }
@@ -1510,3 +1509,5 @@ TargetMachine *llvm::allocateCTargetMachine(const Module &M,
                                             IntrinsicLowering *IL) {
   return new CTargetMachine(M, IL);
 }
+
+// vim: sw=2
index c3a9f6edc5be46abd63c765c77b170733d09363e..28e5dca9f0b4253b5c962dcdeddbcbfbcd6e8728 100644 (file)
@@ -74,25 +74,24 @@ bool DTE::run(Module &M) {
   // Check the symbol table for superfluous type entries...
   //
   // Grab the 'type' plane of the module symbol...
-  SymbolTable::iterator STI = ST.find(Type::TypeTy);
-  if (STI != ST.end()) {
-    // Loop over all entries in the type plane...
-    SymbolTable::VarMap &Plane = STI->second;
-    for (SymbolTable::VarMap::iterator PI = Plane.begin(); PI != Plane.end();) {
-      // If this entry should be unconditionally removed, or if we detect that
-      // the type is not used, remove it.
-      const Type *RHS = cast<Type>(PI->second);
-      if (ShouldNukeSymtabEntry(RHS) || !UsedTypes.count(RHS)) {
-        Plane.erase(PI++);
-        ++NumKilled;
-        Changed = true;
-      } else {
-        ++PI;
-        // We only need to leave one name for each type.
-        UsedTypes.erase(RHS);
-      }
+  SymbolTable::type_iterator TI = ST.type_begin();
+  while ( TI != ST.type_end() ) {
+    // If this entry should be unconditionally removed, or if we detect that
+    // the type is not used, remove it.
+    const Type *RHS = TI->second;
+    if (ShouldNukeSymtabEntry(RHS) || !UsedTypes.count(RHS)) {
+      SymbolTable::type_iterator ToRemove = TI++;
+      ST.remove(TI->second);
+      ++NumKilled;
+      Changed = true;
+    } else {
+      ++TI;
+      // We only need to leave one name for each type.
+      UsedTypes.erase(RHS);
     }
   }
 
   return Changed;
 }
+
+// vim: sw=2
index ad18bae42a56d0f8333a9fa82362d75ce2c738c3..38f9445218c32bf1361b30f4108900e29a30800e 100644 (file)
@@ -269,16 +269,13 @@ void MutateStructTypes::processGlobals(Module &M) {
   // Remap the symbol table to refer to the types in a nice way
   //
   SymbolTable &ST = M.getSymbolTable();
-  SymbolTable::iterator I = ST.find(Type::TypeTy);
-  if (I != ST.end()) {    // Get the type plane for Type's
-    SymbolTable::VarMap &Plane = I->second;
-    for (SymbolTable::type_iterator TI = Plane.begin(), TE = Plane.end();
-         TI != TE; ++TI) {
-      // FIXME: This is gross, I'm reaching right into a symbol table and
-      // mucking around with it's internals... but oh well.
-      //
-      TI->second = (Value*)cast<Type>(ConvertType(cast<Type>(TI->second)));
-    }
+  SymbolTable::type_iterator TI = ST.type_begin();
+  SymbolTable::type_iterator TE = ST.type_end();
+  for ( ; TI != TE; ++TI ) {
+    // FIXME: This is gross, I'm reaching right into a symbol table and
+    // mucking around with it's internals... but oh well.
+    //
+    TI->second = const_cast<Type*>(ConvertType(TI->second));
   }
 }
 
@@ -495,3 +492,4 @@ bool MutateStructTypes::run(Module &M) {
   return true;
 }
 
+// vim: sw=2
index f8ee99b30699b5f5562a544592273fe677deb198..d98848aa7c251aa9f775ab3d4d6b813bbea86d9a 100644 (file)
@@ -33,11 +33,11 @@ Module *llvm::CloneModule(const Module *M) {
 
   // Copy all of the type symbol table entries over...
   const SymbolTable &SymTab = M->getSymbolTable();
-  SymbolTable::const_iterator TypeI = SymTab.find(Type::TypeTy);
-  if (TypeI != SymTab.end())
-    for (SymbolTable::VarMap::const_iterator I = TypeI->second.begin(),
-           E = TypeI->second.end(); I != E; ++I)
-      New->addTypeName(I->first, cast<Type>(I->second));
+  SymbolTable::type_const_iterator TypeI = SymTab.type_begin();
+  SymbolTable::type_const_iterator TypeE = SymTab.type_end();
+  for ( ; TypeI != TypeE; ++TypeI ) {
+    New->addTypeName(TypeI->first, TypeI->second);
+  }
 
   // Create the value map that maps things from the old module over to the new
   // module.
@@ -89,3 +89,5 @@ Module *llvm::CloneModule(const Module *M) {
 
   return New;
 }
+
+// vim: sw=2
index 533274a6d837cca21727697ce05c35fd44a52324..bb30570395a9afc86030f6c76a6749518e54a69b 100644 (file)
@@ -105,19 +105,16 @@ static void fillTypeNameTable(const Module *M,
                               std::map<const Type *, std::string> &TypeNames) {
   if (!M) return;
   const SymbolTable &ST = M->getSymbolTable();
-  SymbolTable::const_iterator PI = ST.find(Type::TypeTy);
-  if (PI != ST.end()) {
-    SymbolTable::type_const_iterator I = PI->second.begin();
-    for (; I != PI->second.end(); ++I) {
-      // As a heuristic, don't insert pointer to primitive types, because
-      // they are used too often to have a single useful name.
-      //
-      const Type *Ty = cast<Type>(I->second);
-      if (!isa<PointerType>(Ty) ||
-          !cast<PointerType>(Ty)->getElementType()->isPrimitiveType() ||
-          isa<OpaqueType>(cast<PointerType>(Ty)->getElementType()))
-        TypeNames.insert(std::make_pair(Ty, getLLVMName(I->first)));
-    }
+  SymbolTable::type_const_iterator TI = ST.type_begin();
+  for (; TI != ST.type_end(); ++TI ) {
+    // As a heuristic, don't insert pointer to primitive types, because
+    // they are used too often to have a single useful name.
+    //
+    const Type *Ty = cast<Type>(TI->second);
+    if (!isa<PointerType>(Ty) ||
+       !cast<PointerType>(Ty)->getElementType()->isPrimitiveType() ||
+       isa<OpaqueType>(cast<PointerType>(Ty)->getElementType()))
+      TypeNames.insert(std::make_pair(Ty, getLLVMName(TI->first)));
   }
 }
 
@@ -605,26 +602,31 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
 }
 
 
-/// printSymbolTable - Run through symbol table looking for named constants
-/// if a named constant is found, emit it's declaration...
-///
+// printSymbolTable - Run through symbol table looking for constants
+// and types. Emit their declarations.
 void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
-  for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
-    SymbolTable::type_const_iterator I = ST.type_begin(TI->first);
-    SymbolTable::type_const_iterator End = ST.type_end(TI->first);
+
+  // Print the types.
+  for (SymbolTable::type_const_iterator TI = ST.type_begin();
+       TI != ST.type_end(); ++TI ) {
+    *Out << "\t" << getLLVMName(TI->first) << " = type ";
+
+    // Make sure we print out at least one level of the type structure, so
+    // that we do not get %FILE = type %FILE
+    //
+    printTypeAtLeastOneLevel(TI->second) << "\n";
+  }
     
-    for (; I != End; ++I) {
-      const Value *V = I->second;
+  // Print the constants, in type plane order.
+  for (SymbolTable::plane_const_iterator PI = ST.plane_begin();
+       PI != ST.plane_end(); ++PI ) {
+    SymbolTable::value_const_iterator VI = ST.value_begin(PI->first);
+    SymbolTable::value_const_iterator VE = ST.value_end(PI->first);
+
+    for (; VI != VE; ++VI) {
+      const Value *V = VI->second;
       if (const Constant *CPV = dyn_cast<Constant>(V)) {
        printConstant(CPV);
-      } else if (const Type *Ty = dyn_cast<Type>(V)) {
-        assert(Ty->getType() == Type::TypeTy && TI->first == Type::TypeTy);
-       *Out << "\t" << getLLVMName(I->first) << " = type ";
-
-        // Make sure we print out at least one level of the type structure, so
-        // that we do not get %FILE = type %FILE
-        //
-        printTypeAtLeastOneLevel(Ty) << "\n";
       }
     }
   }
@@ -1014,6 +1016,7 @@ void Argument::print(std::ostream &o) const {
 }
 
 void Value::dump() const { print(std::cerr); }
+void Type::dump() const { print(std::cerr); }
 
 //===----------------------------------------------------------------------===//
 //  CachedWriter Class Implementation
@@ -1062,3 +1065,5 @@ void CachedWriter::setStream(std::ostream &os) {
   Out = &os;
   if (AW) AW->setStream(os);
 }
+
+// vim: sw=2
index 354905327955bc1f4c2b8ac3fcb4189c28b68300..ec5a837cf901f7a74e6986b5a680bf8c1df09f0e 100644 (file)
@@ -248,18 +248,32 @@ void SlotCalculator::processModule() {
 // into the values table...
 //
 void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
-  for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I)
-    for (SymbolTable::type_const_iterator TI = I->second.begin(), 
-          TE = I->second.end(); TI != TE; ++TI)
-      getOrCreateSlot(TI->second);
+  // Do the types first.
+  for (SymbolTable::type_const_iterator TI = ST->type_begin(),
+       TE = ST->type_end(); TI != TE; ++TI )
+    getOrCreateSlot(TI->second);
+
+  // Now do the values.
+  for (SymbolTable::plane_const_iterator PI = ST->plane_begin(), 
+       PE = ST->plane_end(); PI != PE; ++PI)
+    for (SymbolTable::value_const_iterator VI = PI->second.begin(),
+          VE = PI->second.end(); VI != VE; ++VI)
+      getOrCreateSlot(VI->second);
 }
 
 void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
-  for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I)
-    for (SymbolTable::type_const_iterator TI = I->second.begin(), 
-          TE = I->second.end(); TI != TE; ++TI)
-      if (isa<Constant>(TI->second) || isa<Type>(TI->second))
-       getOrCreateSlot(TI->second);
+  // Do the types first
+  for (SymbolTable::type_const_iterator TI = ST->type_begin(),
+       TE = ST->type_end(); TI != TE; ++TI )
+    getOrCreateSlot(TI->second);
+
+  // Now do the constant values in all planes
+  for (SymbolTable::plane_const_iterator PI = ST->plane_begin(), 
+       PE = ST->plane_end(); PI != PE; ++PI)
+    for (SymbolTable::value_const_iterator VI = PI->second.begin(),
+          VE = PI->second.end(); VI != VE; ++VI)
+      if (isa<Constant>(VI->second))
+       getOrCreateSlot(VI->second);
 }
 
 
@@ -452,13 +466,19 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
       getOrCreateCompactionTableSlot(VAN->getArgType());
   }
 
+  // Do the types in the symbol table
   const SymbolTable &ST = F->getSymbolTable();
-  for (SymbolTable::const_iterator I = ST.begin(), E = ST.end(); I != E; ++I)
-    for (SymbolTable::type_const_iterator TI = I->second.begin(), 
-          TE = I->second.end(); TI != TE; ++TI)
-      if (isa<Constant>(TI->second) || isa<Type>(TI->second) ||
-          isa<GlobalValue>(TI->second))
-       getOrCreateCompactionTableSlot(TI->second);
+  for (SymbolTable::type_const_iterator TI = ST.type_begin(),
+       TE = ST.type_end(); TI != TE; ++TI)
+    getOrCreateCompactionTableSlot(TI->second);
+
+  // Now do the constants and global values
+  for (SymbolTable::plane_const_iterator PI = ST.plane_begin(), 
+       PE = ST.plane_end(); PI != PE; ++PI)
+    for (SymbolTable::value_const_iterator VI = PI->second.begin(),
+          VE = PI->second.end(); VI != VE; ++VI)
+      if (isa<Constant>(VI->second) || isa<GlobalValue>(VI->second))
+       getOrCreateCompactionTableSlot(VI->second);
 
   // Now that we have all of the values in the table, and know what types are
   // referenced, make sure that there is at least the zero initializer in any
index 2be8cd0244bbcde35e12387ec2c23c4fc12dab75..90e2edcfdaaa2bf0c85875643aaa9eb8c88ac3ae 100644 (file)
@@ -245,9 +245,9 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
     BBs.clear();
     for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
       SymbolTable &ST = BlockInfo[i].first->getSymbolTable();
-      SymbolTable::iterator I = ST.find(Type::LabelTy);
-      if (I != ST.end() && I->second.count(BlockInfo[i].second))
-        BBs.push_back(cast<BasicBlock>(I->second[BlockInfo[i].second]));
+      SymbolTable::plane_iterator PI = ST.find(Type::LabelTy);
+      if (PI != ST.plane_end() && PI->second.count(BlockInfo[i].second))
+        BBs.push_back(cast<BasicBlock>(PI->second[BlockInfo[i].second]));
     }
     return true;
   }