Re: [RFC] replace malloc with a decl on the stack

2013-11-24 Thread Marc Glisse
On Sun, 24 Nov 2013, Florian Weimer wrote: On 11/12/2013 04:22 PM, Marc Glisse wrote: On Tue, 12 Nov 2013, Ondřej Bílka wrote: Anyway you need a better analysis to determine if user called realloc on converted pointer. Note that I am checking if the argument of free is the same as the retur

Re: [RFC] replace malloc with a decl on the stack

2013-11-24 Thread Florian Weimer
On 11/12/2013 04:22 PM, Marc Glisse wrote: On Tue, 12 Nov 2013, Ondřej Bílka wrote: Anyway you need a better analysis to determine if user called realloc on converted pointer. Note that I am checking if the argument of free is the same as the return value of malloc by looking at the SSA_NAME,

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Jeff Law
On 11/12/13 05:41, Marc Glisse wrote: On Tue, 12 Nov 2013, Ondřej Bílka wrote: I am trying to get something to actually work and be accepted in gcc. That may mean being conservative. That also may mean that you will cover only cases where it is not needed. A malloc will have a small per-thre

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Marc Glisse
On Tue, 12 Nov 2013, Ondřej Bílka wrote: Seems to be missing some bits. A example, its purpose is to show a idea not to be complete. I agree, but when too many bits are missing or wrong I fail to get the idea :-( How will you find small constant allocations with this in place? I won't.

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Ondřej Bílka
On Tue, Nov 12, 2013 at 05:01:31PM +0100, Marc Glisse wrote: > On Tue, 12 Nov 2013, Ondřej Bílka wrote: > > >On Tue, Nov 12, 2013 at 01:41:24PM +0100, Marc Glisse wrote: > >>On Tue, 12 Nov 2013, Ondřej Bílka wrote: > >> > I am trying to get something to actually work and be accepted in > g

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Marc Glisse
On Tue, 12 Nov 2013, Ondřej Bílka wrote: On Tue, Nov 12, 2013 at 01:41:24PM +0100, Marc Glisse wrote: On Tue, 12 Nov 2013, Ondřej Bílka wrote: I am trying to get something to actually work and be accepted in gcc. That may mean being conservative. That also may mean that you will cover only

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Marc Glisse
On Tue, 12 Nov 2013, Ondřej Bílka wrote: Anyway you need a better analysis to determine if user called realloc on converted pointer. Note that I am checking if the argument of free is the same as the return value of malloc by looking at the SSA_NAME, not the C variable. If the user called re

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Ondřej Bílka
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 wrote: > >>Hello, > >> > >>I am posting this patch to get some feedback on the approach. The goal is to > >>replace malloc+free with a stack

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Ondřej Bílka
On Tue, Nov 12, 2013 at 01:41:24PM +0100, Marc Glisse wrote: > On Tue, 12 Nov 2013, Ondřej Bílka wrote: > > >>I am trying to get something to actually work and be accepted in > >>gcc. That may mean being conservative. > > > >That also may mean that you will cover only cases where it is not needed.

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Marc Glisse
On Tue, 12 Nov 2013, Ondřej Bílka wrote: I am trying to get something to actually work and be accepted in gcc. That may mean being conservative. That also may mean that you will cover only cases where it is not needed. A malloc will have a small per-thread cache for small requests that does n

Re: [RFC] replace malloc with a decl on the stack

2013-11-12 Thread Ondřej Bílka
On Tue, Nov 12, 2013 at 01:16:14AM +0100, Marc Glisse wrote: > On Mon, 11 Nov 2013, Ondřej Bílka wrote: > > >On Sun, Nov 10, 2013 at 04:27:00PM +0100, Marc Glisse wrote: > >>Hello, > >> > >>I am posting this patch to get some feedback on the approach. The > >>goal is to replace malloc+free with a

Re: [RFC] replace malloc with a decl on the stack

2013-11-11 Thread Marc Glisse
On Mon, 11 Nov 2013, Ondřej Bílka wrote: On Sun, Nov 10, 2013 at 04:27:00PM +0100, Marc Glisse 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. Why const

Re: [RFC] replace malloc with a decl on the stack

2013-11-11 Thread Marc Glisse
On Mon, 11 Nov 2013, Richard Biener wrote: On Sun, Nov 10, 2013 at 4:27 PM, Marc Glisse 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 h

Re: [RFC] replace malloc with a decl on the stack

2013-11-11 Thread Richard Biener
On Sun, Nov 10, 2013 at 4:27 PM, Marc Glisse 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

Re: [RFC] replace malloc with a decl on the stack

2013-11-11 Thread Ondřej Bílka
On Mon, Nov 11, 2013 at 11:19:05AM +0100, Jakub Jelinek wrote: > On Mon, Nov 11, 2013 at 11:08:14AM +0100, Ondřej Bílka wrote: > > On Sun, Nov 10, 2013 at 04:27:00PM +0100, Marc Glisse wrote: > > > I am posting this patch to get some feedback on the approach. The > > > goal is to replace malloc+fre

Re: [RFC] replace malloc with a decl on the stack

2013-11-11 Thread Jakub Jelinek
On Mon, Nov 11, 2013 at 11:08:14AM +0100, Ondřej Bílka wrote: > On Sun, Nov 10, 2013 at 04:27:00PM +0100, Marc Glisse wrote: > > 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 smal

Re: [RFC] replace malloc with a decl on the stack

2013-11-11 Thread Ondřej Bílka
On Sun, Nov 10, 2013 at 04:27:00PM +0100, Marc Glisse 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. > Why constraint yourself to small sizes. Stac

Re: [RFC] replace malloc with a decl on the stack

2013-11-10 Thread Marc Glisse
On Sun, 10 Nov 2013, Marc Glisse wrote: 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. A slightly updated version that handles abort and if(VAR==0) where VAR is the

[RFC] replace malloc with a decl on the stack

2013-11-10 Thread Marc Glisse
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