[llvm-commits] [llvm] r124717 - /llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp

Nick Lewycky nicholas at mxc.ca
Tue Feb 1 21:31:01 PST 2011


Author: nicholas
Date: Tue Feb  1 23:31:01 2011
New Revision: 124717

URL: http://llvm.org/viewvc/llvm-project?rev=124717&view=rev
Log:
Remove wasteful caching. This isn't needed for correctness because any function
that might have changed been affected by a merge elsewhere will have been
removed from the function set, and it isn't needed for performance because we
call grow() ahead of time to prevent reallocations.

Modified:
    llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp

Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=124717&r1=124716&r2=124717&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Tue Feb  1 23:31:01 2011
@@ -112,23 +112,10 @@
     Func = NULL;
   }
 
-  bool &getOrInsertCachedComparison(const ComparableFunction &Other,
-                                    bool &inserted) const {
-    typedef DenseMap<Function *, bool>::iterator iterator;
-    std::pair<iterator, bool> p =
-        CompareResultCache.insert(std::make_pair(Other.getFunc(), false));
-    inserted = p.second;
-    return p.first->second;
-  }
-
 private:
   explicit ComparableFunction(unsigned Hash)
     : Func(NULL), Hash(Hash), TD(NULL) {}
 
-  // DenseMap::grow() triggers a recomparison of all keys in the map, which is
-  // wildly expensive. This cache tries to preserve known results.
-  mutable DenseMap<Function *, bool> CompareResultCache;
-
   AssertingVH<Function> Func;
   unsigned Hash;
   TargetData *TD;
@@ -675,16 +662,8 @@
   assert(LHS.getTD() == RHS.getTD() &&
          "Comparing functions for different targets");
 
-  bool inserted;
-  bool &result1 = LHS.getOrInsertCachedComparison(RHS, inserted);
-  if (!inserted)
-    return result1;
-  bool &result2 = RHS.getOrInsertCachedComparison(LHS, inserted);
-  if (!inserted)
-    return result1 = result2;
-
-  return result1 = result2 = FunctionComparator(LHS.getTD(), LHS.getFunc(),
-                                                RHS.getFunc()).compare();
+  return FunctionComparator(LHS.getTD(), LHS.getFunc(),
+                            RHS.getFunc()).compare();
 }
 
 // Replace direct callers of Old with New.





More information about the llvm-commits mailing list