Loop invariant code motion now depends on the LoopPreheader pass. Dead code
[oota-llvm.git] / lib / Transforms / IPO / DeadTypeElimination.cpp
index 3473f526dcd84d36d8acf0bfa5fdbf24cfbabab4..58fe7f0a595b7d7014285b8fd4013e9056460dc7 100644 (file)
@@ -27,7 +27,7 @@ namespace {
     // getAnalysisUsage - This function needs FindUsedTypes to do its job...
     //
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired(FindUsedTypes::ID);
+      AU.addRequired<FindUsedTypes>();
     }
   };
   RegisterOpt<DTE> X("deadtypeelim", "Dead Type Elimination");
@@ -74,21 +74,16 @@ bool DTE::run(Module &M) {
       // Loop over all entries in the type plane...
       SymbolTable::VarMap &Plane = STI->second;
       for (SymbolTable::VarMap::iterator PI = Plane.begin(); PI != Plane.end();)
-        if (ShouldNukeSymtabEntry(*PI)) {    // Should we remove this entry?
+        // 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!
 #else
           Plane.erase(PI);          // Alas, GCC 2.95.3 doesn't  *SIGH*
           PI = Plane.begin();
-#endif
-          ++NumKilled;
-          Changed = true;
-        } else if (!UsedTypes.count(cast<Type>(PI->second))) {
-#if MAP_IS_NOT_BRAINDEAD
-          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();       // N^2 algorithms are fun.  :(
 #endif
           ++NumKilled;
           Changed = true;