From: Richard Henderson <rth@redhat.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: jh@suse.cz, gcc@gcc.gnu.org
Subject: Re: [trans-mem] cgraph edges vs function cloning
Date: Mon, 27 Jul 2009 23:08:00 -0000 [thread overview]
Message-ID: <4A6E333E.7060402@redhat.com> (raw)
In-Reply-To: <20090723172828.GA20017@atrey.karlin.mff.cuni.cz>
> struct cgraph_edge *edge = cgraph_edge (id->src_node, orig_stmt);
POINT_A
> int flags;
>
> switch (id->transform_call_graph_edges)
> {
> case CB_CGE_DUPLICATE:
> if (edge)
> cgraph_clone_edge (edge, id->dst_node, stmt,
> REG_BR_PROB_BASE, 1,
> edge->frequency, true);
> break;
>
> case CB_CGE_MOVE_CLONES:
> cgraph_set_call_stmt_including_clones (id->dst_node, orig_stmt, stmt);
> break;
>
> case CB_CGE_MOVE:
> if (edge)
> cgraph_set_call_stmt (edge, stmt);
POINT_B
> break;
>
> default:
> gcc_unreachable ();
> }
>
> edge = cgraph_edge (id->src_node, orig_stmt);
POINT_C
> /* Constant propagation on argument done during inlining
> may create new direct call. Produce an edge for it. */
> if ((!edge
> || (edge->indirect_call
> && id->transform_call_graph_edges == CB_CGE_MOVE_CLONES))
> && is_gimple_call (stmt)
> && (fn = gimple_call_fndecl (stmt)) != NULL)
POINT_D
This code cannot possibly work.
We begin by looking up the edge at POINT_A.
We then move the edge at POINT_B.
We then look up the edge *again* at POINT_C.
Ought we be surprised when we do not find the edge at POINT_D?
After POINT_D, we "fix" the missing edge by creating a new one, which of
course is a duplicate, which then of course leads to verification failure.
I think POINT_B is additionally buggy in that we've just corrupted
the cgraph node for the source function when we wanted to change the
destination function. I believe we should have done
case CB_CGE_MOVE:
edge = cgraph_edge (id->dst_node, orig_stmt);
cgraph_set_call_stmt (edge, stmt);
// Possibly fix up indirect->direct call here.
Although, frankly I think it would be easiest to *only* create edges
here. There ought to be no problem doing the cgraph_clone_edge here
instead of in cgraph_copy_node_for_versioning. That would still
preserve all of the information you wanted that's attached to the edges.
Thoughts?
r~
next prev parent reply other threads:[~2009-07-27 23:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-23 1:39 Richard Henderson
2009-07-23 17:28 ` Jan Hubicka
2009-07-23 20:59 ` Richard Henderson
2009-07-27 23:08 ` Richard Henderson [this message]
2009-07-28 17:16 ` Jan Hubicka
2009-07-28 17:44 ` Richard Henderson
2009-07-28 23:26 ` Richard Henderson
2009-07-29 6:43 ` Jan Hubicka
2009-07-29 7:27 ` Martin Jambor
2009-07-29 16:24 ` Richard Henderson
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=4A6E333E.7060402@redhat.com \
--to=rth@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=jh@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).