[LLVMdev] Unused malloc/free don't get optimized
Robert L. Bocchino Jr.
bocchino at uiuc.edu
Fri Feb 16 21:50:16 PST 2007
Hi,
>> That's surprising to me. I thought there was a pass that converts
>> malloc's that trivially dominate all free's and whose pointer doesn't
>> escape would be lowered to alloca's -- but I looked and couldn't
>> find one.
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.
Rob
Robert L. Bocchino Jr.
Ph.D. Student
University of Illinois, Urbana-Champaign
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070216/1c8aecdc/attachment.html>
More information about the llvm-dev
mailing list