<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi,<DIV><BR><DIV><BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">That's surprising to me. I thought there was a pass that converts</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">malloc's that trivially dominate all free's and whose pointer doesn't</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">escape would be lowered to alloca's -- but I looked and couldn't find one.</DIV> </BLOCKQUOTE></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I implemented a pass like this a while back.  It's fairly sophisticated and relies on DSA to generate a call graph and do some other things.  At one point I gave the pass to the PyPy folks; they reported that it worked except for a case that DSA couldn't handle -- I think it was variable length arrays.  DSA may be able to handle that case now.  I'm happy to give you my code if you want to use it and/or work it up for submission into LLVM.  If you don't want the dependence on DSA, you could probably easily modify it to make it simpler and more conservative.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Rob</DIV><BR><DIV> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Robert L. Bocchino Jr.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Ph.D. Student</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">University of Illinois, Urbana-Champaign</FONT></P>  </DIV><BR></DIV></BODY></HTML>