[llvm] r234313 - Clear the stub map in getSortedStubs.

Rafael Espindola rafael.espindola at gmail.com
Tue Apr 7 05:59:28 PDT 2015


Author: rafael
Date: Tue Apr  7 07:59:28 2015
New Revision: 234313

URL: http://llvm.org/viewvc/llvm-project?rev=234313&view=rev
Log:
Clear the stub map in getSortedStubs.

This makes sure they are only output once (and frees a bit of memory).

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
    llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h
    llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=234313&r1=234312&r2=234313&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Tue Apr  7 07:59:28 2015
@@ -91,7 +91,10 @@ public:
   virtual ~MachineModuleInfoImpl();
   typedef std::vector<std::pair<MCSymbol*, StubValueTy> > SymbolListTy;
 protected:
-  static SymbolListTy GetSortedStubs(const DenseMap<MCSymbol*, StubValueTy>&);
+
+  /// Return the entries from a DenseMap in a deterministic sorted orer.
+  /// Clears the map.
+  static SymbolListTy getSortedStubs(DenseMap<MCSymbol*, StubValueTy>&);
 };
 
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h?rev=234313&r1=234312&r2=234313&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h Tue Apr  7 07:59:28 2015
@@ -58,14 +58,14 @@ namespace llvm {
     }
 
     /// Accessor methods to return the set of stubs in sorted order.
-    SymbolListTy GetFnStubList() const {
-      return GetSortedStubs(FnStubs);
+    SymbolListTy GetFnStubList() {
+      return getSortedStubs(FnStubs);
     }
-    SymbolListTy GetGVStubList() const {
-      return GetSortedStubs(GVStubs);
+    SymbolListTy GetGVStubList() {
+      return getSortedStubs(GVStubs);
     }
-    SymbolListTy GetHiddenGVStubList() const {
-      return GetSortedStubs(HiddenGVStubs);
+    SymbolListTy GetHiddenGVStubList() {
+      return getSortedStubs(HiddenGVStubs);
     }
   };
 
@@ -87,8 +87,8 @@ namespace llvm {
 
     /// Accessor methods to return the set of stubs in sorted order.
 
-    SymbolListTy GetGVStubList() const {
-      return GetSortedStubs(GVStubs);
+    SymbolListTy GetGVStubList() {
+      return getSortedStubs(GVStubs);
     }
   };
 

Modified: llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp?rev=234313&r1=234312&r2=234313&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp Tue Apr  7 07:59:28 2015
@@ -31,15 +31,14 @@ static int SortSymbolPair(const void *LH
   return LHSS->getName().compare(RHSS->getName());
 }
 
-/// GetSortedStubs - Return the entries from a DenseMap in a deterministic
-/// sorted orer.
-MachineModuleInfoImpl::SymbolListTy
-MachineModuleInfoImpl::GetSortedStubs(const DenseMap<MCSymbol*,
-                                      MachineModuleInfoImpl::StubValueTy>&Map) {
+MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs(
+    DenseMap<MCSymbol *, MachineModuleInfoImpl::StubValueTy> &Map) {
   MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
 
   if (!List.empty())
     qsort(&List[0], List.size(), sizeof(List[0]), SortSymbolPair);
+
+  Map.clear();
   return List;
 }
 





More information about the llvm-commits mailing list