Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-26 Thread Jason Merrill
On Tue, Apr 26, 2016 at 5:07 AM, Richard Biener wrote: > On Mon, Apr 25, 2016 at 9:57 PM, Jason Merrill wrote: >> Hmm, this seems to assume that operator delete itself doesn't do >> anything with the object being deleted. This is true of the default

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-26 Thread Richard Biener
On Tue, Apr 26, 2016 at 11:28 AM, Marc Glisse wrote: > On Tue, 26 Apr 2016, Richard Biener wrote: > >> On Mon, Apr 25, 2016 at 9:57 PM, Jason Merrill wrote: >>> >>> Hmm, this seems to assume that operator delete itself doesn't do >>> anything with the

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-26 Thread Marc Glisse
On Tue, 26 Apr 2016, Richard Biener wrote: On Mon, Apr 25, 2016 at 9:57 PM, Jason Merrill wrote: Hmm, this seems to assume that operator delete itself doesn't do anything with the object being deleted. This is true of the default implementation, but I don't see anything in

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-26 Thread Richard Biener
On Mon, Apr 25, 2016 at 9:57 PM, Jason Merrill wrote: > Hmm, this seems to assume that operator delete itself doesn't do > anything with the object being deleted. This is true of the default > implementation, but I don't see anything in the standard that > prohibits a

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-25 Thread Jason Merrill
Hmm, this seems to assume that operator delete itself doesn't do anything with the object being deleted. This is true of the default implementation, but I don't see anything in the standard that prohibits a user-supplied replacement or class-specific deallocation function from accessing the

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-25 Thread Richard Biener
On Fri, Apr 22, 2016 at 11:37 PM, Mikhail Maltsev wrote: > On 04/20/2016 05:12 PM, Richard Biener wrote: >> You have >> >> +static tree >> +handle_free_attribute (tree *node, tree name, tree /*args*/, int /*flags*/, >> + bool *no_add_attrs) >> +{ >> +

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-25 Thread Richard Biener
On Mon, Apr 25, 2016 at 11:02 AM, Bernd Schmidt wrote: > On 04/19/2016 10:48 PM, Mikhail Maltsev wrote: >> >> On 04/18/2016 12:14 PM, Richard Biener wrote: >>> >>> >>> Enlarging tree_function_decl is bad. >> >> Probably using 3 bits for malloc_flag, operator_new_flag and

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-25 Thread Bernd Schmidt
On 04/19/2016 10:48 PM, Mikhail Maltsev wrote: On 04/18/2016 12:14 PM, Richard Biener wrote: Enlarging tree_function_decl is bad. Probably using 3 bits for malloc_flag, operator_new_flag and free_flag is redundant. I packed the state into 2 bits. Passes should get at the info via

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-22 Thread Mikhail Maltsev
On 04/20/2016 05:12 PM, Richard Biener wrote: > You have > > +static tree > +handle_free_attribute (tree *node, tree name, tree /*args*/, int /*flags*/, > + bool *no_add_attrs) > +{ > + tree decl = *node; > + if (TREE_CODE (decl) == FUNCTION_DECL > + &&

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-20 Thread Richard Biener
On Tue, Apr 19, 2016 at 10:48 PM, Mikhail Maltsev wrote: > On 04/18/2016 12:14 PM, Richard Biener wrote: >> >> Enlarging tree_function_decl is bad. > Probably using 3 bits for malloc_flag, operator_new_flag and free_flag is > redundant. I packed the state into 2 bits. >> >>

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-19 Thread Mikhail Maltsev
On 04/18/2016 12:14 PM, Richard Biener wrote: > > Enlarging tree_function_decl is bad. Probably using 3 bits for malloc_flag, operator_new_flag and free_flag is redundant. I packed the state into 2 bits. > > Passes should get at the info via flags_from_decl_or_type () and a new > ECF_FREE.

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-18 Thread Richard Biener
On Sat, Apr 16, 2016 at 11:32 PM, Mikhail Maltsev wrote: > Hi, all! > > Currently GCC can optimize away the following dead store: > > void test(char *x) > { > *x = 1; > free(x); > } > > but not this one (Clang handles both cases): > > void test(char *x) > { > *x = 1; >

Re: [PATCH] Fix missed DSE opportunity with operator delete.

2016-04-17 Thread Marc Glisse
On Sun, 17 Apr 2016, Mikhail Maltsev wrote: Currently GCC can optimize away the following dead store: void test(char *x) { *x = 1; free(x); } but not this one (Clang handles both cases): void test(char *x) { *x = 1; delete x; } The attached patch fixes this by introducing a new

[PATCH] Fix missed DSE opportunity with operator delete.

2016-04-16 Thread Mikhail Maltsev
Hi, all! Currently GCC can optimize away the following dead store: void test(char *x) { *x = 1; free(x); } but not this one (Clang handles both cases): void test(char *x) { *x = 1; delete x; } The attached patch fixes this by introducing a new __attribute__((free)). I first tried to