For PR411:
Take an incremental step towards type plane elimination. This change
separates types from values in the symbol tables by finally making use
of the TypeSymbolTable class. This yields more natural interfaces for
dealing with types and unclutters the SymbolTable class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32956 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index cf770c4..fdf7174 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
 #include "llvm/Type.h"
 #include "llvm/Analysis/ConstantsScanner.h"
 #include "llvm/ADT/PostOrderIterator.h"
@@ -189,13 +190,14 @@
       }
       getOrCreateSlot(I->getType());
     }
-    processSymbolTableConstants(&F->getSymbolTable());
+    processSymbolTableConstants(&F->getValueSymbolTable());
   }
 
   // Insert constants that are named at module level into the slot pool so that
   // the module symbol table can refer to them...
   SC_DEBUG("Inserting SymbolTable values:\n");
-  processSymbolTable(&TheModule->getSymbolTable());
+  processTypeSymbolTable(&TheModule->getTypeSymbolTable());
+  processValueSymbolTable(&TheModule->getValueSymbolTable());
 
   // Now that we have collected together all of the information relevant to the
   // module, compactify the type table if it is particularly big and outputting
@@ -233,16 +235,18 @@
   SC_DEBUG("end processModule!\n");
 }
 
+// processTypeSymbolTable - Insert all of the type sin the specified symbol
+// table.
+void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *ST) {
+  for (TypeSymbolTable::const_iterator TI = ST->begin(), TE = ST->end(); 
+       TI != TE; ++TI )
+    getOrCreateSlot(TI->second);
+}
+
 // processSymbolTable - Insert all of the values in the specified symbol table
 // into the values table...
 //
-void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
-  // 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.
+void SlotCalculator::processValueSymbolTable(const SymbolTable *ST) {
   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(),
@@ -251,11 +255,6 @@
 }
 
 void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
-  // 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)
@@ -306,7 +305,7 @@
     // symbol table references to constants not in the output.  Scan for these
     // constants now.
     //
-    processSymbolTableConstants(&F->getSymbolTable());
+    processSymbolTableConstants(&F->getValueSymbolTable());
   }
 
   SC_DEBUG("Inserting Instructions:\n");
@@ -468,13 +467,8 @@
         getOrCreateCompactionTableSlot(I->getOperand(op));
   }
 
-  // Do the types in the symbol table
-  const SymbolTable &ST = F->getSymbolTable();
-  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
+  const SymbolTable &ST = F->getValueSymbolTable();
   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(),