[llvm] r238167 - Move MCSection destruction to MCContext::reset.

Rafael Espindola rafael.espindola at gmail.com
Mon May 25 18:52:19 PDT 2015


Author: rafael
Date: Mon May 25 20:52:19 2015
New Revision: 238167

URL: http://llvm.org/viewvc/llvm-project?rev=238167&view=rev
Log:
Move MCSection destruction to MCContext::reset.

Fixes the leaks when running llc.

Also found by an asan bot.

Modified:
    llvm/trunk/lib/MC/MCContext.cpp

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=238167&r1=238166&r2=238167&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Mon May 25 20:52:19 2015
@@ -55,14 +55,6 @@ MCContext::MCContext(const MCAsmInfo *ma
 }
 
 MCContext::~MCContext() {
-  // Call the destructors so the fragments are freed
-  for (auto &I : ELFUniquingMap)
-    I.second->~MCSectionELF();
-  for (auto &I : COFFUniquingMap)
-    I.second->~MCSectionCOFF();
-  for (auto &I : MachOUniquingMap)
-    I.second->~MCSectionMachO();
-
   if (AutoReset)
     reset();
 
@@ -78,6 +70,14 @@ MCContext::~MCContext() {
 //===----------------------------------------------------------------------===//
 
 void MCContext::reset() {
+  // Call the destructors so the fragments are freed
+  for (auto &I : ELFUniquingMap)
+    I.second->~MCSectionELF();
+  for (auto &I : COFFUniquingMap)
+    I.second->~MCSectionCOFF();
+  for (auto &I : MachOUniquingMap)
+    I.second->~MCSectionMachO();
+
   UsedNames.clear();
   Symbols.clear();
   Allocator.Reset();





More information about the llvm-commits mailing list