[LLVMdev] Unused malloc/free don't get optimized
nicholas at mxc.ca
Wed Feb 21 20:50:21 PST 2007
Robert L. Bocchino Jr. wrote:
>>> 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
> 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.
Sounds good! I'd like to see the code, even though I can't promise that
I'll do anything with it in the near term.
I'd rather not depend on DSA in particular. If it could depend on
AliasAnalysis then it would grow stronger or weaker depending on what
aliasing analysis was loaded at the time. Are there any special features
of DSA that you're using?
More information about the llvm-dev