public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>, "Jan Hubicka" <hubicka@ucw.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Marc Glisse <marc.glisse@inria.fr>
Subject: Re: [PATCH] Check DECL_CONTEXT of new/delete operators.
Date: Mon, 30 Mar 2020 10:53:51 +0200	[thread overview]
Message-ID: <CAFiYyc03b7gQONwgma3s7TsX-Ga-8ZFy8SW8SiEZgzjor--e4A@mail.gmail.com> (raw)
In-Reply-To: <af29444d-118a-4818-26ca-bbe468a587dd@suse.cz>

On Mon, Mar 30, 2020 at 10:41 AM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> The patch ensures that a deleted new/delete pair has a same context.
> That will fix the issue presented in the PR.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

I think this will break the DCE with LTO since we strip quite some
DECL_CONTEXT in free-lang-data.

Honza - do you remember why we strip DECL_CONTEXT for methods
which will most likely keep their containing record types live through
their this
arguments?  Quoting:

  /* We need to keep field decls associated with their trees. Otherwise tree
     merging may merge some fileds and keep others disjoint wich in turn will
     not do well with TREE_CHAIN pointers linking them.

     Also do not drop containing types for virtual methods and tables because
     these are needed by devirtualization.
     C++ destructors are special because C++ frontends sometimes produces
     virtual destructor as an alias of non-virtual destructor.  In
     devirutalization code we always walk through aliases and we need
     context to be preserved too.  See PR89335  */
  if (TREE_CODE (decl) != FIELD_DECL
      && ((TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
          || (!DECL_VIRTUAL_P (decl)
              && (TREE_CODE (decl) != FUNCTION_DECL
                  || !DECL_CXX_DESTRUCTOR_P (decl)))))
    DECL_CONTEXT (decl) = fld_decl_context (DECL_CONTEXT (decl));

and fld_decl_context stripping up to the next non-TYPE context (unless VLA).

Richard.

> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2020-03-30  Martin Liska  <mliska@suse.cz>
>
>         PR c++/94314
>         * tree-ssa-dce.c (propagate_necessity): Verify that
>         DECL_CONTEXT of a new/delete operators do match.
>
> gcc/testsuite/ChangeLog:
>
> 2020-03-30  Martin Liska  <mliska@suse.cz>
>
>         PR c++/94314
>         * g++.dg/pr94314.C: New test.
> ---
>   gcc/testsuite/g++.dg/pr94314.C | 84 ++++++++++++++++++++++++++++++++++
>   gcc/tree-ssa-dce.c             | 31 +++++++++----
>   2 files changed, 105 insertions(+), 10 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/pr94314.C
>
>

  reply	other threads:[~2020-03-30  8:54 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30  8:40 Martin Liška
2020-03-30  8:53 ` Richard Biener [this message]
2020-03-31 12:29   ` Jan Hubicka
2020-03-31 12:38     ` Martin Liška
2020-04-03 15:26       ` Jan Hubicka
2020-04-03 15:42         ` Jan Hubicka
2020-04-04 11:53           ` Jan Hubicka
2020-04-06  9:27             ` Richard Biener
2020-04-06 15:10               ` Jason Merrill
2020-04-06  8:34         ` Martin Liška
2020-04-06 12:45           ` Nathan Sidwell
2020-04-07  8:26             ` Jonathan Wakely
2020-04-07  9:29               ` Richard Biener
2020-04-07  9:49                 ` Jan Hubicka
2020-04-07 10:22                   ` Richard Biener
2020-04-07 10:42                     ` Martin Liška
2020-04-07 11:41                 ` Jonathan Wakely
2020-04-07 10:46             ` Martin Liška
2020-04-07 11:29             ` Jonathan Wakely
2020-04-07 11:40               ` Richard Biener
2020-04-07 11:46                 ` Jonathan Wakely
2020-04-07 11:57                   ` Richard Biener
2020-04-07 15:00                     ` [PATCH] Allow new/delete operator deletion only for replaceable Martin Liška
2020-04-08  8:47                       ` Richard Biener
2020-04-08 13:20                         ` Jason Merrill
2020-04-08 13:32                           ` Jakub Jelinek
2020-04-08 13:34                             ` Jason Merrill
2020-04-08 15:16                               ` Martin Liška
2020-04-08 15:46                                 ` Jan Hubicka
2020-04-08 16:06                                   ` Jakub Jelinek
2020-04-09  5:05                                 ` Martin Liška
2020-04-09  6:45                                   ` Richard Biener
2020-04-09  6:59                                     ` Martin Liška
2020-04-09  7:21                                       ` Richard Biener
2020-04-09  7:55                                       ` Jakub Jelinek
2020-04-09  8:04                                     ` Marc Glisse
2020-04-09  8:13                                       ` Jonathan Wakely
2020-04-10  8:08                                         ` Martin Liška
2020-04-10  8:18                                           ` Jonathan Wakely
2020-04-10  8:29                                             ` Martin Liška
2020-04-10  9:17                                               ` Jakub Jelinek
2020-04-14  7:09                                                 ` Martin Liška
2020-04-14  7:11                                                   ` Martin Liška
2020-04-14  8:37                                                     ` Jakub Jelinek
2020-04-14 10:54                                                       ` Martin Liška
2020-04-17  7:05                                                         ` Jakub Jelinek
2020-04-17  8:12                                                           ` Jonathan Wakely
2020-04-10  8:37                                           ` Marc Glisse
2020-04-10  9:11                                             ` Iain Sandoe
2020-04-09 16:55                                   ` Jason Merrill
2020-04-07 15:16                     ` [PATCH] Check DECL_CONTEXT of new/delete operators Jonathan Wakely
2020-04-08  7:34                       ` Richard Biener
2020-04-08  8:11                         ` Jonathan Wakely
2020-04-07 14:11               ` Nathan Sidwell
2020-03-30  9:29 ` 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=CAFiYyc03b7gQONwgma3s7TsX-Ga-8ZFy8SW8SiEZgzjor--e4A@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=marc.glisse@inria.fr \
    --cc=mliska@suse.cz \
    /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).