On Tue, Nov 12, 2013 at 12:55:17AM +0100, Marc Glisse wrote: > On Mon, 11 Nov 2013, Richard Biener wrote: > > >On Sun, Nov 10, 2013 at 4:27 PM, Marc Glisse <marc.gli...@inria.fr> wrote: > >>Hello, > >> > >>I am posting this patch to get some feedback on the approach. The goal is to > >>replace malloc+free with a stack allocation (a decl actually) when the size > >>is a small constant. > >> > >>For testing, I highjacked the "leaf" attribute, but it isn't right, I'll > >>remove it from the list (not sure what I'll do for the testcases then). What > >>I'd want instead is a "returns" attribute that means the function will > >>return (either by "return" or an exception), as opposed to having an > >>infinite loop, calling exit or longjmp, etc (sched-deps.c has a related > >>call_may_noreturn_p). The situation I am trying to avoid is: > >>p=malloc(12); > >>f(p) > >>free(p) > >> > >>where f contains somewhere: > >>free(p); exit(42); > >>(or longjmp or something else that takes the regular call to free out of the > >>execution flow). > > > >Instead of a new attribute IPA should be used to compute this call-graph > >property. > > Could be both, no? Any idea where I could store this information? > Space is so short that pure and const don't even have their bits in > the same place. > Then there is the question of what properties should be looked at exactly: > - may leave the function via longjmp > - must leave the function via return or an exception > - may free memory it didn't allocate itself > - ?
Anyway you need a better analysis to determine if user called realloc on converted pointer.