<p dir="ltr">LGTM. Thanks. </p>
<p dir="ltr">I was wondering why the original code pattern was there - no tests seemed to exercise it - though it looks like asan found it after as well. So thanks for the comment in the code too. :)</p>
<br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 16, 2016, 4:59 AM Eric Liu <<a href="mailto:ioeric@google.com">ioeric@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This revision was automatically updated to reflect the committed changes.<br class="gmail_msg">
Closed by commit rL281718: Trying to fix Mangler memory leak in TargetLoweringObjectFile. (authored by ioeric).<br class="gmail_msg">
<br class="gmail_msg">
Changed prior to commit:<br class="gmail_msg">
<a href="https://reviews.llvm.org/D24659?vs=71616&id=71617#toc" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24659?vs=71616&id=71617#toc</a><br class="gmail_msg">
<br class="gmail_msg">
Repository:<br class="gmail_msg">
rL LLVM<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D24659" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24659</a><br class="gmail_msg">
<br class="gmail_msg">
Files:<br class="gmail_msg">
llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h<br class="gmail_msg">
llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp<br class="gmail_msg">
<br class="gmail_msg">
Index: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h<br class="gmail_msg">
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h<br class="gmail_msg">
@@ -38,7 +38,7 @@<br class="gmail_msg">
MCContext *Ctx;<br class="gmail_msg">
<br class="gmail_msg">
/// Name-mangler for global names.<br class="gmail_msg">
- Mangler *Mang;<br class="gmail_msg">
+ Mangler *Mang = nullptr;<br class="gmail_msg">
<br class="gmail_msg">
TargetLoweringObjectFile(<br class="gmail_msg">
const TargetLoweringObjectFile&) = delete;<br class="gmail_msg">
Index: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp<br class="gmail_msg">
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp<br class="gmail_msg">
@@ -43,6 +43,8 @@<br class="gmail_msg">
void TargetLoweringObjectFile::Initialize(MCContext &ctx,<br class="gmail_msg">
const TargetMachine &TM) {<br class="gmail_msg">
Ctx = &ctx;<br class="gmail_msg">
+ // `Initialize` can be called more than once.<br class="gmail_msg">
+ if (Mang != nullptr) delete Mang;<br class="gmail_msg">
Mang = new Mangler();<br class="gmail_msg">
InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(),<br class="gmail_msg">
TM.getCodeModel(), *Ctx);<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>