From: Tom de Vries <tom@codesourcery.com>
To: Vladimir Makarov <vmakarov@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH][02/10] -fuse-caller-save - Add new reg-note REG_CALL_DECL
Date: Fri, 29 Mar 2013 13:06:00 -0000 [thread overview]
Message-ID: <20130329130606.205BF4213AB@build1-lucid-cs> (raw)
In-Reply-To: <51558EF4.1030106@mentor.com>
[-- Attachment #1: Type: text/plain, Size: 715 bytes --]
Vladimir,
This patch addes the REG_CALL_DECL reg-note. Using the reg-note we are able to
easily link call_insns to their corresponding declaration, even after the calls
may have been split into an insn (set register to function address) and a
call_insn (call register), which can happen for f.i. sh, and mips
with -mabi-calls.
Thanks,
-Tom
2013-03-29 Radovan Obradovic <robradovic@mips.com>
Tom de Vries <tom@codesourcery.com>
* reg-notes.def (REG_NOTE (CALL_DECL)): New reg-note REG_CALL_DECL.
* calls.c (expand_call, emit_library_call_value_1): Add REG_CALL_DECL
reg-note.
* combine.c (distribute_notes): Handle REG_CALL_DECL reg-note.
* emit-rtl.c (try_split): Same.
[-- Attachment #2: 0002-Add-new-reg-note-REG_CALL_DECL.patch --]
[-- Type: text/x-patch, Size: 3285 bytes --]
diff --git a/gcc/calls.c b/gcc/calls.c
index cdab8e0..39571da 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -3158,6 +3158,19 @@ expand_call (tree exp, rtx target, int ignore)
next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
flags, args_so_far);
+ if (flag_use_caller_save)
+ {
+ rtx last, datum = NULL_RTX;
+ if (fndecl != NULL_TREE)
+ {
+ datum = XEXP (DECL_RTL (fndecl), 0);
+ gcc_assert (datum != NULL_RTX
+ && GET_CODE (datum) == SYMBOL_REF);
+ }
+ last = last_call_insn ();
+ add_reg_note (last, REG_CALL_DECL, datum);
+ }
+
/* If the call setup or the call itself overlaps with anything
of the argument setup we probably clobbered our call address.
In that case we can't do sibcalls. */
@@ -4185,6 +4198,14 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
valreg,
old_inhibit_defer_pop + 1, call_fusage, flags, args_so_far);
+ if (flag_use_caller_save)
+ {
+ rtx last, datum = orgfun;
+ gcc_assert (GET_CODE (datum) == SYMBOL_REF);
+ last = last_call_insn ();
+ add_reg_note (last, REG_CALL_DECL, datum);
+ }
+
/* Right-shift returned value if necessary. */
if (!pcc_struct_value
&& TYPE_MODE (tfom) != BLKmode
diff --git a/gcc/combine.c b/gcc/combine.c
index acb4cb4..191eb71 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -13187,6 +13187,7 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2,
case REG_NORETURN:
case REG_SETJMP:
case REG_TM:
+ case REG_CALL_DECL:
/* These notes must remain with the call. It should not be
possible for both I2 and I3 to be a call. */
if (CALL_P (i3))
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index e412bef..e4843fe 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3473,6 +3473,7 @@ try_split (rtx pat, rtx trial, int last)
int probability;
rtx insn_last, insn;
int njumps = 0;
+ rtx call_insn = NULL_RTX;
/* We're not good at redistributing frame information. */
if (RTX_FRAME_RELATED_P (trial))
@@ -3545,6 +3546,9 @@ try_split (rtx pat, rtx trial, int last)
{
rtx next, *p;
+ gcc_assert (call_insn == NULL_RTX);
+ call_insn = insn;
+
/* Add the old CALL_INSN_FUNCTION_USAGE to whatever the
target may have explicitly specified. */
p = &CALL_INSN_FUNCTION_USAGE (insn);
@@ -3616,6 +3620,11 @@ try_split (rtx pat, rtx trial, int last)
fixup_args_size_notes (NULL_RTX, insn_last, INTVAL (XEXP (note, 0)));
break;
+ case REG_CALL_DECL:
+ gcc_assert (call_insn != NULL_RTX);
+ add_reg_note (call_insn, REG_NOTE_KIND (note), XEXP (note, 0));
+ break;
+
default:
break;
}
diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def
index db61c09..f0b6dad 100644
--- a/gcc/reg-notes.def
+++ b/gcc/reg-notes.def
@@ -216,3 +216,8 @@ REG_NOTE (ARGS_SIZE)
that the return value of a call can be used to reinitialize a
pseudo reg. */
REG_NOTE (RETURNED)
+
+/* Used to mark a call with the function decl called by the call.
+ The decl might not be available in the call due to splitting of the call
+ insn. This note is a SYMBOL_REF. */
+REG_NOTE (CALL_DECL)
next prev parent reply other threads:[~2013-03-29 13:06 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 13:05 [PATCH][IRA] Analysis of register usage of functions for usage by IRA Tom de Vries
2013-01-25 15:46 ` Vladimir Makarov
2013-02-07 19:12 ` Tom de Vries
2013-02-13 22:35 ` Vladimir Makarov
2013-03-14 9:35 ` Tom de Vries
2013-03-14 15:22 ` Vladimir Makarov
2013-03-29 12:54 ` Tom de Vries
2013-03-29 13:06 ` [PATCH][07/10] -fuse-caller-save - Use collected register usage information Tom de Vries
2013-03-29 13:06 ` [PATCH][08/10] -fuse-caller-save - Enable by default at O2 and higher Tom de Vries
2013-03-29 13:06 ` [PATCH][10/10] -fuse-caller-save - Add test-case Tom de Vries
2013-03-29 13:06 ` [PATCH][03/10] -fuse-caller-save - Add implicit parameter to find_all_hard_reg_sets Tom de Vries
2013-03-29 13:06 ` [PATCH][01/10] -fuse-caller-save - Add command line option Tom de Vries
2013-03-29 13:06 ` [PATCH][04/10] -fuse-caller-save - Add TARGET_FN_OTHER_HARD_REG_USAGE hook Tom de Vries
2013-03-29 13:06 ` [PATCH][05/10] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for ARM Tom de Vries
2013-03-29 13:06 ` Tom de Vries [this message]
2013-03-29 13:06 ` [PATCH][09/10] -fuse-caller-save - Add documentation Tom de Vries
2013-03-29 13:06 ` [PATCH][06/10] -fuse-caller-save - Collect register usage information Tom de Vries
2013-03-30 16:10 ` [PATCH][IRA] Analysis of register usage of functions for usage by IRA Tom de Vries
2014-01-09 14:42 ` Richard Earnshaw
2014-01-09 20:56 ` Tom de Vries
2014-01-09 21:10 ` Andi Kleen
2014-01-10 0:22 ` Tom de Vries
2014-01-10 11:39 ` Richard Earnshaw
2014-01-10 16:44 ` Tom de Vries
2014-01-13 16:16 ` Tom de Vries
2014-01-14 10:00 ` Richard Earnshaw
2013-03-30 17:11 ` [PATCH][03/10] -fuse-caller-save - Add implicit parameter to find_all_hard_reg_sets Tom de Vries
2013-03-30 17:11 ` [PATCH][04/10] -fuse-caller-save - Add TARGET_FN_OTHER_HARD_REG_USAGE hook Tom de Vries
2013-12-07 15:07 ` [PATCH] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for MIPS Tom de Vries
2013-12-25 13:02 ` Tom de Vries
2014-01-09 13:51 ` [PING^2][PATCH] " Tom de Vries
2014-01-09 15:31 ` Richard Sandiford
2014-01-09 23:43 ` Tom de Vries
2014-01-10 8:47 ` Richard Sandiford
2014-01-13 15:04 ` Tom de Vries
2013-03-30 17:11 ` [PATCH][01/10] -fuse-caller-save - Add command line option Tom de Vries
2013-03-30 17:11 ` [PATCH][02/10] -fuse-caller-save - Add new reg-note REG_CALL_DECL Tom de Vries
2013-03-30 17:11 ` [PATCH][05/10] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for ARM Tom de Vries
2013-12-06 0:54 ` Tom de Vries
2013-12-09 10:03 ` Richard Earnshaw
2013-03-30 17:11 ` [PATCH][06/10] -fuse-caller-save - Collect register usage information Tom de Vries
2013-03-30 17:12 ` [PATCH][08/10] -fuse-caller-save - Enable by default at O2 and higher Tom de Vries
2013-03-30 17:12 ` [PATCH][09/10] -fuse-caller-save - Add documentation Tom de Vries
2013-03-30 17:12 ` [PATCH][10/10] -fuse-caller-save - Add test-case Tom de Vries
2013-04-28 10:57 ` Richard Sandiford
2013-12-06 0:34 ` Tom de Vries
2013-12-06 8:51 ` Richard Sandiford
2013-03-30 17:12 ` [PATCH][07/10] -fuse-caller-save - Use collected register usage information Tom de Vries
2013-12-06 0:56 ` Tom de Vries
2013-12-06 9:11 ` Paolo Bonzini
2013-12-06 0:47 ` [PATCH][IRA] Analysis of register usage of functions for usage by IRA Tom de Vries
2014-01-14 19:36 ` Vladimir Makarov
2014-05-30 9:20 ` Tom de Vries
2014-09-01 16:41 ` Ulrich Weigand
2014-09-03 16:58 ` Tom de Vries
2014-09-03 18:12 ` Ulrich Weigand
2014-09-03 22:24 ` Tom de Vries
2014-09-04 7:37 ` Tom de Vries
2014-09-04 14:55 ` Vladimir Makarov
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=20130329130606.205BF4213AB@build1-lucid-cs \
--to=tom@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=vmakarov@redhat.com \
/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).