public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Teresa Johnson <tejohnson@google.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: David Li <davidxl@google.com>
Subject: [PATCH] Fix segfault in FRE during SCC value numbering
Date: Wed, 15 Jan 2014 17:07:00 -0000	[thread overview]
Message-ID: <CAAe5K+UcnQhUZ6WdOLdMSABa+9FTQLE+jiUJ_QrZ2BwvhAf_gA@mail.gmail.com> (raw)

Handle NULL vdef for call in the case where we have a matching vnresult
that has a vdef (it already handles the NULL vdef case when !vnresult). This
can happen for promoted indirect calls if the fallback indirect call
(which has a vdef) can be proven equivalent to the promoted direct call
(which might not have a vdef).

This occurred for a case where we had a promoted indirect call,
where FRE determined that the promoted direct call and the fall-back indirect
call were equivalent (since earlier it determined that the function pointer
was always set to that target). The indirect call had been analyzed by
visit_reference_op_call first, and had a VDEF. The direct call did not have a
VDEF, presumably because it was a leaf function in the same module without any
stores. But visit_reference_op_call unconditionally calls set_ssa_val_to when
the previous vnresult had a vdef, leading to a seg fault in this case.
If we had analyzed the direct call first the failure wouldn't have occurred
since the !vnresult case guards the call to set_ssa_val_to with a check
for a NULL vdef, and the subsequent handling of the indirect call would
also not call set_ssa_val_to since vnresult would have had a null result_vdef.

Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?

2014-01-15  Teresa Johnson  <tejohnson@google.com>

        * tree-ssa-sccvn.c (visit_reference_op_call): Handle NULL vdef.

Index: tree-ssa-sccvn.c
===================================================================
--- tree-ssa-sccvn.c    (revision 206100)
+++ tree-ssa-sccvn.c    (working copy)
@@ -2792,7 +2792,7 @@ visit_reference_op_call (tree lhs, gimple stmt)

   if (vnresult)
     {
-      if (vnresult->result_vdef)
+      if (vnresult->result_vdef && vdef)
        changed |= set_ssa_val_to (vdef, vnresult->result_vdef);

       if (!vnresult->result && lhs)


-- 
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413

             reply	other threads:[~2014-01-15 17:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 17:07 Teresa Johnson [this message]
2014-01-15 18:46 ` Jeff Law
2014-01-15 20:00   ` Teresa Johnson
2014-01-15 21:17     ` Teresa Johnson
2014-01-15 21:23       ` Xinliang David Li
2014-01-15 21:33         ` Teresa Johnson

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=CAAe5K+UcnQhUZ6WdOLdMSABa+9FTQLE+jiUJ_QrZ2BwvhAf_gA@mail.gmail.com \
    --to=tejohnson@google.com \
    --cc=davidxl@google.com \
    --cc=gcc-patches@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).