public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/60306] [4.9 Regression] Incorrect devirtualization "pure virtual method called"
Date: Fri, 28 Feb 2014 05:10:00 -0000	[thread overview]
Message-ID: <bug-60306-4-VHbdWvBEX5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60306-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60306

--- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
OK, I am re-considering my decision to not assign this to Martin.
The problem is the following.  We have call:

  struct Box x;
...
  x = edges_connecting_to_node (1); [return slot optimization]
...
  _19 = OBJ_TYPE_REF(_18;(const struct Object)&x.D.8084->0) (&x.D.8084);

The dynamic type of x at that point is Box. We however get it wrong as Object.
This is what come from detect_type_change.

The reason is that detect_type_change actually ignores
  x = edges_connecting_to_node (1); [return slot optimization]
which it should not, since it gives it an useful information that x is fully
constructed when the return value happens.

But it considers other statement:
  MEM[(struct new_allocator *)&x + 8B] ={v} {CLOBBER};
  MEM[(struct allocator *)&x + 8B] ={v} {CLOBBER};
  MEM[(struct _Vector_impl *)&x + 8B] ={v} {CLOBBER};
  MEM[(struct _Vector_base *)&x + 8B] ={v} {CLOBBER};
  MEM[(struct vector *)&x + 8B] ={v} {CLOBBER};
  MEM[(struct Object *)&x]._vptr.Object = &MEM[(void *)&_ZTV6Object + 16B];
  MEM[(struct Object *)&x] ={v} {CLOBBER};
  x ={v} {CLOBBER};

which is end of the loop the whole thing is contained in.  The dead store to
._vptr.Object come from inlined destructor and it makes detect_type_change to
believe that the dynamic type is Object.  That is true if you manage to ignore
the initialization.

Now I wonder how to fix this; simple fix is to make detect_type_change to
notice the call and constructors, that is useful by itself.
But I believe there is deeper problem, we need to prove that on _all_ paths to
the statement the dynamic type was changed in known way, not that on all paths
where we can understand the dynamic change the type changed same way.

Can alias oracle walker tell us when it runs into default def?


  parent reply	other threads:[~2014-02-28  5:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21 21:22 [Bug ipa/60306] New: " bredelin at ucla dot edu
2014-02-22 13:55 ` [Bug ipa/60306] [4.9 Regression] " rguenth at gcc dot gnu.org
2014-02-27  9:35 ` rguenth at gcc dot gnu.org
2014-02-28  1:17 ` hubicka at gcc dot gnu.org
2014-02-28  1:26 ` hubicka at gcc dot gnu.org
2014-02-28  5:10 ` hubicka at gcc dot gnu.org [this message]
2014-02-28  5:55 ` hubicka at gcc dot gnu.org
2014-02-28 12:32 ` rguenth at gcc dot gnu.org
2014-02-28 12:35 ` rguenth at gcc dot gnu.org
2014-02-28 20:32 ` hubicka at gcc dot gnu.org
2014-03-02  2:14 ` hubicka at gcc dot gnu.org
2014-03-02 20:52 ` hubicka at gcc dot gnu.org
2014-03-02 22:24 ` hubicka at gcc dot gnu.org

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=bug-60306-4-VHbdWvBEX5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).