<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr">This patch doesn't appear to do the right thing w/ memory management.<div><br></div><div><a href="http://lab.llvm.org:8011/builders/llvm-ppc64-linux1/builds/2258">http://lab.llvm.org:8011/builders/llvm-ppc64-linux1/builds/2258</a><br>
</div><div><br></div><div style>Please revert so we can get our builds back.</div><div style><br></div><div style>Does it pass under Valgrind or other memory safety tools? Those are likely to be able to reproduce these types of failures.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 5, 2012 at 4:50 PM, Pedro Artigas <span dir="ltr"><<a href="mailto:partigas@apple.com" target="_blank">partigas@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: partigas<br>
Date: Wed Dec  5 18:50:55 2012<br>
New Revision: 169456<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=169456&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=169456&view=rev</a><br>
Log:<br>
<br>
change MCContext to work on the doInitialization/doFinalization model<br>
<br>
reviewed by Evan Cheng <<a href="mailto:evan.cheng@apple.com">evan.cheng@apple.com</a>><br>
<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/MC/MCContext.h<br>
    llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp<br>
    llvm/trunk/lib/MC/MCContext.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/MC/MCContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=169456&r1=169455&r2=169456&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=169456&r1=169455&r2=169456&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/MC/MCContext.h (original)<br>
+++ llvm/trunk/include/llvm/MC/MCContext.h Wed Dec  5 18:50:55 2012<br>
@@ -154,6 +154,17 @@<br>
<br>
     void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }<br>
<br>
+    /// @name Module Lifetime Management<br>
+    /// @{<br>
+<br>
+    /// doInitialization - prepare to process a new module<br>
+    void doInitialization();<br>
+<br>
+    /// doFinalization - clean up state from the current module<br>
+    void doFinalization();<br>
+<br>
+    /// @}<br>
+<br>
     /// @name Symbol Management<br>
     /// @{<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=169456&r1=169455&r2=169456&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=169456&r1=169455&r2=169456&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Wed Dec  5 18:50:55 2012<br>
@@ -270,6 +270,9 @@<br>
 }<br>
<br>
 bool MachineModuleInfo::doInitialization(Module &M) {<br>
+<br>
+  Context.doInitialization();<br>
+<br>
   ObjFileMMI = 0;<br>
   CompactUnwindEncoding = 0;<br>
   CurCallSite = 0;<br>
@@ -291,6 +294,8 @@<br>
   delete AddrLabelSymbols;<br>
   AddrLabelSymbols = 0;<br>
<br>
+  Context.doFinalization();<br>
+<br>
   return false;<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/MC/MCContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=169456&r1=169455&r2=169456&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=169456&r1=169455&r2=169456&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/MC/MCContext.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCContext.cpp Wed Dec  5 18:50:55 2012<br>
@@ -44,23 +44,48 @@<br>
   SecureLogFile = getenv("AS_SECURE_LOG_FILE");<br>
   SecureLog = 0;<br>
   SecureLogUsed = false;<br>
+}<br>
<br>
+MCContext::~MCContext() {<br>
+  // NOTE: The symbols are all allocated out of a bump pointer allocator,<br>
+  // we don't need to free them here.<br>
+<br>
+  // If the stream for the .secure_log_unique directive was created free it.<br>
+  delete (raw_ostream*)SecureLog;<br>
+}<br>
+<br>
+//===----------------------------------------------------------------------===//<br>
+// Module Lifetime Management<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+void MCContext::doInitialization() {<br>
+  NextUniqueID = 0;<br>
+  AllowTemporaryLabels = true;<br>
   DwarfLocSeen = false;<br>
   GenDwarfForAssembly = false;<br>
   GenDwarfFileNumber = 0;<br>
 }<br>
<br>
-MCContext::~MCContext() {<br>
-  // NOTE: The symbols are all allocated out of a bump pointer allocator,<br>
-  // we don't need to free them here.<br>
+void MCContext::doFinalization() {<br>
+  UsedNames.clear();<br>
+  Symbols.clear();<br>
+  Allocator.Reset();<br>
+  Instances.clear();<br>
+  MCDwarfFiles.clear();<br>
+  MCDwarfDirs.clear();<br>
+  MCGenDwarfLabelEntries.clear();<br>
+  DwarfDebugFlags = StringRef();<br>
+  MCLineSections.clear();<br>
+  MCLineSectionOrder.clear();<br>
+  CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);<br>
<br>
   // If we have the MachO uniquing map, free it.<br>
   delete (MachOUniqueMapTy*)MachOUniquingMap;<br>
   delete (ELFUniqueMapTy*)ELFUniquingMap;<br>
   delete (COFFUniqueMapTy*)COFFUniquingMap;<br>
-<br>
-  // If the stream for the .secure_log_unique directive was created free it.<br>
-  delete (raw_ostream*)SecureLog;<br>
+  MachOUniquingMap = 0;<br>
+  ELFUniquingMap = 0;<br>
+  COFFUniquingMap = 0;<br>
 }<br>
<br>
 //===----------------------------------------------------------------------===//<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>