[llvm-commits] CVS: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp FunctionResolution.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Nov 20 12:35:03 PST 2002


Changes in directory llvm/lib/Transforms/IPO:

DeadTypeElimination.cpp updated: 1.41 -> 1.42
FunctionResolution.cpp updated: 1.16 -> 1.17

---
Log message:

  - Eliminated the deferred symbol table stuff in Module & Function, it really
    wasn't an optimization and it was causing lots of bugs.


---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.41 llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.42
--- llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.41	Tue Oct  1 17:38:36 2002
+++ llvm/lib/Transforms/IPO/DeadTypeElimination.cpp	Wed Nov 20 12:34:36 2002
@@ -63,35 +63,34 @@
 bool DTE::run(Module &M) {
   bool Changed = false;
 
-  if (SymbolTable *ST = M.getSymbolTable()) {
-    const std::set<const Type *> &UsedTypes =
-      getAnalysis<FindUsedTypes>().getTypes();
+  SymbolTable &ST = M.getSymbolTable();
+  const std::set<const Type *> &UsedTypes =
+    getAnalysis<FindUsedTypes>().getTypes();
 
-    // 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.
-        //
-        if (ShouldNukeSymtabEntry(*PI) ||
-            !UsedTypes.count(cast<Type>(PI->second))) {
+  // 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.
+      //
+      if (ShouldNukeSymtabEntry(*PI) ||
+          !UsedTypes.count(cast<Type>(PI->second))) {
 #if MAP_IS_NOT_BRAINDEAD
-          PI = Plane.erase(PI);     // STD C++ Map should support this!
+        PI = Plane.erase(PI);     // STD C++ Map should support this!
 #else
-          Plane.erase(PI);          // Alas, GCC 2.95.3 doesn't  *SIGH*
-          PI = Plane.begin();
+        Plane.erase(PI);          // Alas, GCC 2.95.3 doesn't  *SIGH*
+        PI = Plane.begin();
 #endif
-          ++NumKilled;
-          Changed = true;
-        } else {
-          ++PI;
-        }
-    }
+        ++NumKilled;
+        Changed = true;
+      } else {
+        ++PI;
+      }
   }
 
   return Changed;


Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.16 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.17
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.16	Sat Nov  9 21:36:55 2002
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp	Wed Nov 20 12:34:36 2002
@@ -304,8 +304,7 @@
 }
 
 bool FunctionResolvingPass::run(Module &M) {
-  SymbolTable *ST = M.getSymbolTable();
-  if (!ST) return false;
+  SymbolTable &ST = M.getSymbolTable();
 
   std::map<string, vector<GlobalValue*> > Globals;
 
@@ -313,7 +312,7 @@
   // then add it to the Functions map.  We do a two pass algorithm here to avoid
   // problems with iterators getting invalidated if we did a one pass scheme.
   //
-  for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I)
+  for (SymbolTable::iterator I = ST.begin(), E = ST.end(); I != E; ++I)
     if (const PointerType *PT = dyn_cast<PointerType>(I->first)) {
       SymbolTable::VarMap &Plane = I->second;
       for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end();





More information about the llvm-commits mailing list