public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Marc Glisse <marc.glisse@inria.fr>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	David Malcolm <dmalcolm@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <richard.guenther@gmail.com>,
	dominik.infuehr@theobroma-systems.com,
	Jan Hubicka <hubicka@ucw.cz>, Martin Jambor <mjambor@suse.cz>
Subject: Re: [PATCH] Handle new operators with no arguments in DCE.
Date: Tue, 06 Aug 2019 14:07:00 -0000	[thread overview]
Message-ID: <4dcdd0cb-dc8d-73f4-75a2-8ad1e91731fc@suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.21.1908051512410.20630@grove.saclay.inria.fr>

On 8/5/19 3:46 PM, Marc Glisse wrote:
> On Mon, 5 Aug 2019, Martin Liška wrote:
> 
>> You are right. It can really lead to confusion of the DCE.
>>
>> What we have is DECL_ABSTRACT_ORIGIN(decl) which we can use to indicate operators
>> that were somehow modified by an IPA optimization.
> 
> Looks similar to the cgraph_node->clone_of that Richard was talking about. I have no idea which one would be best.


Hm, strange that the ISRA clones don't have n->clone_of set. It's created here:

#0  cgraph_node::create (decl=<function_decl 0x7ffff721c300 _ZN1AdlEPvd.isra.0>) at /home/marxin/Programming/gcc/gcc/profile-count.h:751
#1  0x0000000000bc8342 in cgraph_node::create_version_clone (this=<cgraph_node * const 0x7ffff7208000 "operator delete"/64>, new_decl=<optimized out>, redirect_callers=..., bbs_to_copy=0x0, suffix=0x1b74427 "isra") at /home/marxin/Programming/gcc/gcc/cgraphclones.c:960
#2  0x0000000000bc9b9a in cgraph_node::create_version_clone_with_body (this=this@entry=<cgraph_node * const 0x7ffff7208000 "operator delete"/64>, redirect_callers=redirect_callers@entry=..., tree_map=tree_map@entry=0x0, args_to_skip=args_to_skip@entry=0x0, 
    skip_return=skip_return@entry=false, bbs_to_copy=bbs_to_copy@entry=0x0, new_entry_block=<optimized out>, suffix=<optimized out>, target_attributes=<optimized out>) at /home/marxin/Programming/gcc/gcc/cgraphclones.c:1071
#3  0x00000000010e4611 in modify_function (adjustments=..., node=<cgraph_node * 0x7ffff7208000 "operator delete"/64>) at /home/marxin/Programming/gcc/gcc/tree-sra.c:5493
#4  ipa_early_sra () at /home/marxin/Programming/gcc/gcc/tree-sra.c:5731
#5  (anonymous namespace)::pass_early_ipa_sra::execute (this=<optimized out>) at /home/marxin/Programming/gcc/gcc/tree-sra.c:5778

@Martin, @Honza: Why do we not set clone_of in this transformation?

> 
>> Do you believe it will be sufficient?
> 
> In DCE only consider the operator delete that are not clones? (possibly the same for operator new? I don't know how much we can change the return value of a function in a clone) I guess that should work, and it wouldn't impact the common case with default, global operator new/delete.

I tent to limit that the only cgraph nodes that are not clones. I'm going to prepare a patch for it.

> 
> An alternative would be to clear the DECL_IS_OPERATOR_DELETE flag when creating a clone (possibly only if it modified the first parameter?). There is probably not much information in the fact that a function that doesn't even take a pointer used to be an operator delete.
> 
> 
> By the way, I just thought of something, now that we handle class-specific operator new/delete (but you could do the same with the global replacable ones as well):
> 
> #include <stdio.h>
> int count = 0;
> struct A {
>   __attribute__((malloc,noinline))
>   static void* operator new(unsigned long sz){++count;return ::operator new(sz);}
>   static void operator delete(void* ptr){--count;::operator delete(ptr);}
> };
> int main(){
>   delete new A;
>   printf("%d\n",count);
> }
> 
> If we do not inline anything, we can remove the pair and nothing touches count. If we inline both new and delete, we can then remove the inner pair instead, count increases and decreases, fine. If we inline only one of them, and DCE the mismatched pair new/delete, we get something inconsistent (count is -1).
> 
> This seems to indicate we should check that the new and delete match somehow...
> 

  reply	other threads:[~2019-08-06 12:42 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 11:35 [RFC][PATCH] Extend DCE to remove unnecessary new/delete-pairs Dominik Inführ
2017-11-21 17:13 ` Jeff Law
2017-11-21 17:36   ` Dominik Inführ
2017-11-21 17:45     ` Jeff Law
2017-11-22 10:40   ` Martin Jambor
2017-11-22 18:03     ` Jeff Law
2017-11-22  9:33 ` Richard Biener
2017-11-22 10:41   ` Jakub Jelinek
2017-11-27  9:57     ` Dominik Inführ
2017-11-27 10:48       ` Jakub Jelinek
2017-11-27 17:04       ` Jeff Law
2017-11-28 11:55         ` Richard Biener
2017-11-28 14:48           ` Jakub Jelinek
2017-11-29  8:13       ` Martin Sebor
2017-11-29  9:33         ` Jakub Jelinek
2017-11-29 16:29           ` Martin Sebor
2017-11-29 16:53             ` David Malcolm
2017-11-29 17:01               ` Andrew Pinski
2018-05-13 17:19               ` Marc Glisse
2019-07-02 11:49                 ` [PATCH 1/2] Come up with function_decl_type and use it in tree_function_decl Martin Liška
2019-07-02 11:50                   ` [PATCH 2/2] Extend DCE to remove unnecessary new/delete-pairs (PR c++/23383) Martin Liška
2019-08-02 21:34                     ` H.J. Lu
2019-08-05  6:44                       ` [PATCH] Handle new operators with no arguments in DCE Martin Liška
2019-08-05  7:08                         ` Marc Glisse
2019-08-05  9:53                           ` Martin Liška
2019-08-05 11:57                             ` Marc Glisse
2019-08-05 12:52                               ` Martin Liška
2019-08-05 13:46                                 ` Marc Glisse
2019-08-06 14:07                                   ` Martin Liška [this message]
2019-08-06 15:35                                     ` [PATCH] Detect not-cloned new/delete operators " Martin Liška
2019-08-06 15:59                                       ` Marc Glisse
2019-08-07  9:31                                         ` Martin Liška
2019-08-07 10:15                                           ` Richard Biener
2019-08-06 17:30                                       ` Martin Jambor
2019-08-07  8:56                                         ` Martin Liška
2019-08-07  9:54                                     ` [PATCH] Handle new operators with no arguments " Richard Biener
2019-08-07 11:36                                       ` Martin Liška
2019-08-07 11:51                                         ` Jakub Jelinek
2019-08-07 12:06                                           ` Martin Liška
2019-08-07 14:35                                             ` Richard Biener
2019-08-08  9:01                                               ` Martin Liška
2019-08-15 11:06                                                 ` Martin Liška
2019-08-15 11:35                                                   ` Richard Biener
2019-08-05 12:13                         ` Richard Biener
2019-07-02 16:02                   ` [PATCH 1/2] Come up with function_decl_type and use it in tree_function_decl Martin Sebor
2019-07-02 17:15                   ` Marc Glisse
2019-07-03 15:03                     ` Martin Liška
2019-07-03 16:44                       ` Richard Biener
2019-07-04 22:21                         ` Marc Glisse
2019-07-08 13:02                           ` Martin Liška
2019-07-08 22:00                             ` Jason Merrill
2019-07-09  2:28                             ` Marc Glisse
2019-07-09  7:52                               ` Marc Glisse
2019-07-09  8:49                                 ` Martin Liška
2019-07-09 10:22                                   ` Marc Glisse
2019-07-09 21:02                                     ` Jason Merrill
2019-07-11  6:48                                       ` Martin Liška
2019-07-22 14:00                                         ` Martin Liška
2019-07-24 19:05                                         ` Jeff Law
2019-07-25 10:24                                           ` Richard Biener
2019-07-25  2:17                                         ` Marc Glisse
2019-07-25  8:34                                           ` Martin Liška
2019-07-25 12:21                                             ` Marc Glisse
2019-07-25 13:50                                               ` Martin Liška
2019-07-25 15:41                                                 ` Martin Liška
2019-07-28 21:50                                                   ` [PATCH] Remove also 2nd argument for unused delete operator (PR tree-optimization/91270) Martin Liška
2019-07-29 10:03                                                     ` Richard Biener
2019-07-29 10:54                                                       ` Martin Liška
2019-07-29 14:40                                                         ` Richard Biener
2019-07-30  7:48                                                           ` Martin Liška
2019-07-30  8:09                                                             ` Martin Liška
2019-07-30  8:42                                                               ` Richard Biener
2019-07-30 10:20                                                                 ` Martin Liška
2019-07-30 10:28                                                                   ` Richard Biener
2019-07-30 12:08                                                                   ` Marc Glisse
2019-07-30 12:12                                                                     ` Martin Liška
2019-07-30 13:14                                                                       ` Marc Glisse
2019-07-30 13:41                                                                         ` Martin Liška
2019-07-30 14:37                                                                           ` Marc Glisse
2019-07-31  8:42                                                                             ` [PATCH] Mark necessary 2nd and later args for delete op Martin Liška
2019-07-31 10:24                                                                               ` Richard Biener
2019-07-31 10:00                                                                           ` [PATCH] Remove also 2nd argument for unused delete operator (PR tree-optimization/91270) Richard Biener
2019-07-29  9:59                                                   ` [PATCH 1/2] Come up with function_decl_type and use it in tree_function_decl Richard Biener
2017-11-29 18:05             ` [RFC][PATCH] Extend DCE to remove unnecessary new/delete-pairs Richard Biener
2017-12-04 12:20             ` Trevor Saunders
2017-12-01  1:24           ` Jeff Law
2017-12-01  1:23         ` Jeff Law
2017-11-22 13:03 ` Nathan Sidwell
2017-11-22 14:18   ` Richard Biener
2017-11-22 14:45     ` Nathan Sidwell
2017-11-22 21:45 ` Marc Glisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dcdd0cb-dc8d-73f4-75a2-8ad1e91731fc@suse.cz \
    --to=mliska@suse.cz \
    --cc=dmalcolm@redhat.com \
    --cc=dominik.infuehr@theobroma-systems.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=hubicka@ucw.cz \
    --cc=marc.glisse@inria.fr \
    --cc=mjambor@suse.cz \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).