[LLVMdev] Promoting malloc to alloca

Duncan Sands baldrick at free.fr
Tue Jul 13 01:47:32 CDT 2010


Hi Nick,

> The attribute you're looking for, "delete if result is unused" doesn't
> exist in LLVM. I've considered it in the past, but the truth is that
> most of the time I want to eliminate dead malloc's, they *do* have a
> use: the matching free. At some point I expect I'm going to teach LLVM
> to remove dead malloc+free / new+delete / new[]+delete[] pairings, but I
> haven't gotten around to it yet. Teaching it to kill an allocation with
> no uses at all will be dead simple too.

LLVM already removes malloc+(perhaps compare with null)+free.

Ciao,

Duncan.


More information about the LLVMdev mailing list