This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC][PATCH] Extend DCE to remove unnecessary new/delete-pairs


Thanks for all the reviews! I’ve revised the patch, the operator_delete_flag is now stored in tree_decl_with_vis (there already seem to be some FUNCTION_DECL-flags in there). I’ve also added the option -fallocation-dce to disable this optimization. It bootstraps and no regressions on aarch64 and x86_64.

The problem with this patch is what Marc noticed: it omits too many allocations. The C++ standard seems to only allow to omit "replaceable global allocation functions (18.6.1.1, 18.6.1.2)”. So e.g. no class-specific or user-defined allocations. I am not sure what’s the best way to implement this. Just checking the function declarations might not be enough and seems more like a hack. The better way seems to introduce a __builtin_operator_new like Marc mentioned. In which way would you implement this? Could you please give me some pointers here to look at?

Thanks,
Dominik

Attachment: dce-new-delete2.diff.txt
Description: Text document

> On 22 Nov 2017, at 11:37, Jakub Jelinek <jakub@redhat.com> wrote:
> 
> On Wed, Nov 22, 2017 at 10:30:29AM +0100, Richard Biener wrote:
>> --- a/gcc/tree-core.h
>> +++ b/gcc/tree-core.h
>> @@ -1787,7 +1787,9 @@ struct GTY(()) tree_function_decl {
>>   unsigned has_debug_args_flag : 1;
>>   unsigned tm_clone_flag : 1;
>>   unsigned versioned_function : 1;
>> -  /* No bits left.  */
>> +
>> +  unsigned operator_delete_flag : 1;
>> +  /* 31 bits left.  */
>> 
>> while it looks bad reality is that on 64bit pointer hosts we had 32 bits left.
> 
> But we can just add it to say tree_decl_common which has 14 spare bits or
> tree_decl_with_vis which has another 14 spare bits.  By just noting the flag
> applies only to FUNCTION_DECLs and enforcing it in the tree.h macros,
> it will be easy to reuse that bit for something different for trees other
> than FUNCTION_DECL.
> 
> 	Jakub

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]