<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-NZ link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Hi,<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>I’m current using LLVM 2.5 to JIT code in a event
driven language running on a game engine.  Haven’t updated to 2.7
yet, but I do intend to.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>When checking for memory leaks I found that each time I was
calling <span style='font-family:"Courier New"'>EE->runFunction</span> after
creating a stub function to execute an event, all the pass information was being
repeatedly added to <span style='font-family:"Courier New"'>PMDataManager</span><span
style='font-size:10.0pt;font-family:"Courier New"'>.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>

<p class=MsoNormal>I have changed <span style='font-family:"Courier New"'>addAnalysisImplsPair</span>
to the following, which seems to have no side effects with what I am doing. 
Prior to that, <span style='font-family:"Courier New"'>AnalysisImpls</span> contained
thousands of entries and each time the vector gets realloced to accommodate more
entries we lose a bigger chunk of memory.<o:p></o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>  <span style='color:blue'>void</span>
addAnalysisImplsPair(<span style='color:blue'>const</span> PassInfo *PI, Pass
*P) {<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>     <span style='color:blue'>for</span>
(std::vector<std::pair<<span style='color:blue'>const</span> PassInfo*,
Pass*> >::iterator I =<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>       
AnalysisImpls.begin(); (I!=AnalysisImpls.end()); ++I)<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>     {<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>        <span
style='color:blue'>if</span> (I->first==PI && I->second==P)<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>        {<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>          
<span style='color:green'>// Return, if PassInfo and Pass are already in
AnalysisImpls.<o:p></o:p></span></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>          
<span style='color:blue'>return</span>;<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>        }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>     }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>    std::pair<<span
style='color:blue'>const</span> PassInfo*, Pass*> pir =
std::make_pair(PI,P);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>    AnalysisImpls.push_back(pir);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>  }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><o:p> </o:p></p>

<p class=MsoNormal style='text-autospace:none'>I’m probably doing
something funny, or not as intended, but your comments would be appreciated.<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><o:p> </o:p></p>

<p class=MsoNormal style='text-autospace:none'>Rob.<o:p></o:p></p>

</div>

</body>

</html>