public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jan Hubicka <hubicka@ucw.cz>
Subject: [PATCH, PR 67133] Always change gimple fntype in cgraph_edge::redirect_call_stmt_to_callee
Date: Mon, 17 Aug 2015 13:46:00 -0000	[thread overview]
Message-ID: <20150817133857.GY2569@virgil.suse.cz> (raw)

Hi,

even though PR 67133 has been avoided by a different patch, I believe
the patch below is the correct fix.  It modifies the function that
changes call statements according to call graph edges so that it
changes the fntype of the call statements also when
combined_args_to_skip is NULL.  This code path is taken for example
when a call is redirected to __builtin_unreachable and then the type
of the callee function is likely to mismatch with fntype of the
statement, which can confuse the compiler later on.

If we agree it is a good idea, I'd like to also propose a patch
making the gimple verifier check whether fntypes of direct call
statements match the types of the callee (or at least that they have
the same number of same-typed arguments).

The patch has been bootstrapped and tested on x86_64-linux, the
testcase is already checked in.  OK for trunk?

Thanks,

Martin


2015-08-17  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/67133
	* cgraph.c (redirect_call_stmt_to_callee): Set gimple call fntype also
	when redirecting without removing any parameters.

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 22a9852..5e5b308 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1461,6 +1461,7 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
     {
       new_stmt = e->call_stmt;
       gimple_call_set_fndecl (new_stmt, e->callee->decl);
+      gimple_call_set_fntype (new_stmt, TREE_TYPE (e->callee->decl));
       update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
     }
 

             reply	other threads:[~2015-08-17 13:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-17 13:46 Martin Jambor [this message]
2015-08-17 13:53 ` Jan Hubicka
2015-08-17 14:13   ` Richard Biener

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=20150817133857.GY2569@virgil.suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.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).