From 5fb724332aeb0f70fb6cd882718e09d1db0e12d5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 8 Sep 2002 21:47:54 +0000 Subject: [PATCH] Factor silly code duplication out git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3627 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/DeadTypeElimination.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index 842bc58b296..58fe7f0a595 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -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(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(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; -- 2.34.1