All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rdsandiford@googlemail.com>
To: David Daney <ddaney@caviumnetworks.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	linux-mips@linux-mips.org, wuzhangjin@gmail.com,
	Adam Nemet <anemet@caviumnetworks.com>,
	rostedt@goodmis.org, Thomas Gleixner <tglx@linutronix.de>,
	Ralf Baechle <ralf@linux-mips.org>,
	Nicholas Mc Guire <der.herr@hofr.at>
Subject: Re: [PATCH] MIPS: Add option to pass return address location to _mcount.
Date: Tue, 27 Oct 2009 21:20:34 +0000	[thread overview]
Message-ID: <87ljiwr0t9.fsf@firetop.home> (raw)
In-Reply-To: <4AE5F392.5020405@caviumnetworks.com> (David Daney's message of "Mon\, 26 Oct 2009 12\:08\:02 -0700")

David Daney <ddaney@caviumnetworks.com> writes:
>> Looks good otherwise, but I'd be interested in other suggestions for
>> the option name.  I kept misreading "raloc" as a typo for "reloc".
>
> Well how about raaddr?  (Return-Address Address)

Taking Wu Zhangjin's suggestion of an extra dash, how about
-mmcount-ra-address?

> +@option{-mmcount-raaddr} can be used in conjunction with @option{-pg}
> +and a specially coded @code{_mcount} function to record function exit

Doc conventions require "specially-coded", I think.  We should
mention the $12 register too, and the treatment of leaf functions.
How about:

--------------------------
Allow (do not allow) @code{_mcount} to modify the calling function's
return address.  When enabled, this option extends the usual @code{_mcount}
interface with a new @var{ra-address} parameter, which has type
@code{intptr_t *} and is passed in register @code{$12}.  @code{_mcount}
can then modify the return address by doing both of the following:
@itemize
@item
Returning the new address in register @code{$31}.
@item
Storing the new address in @code{*@var{ra-address}},
if @var{ra-address} is nonnull.
@end @itemize

The default is @option{-mno-mcount-ra-address}.
--------------------------

> +/* { dg-do compile } */
> +/* { dg-options "-O2 -pg -mmcount-raaddr -march=mips64 -mabi=64 -mno-abicalls -msym32" } */

This is a general feature, so I'd rather test with as few special options
as possible.  Just "-O2 -pg" if we can.  Same with the other tests.

Sorry to ask, but while you're here, would you mind fixing a couple
of pre-existing formatting problems too?  Namely:

> +      /*  For TARGET_LONG_CALLS use $3 for the address of _mcount.  */

Only one space for "For" and

> +  if (!TARGET_NEWABI)
> +    {
> +      fprintf (file,
> +	       "\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from  stack\n",
> +	       TARGET_64BIT ? "dsubu" : "subu",
> +	       reg_names[STACK_POINTER_REGNUM],
> +	       reg_names[STACK_POINTER_REGNUM],
> +	       Pmode == DImode ? 16 : 8);
> +    }

No braces here.

As far as the new bits are concerned:

> +      /* If TARGET_MCOUNT_RAADDR load $12 with the address of the ra save
> +	 location.  */
> +      if (cfun->machine->frame.ra_fp_offset == 0)
> +	/* ra not saved, pass zero.  */
> +	fprintf (file, "\tmove\t%s,%s\t\t# address of ra\n",
> +		 reg_names[12], reg_names[0]);

Let's drop the "# address of ra" comment.  We don't add comments to
the other bits.

Everything in the following block:

> +      else if (SMALL_OPERAND (cfun->machine->frame.ra_fp_offset))
> +	fprintf (file,
> +		 "\t%s\t%s,%s," HOST_WIDE_INT_PRINT_DEC "\t\t# address of ra\n",
> +		 Pmode == DImode ? "daddiu" : "addiu",
> +		 reg_names[12], reg_names[STACK_POINTER_REGNUM],
> +		 cfun->machine->frame.ra_fp_offset);
> +      else
> +	{
> +	  fprintf (file,
> +		   "\t%s\t%s," HOST_WIDE_INT_PRINT_DEC "\n",
> +		   Pmode == DImode ? "dli" : "li",
> +		   reg_names[12],
> +		   cfun->machine->frame.ra_fp_offset);
> +	  fprintf (file, "\t%s\t%s,%s,%s\t\t# address of ra\n",
> +		   Pmode == DImode ? "daddu" : "addu",
> +		   reg_names[12], reg_names[12],
> +		   reg_names[STACK_POINTER_REGNUM]);
> +	}

reduces to:

      else
	fprintf (file, "\t%s\t%s," HOST_WIDE_INT_PRINT_DEC "(%s)",
		 Pmode == DImode ? "dla" : "la", reg_names[12],
		 cfun->machine->frame.ra_fp_offset,
		 reg_names[STACK_POINTER_REGNUM]);

OK with those changes, thanks, if it passing testing, and if
Ralf is happy with the linux side.

Richard

  parent reply	other threads:[~2009-10-27 21:20 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1256135456.git.wuzhangjin@gmail.com>
2009-10-21 14:34 ` [PATCH -v4 1/9] tracing: convert trace_clock_local() as weak function Wu Zhangjin
2009-10-21 14:34 ` [PATCH -v4 2/9] MIPS: add mips_timecounter_read() to get high precision timestamp Wu Zhangjin
2009-10-22 13:03   ` pajko
2009-10-21 14:34 ` [PATCH -v4 3/9] tracing: add MIPS specific trace_clock_local() Wu Zhangjin
2009-10-21 14:46   ` Steven Rostedt
2009-10-21 15:11     ` Wu Zhangjin
2009-10-21 14:34 ` [PATCH -v4 4/9] tracing: add static function tracer support for MIPS Wu Zhangjin
2009-10-21 15:24   ` Steven Rostedt
2009-10-22 17:47     ` Wu Zhangjin
2009-10-22 17:59       ` Steven Rostedt
2009-10-22 18:34         ` Wu Zhangjin
2009-10-22 18:34       ` David Daney
2009-10-22 19:13         ` Wu Zhangjin
2009-10-22 20:30         ` Adam Nemet
2009-10-22 20:52           ` Steven Rostedt
2009-10-22 21:09             ` Frederic Weisbecker
2009-10-22 21:29             ` Adam Nemet
2009-10-22 21:55               ` Steven Rostedt
2009-10-23  1:09                 ` Wu Zhangjin
2009-10-22 22:17         ` Richard Sandiford
2009-10-23  9:32           ` Wu Zhangjin
2009-10-23 22:48           ` [PATCH] MIPS: Add option to pass return address location to _mcount. Was: " David Daney
2009-10-24  9:12             ` Richard Sandiford
2009-10-24 15:53               ` Wu Zhangjin
2009-10-26 19:08               ` [PATCH] MIPS: Add option to pass return address location to _mcount David Daney
2009-10-27  1:04                 ` Wu Zhangjin
2009-10-27 21:20                 ` Richard Sandiford [this message]
2009-10-29  6:44                   ` Wu Zhangjin
2009-10-29 16:32                     ` David Daney
2009-10-29 18:11                   ` David Daney
2009-10-23  7:21         ` [PATCH -v4 4/9] tracing: add static function tracer support for MIPS Wu Zhangjin
2009-10-21 14:34 ` [PATCH -v4 5/9] tracing: enable HAVE_FUNCTION_TRACE_MCOUNT_TEST " Wu Zhangjin
2009-10-21 14:35 ` [PATCH -v4 6/9] tracing: add an endian argument to scripts/recordmcount.pl Wu Zhangjin
2009-10-21 15:26   ` Steven Rostedt
2009-10-21 14:35 ` [PATCH -v4 7/9] tracing: add dynamic function tracer support for MIPS Wu Zhangjin
2009-10-21 14:35 ` [PATCH -v4 8/9] tracing: not trace mips_timecounter_init() in MIPS Wu Zhangjin
2009-10-21 14:35 ` [PATCH -v4 9/9] tracing: add function graph tracer support for MIPS Wu Zhangjin
2009-10-21 15:21   ` Wu Zhangjin
2009-10-21 16:14     ` Steven Rostedt
2009-10-21 16:12   ` Steven Rostedt
2009-10-21 16:37     ` David Daney
2009-10-21 16:46       ` Steven Rostedt
2009-10-21 17:07         ` David Daney
2009-10-21 17:23           ` Steven Rostedt
2009-10-21 17:48             ` David Daney
2009-10-21 18:09               ` Steven Rostedt
2009-10-21 18:17                 ` Nicholas Mc Guire
2009-10-21 18:34                   ` Steven Rostedt
2009-10-21 18:25                 ` David Daney
2009-10-22 11:38             ` Wu Zhangjin
2009-10-22 13:17               ` Steven Rostedt
2009-10-22 13:31                 ` Wu Zhangjin
2009-10-22 15:20                   ` Steven Rostedt
2009-10-22 15:59               ` David Daney
2009-10-22 16:11                 ` Steven Rostedt
2009-10-22 16:16                   ` David Daney
2009-10-22 18:00                     ` Steven Rostedt
2009-10-22 17:39     ` Wu Zhangjin
2009-10-22 17:58       ` Steven Rostedt
2009-10-22 11:37   ` pajko
2009-10-25 10:48     ` Wu Zhangjin
2009-10-25 10:48       ` Wu Zhangjin
2009-10-25 13:37       ` Patrik Kluba
2009-10-25 13:37         ` Patrik Kluba
2009-10-25 14:22         ` Wu Zhangjin
2009-10-25 15:55       ` Richard Sandiford
2009-10-29  8:14 [PATCH] MIPS: Add option to pass return address location to _mcount Wu Zhangjin
2009-10-29  8:14 ` Wu Zhangjin
2009-10-29 16:24 ` David Daney

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=87ljiwr0t9.fsf@firetop.home \
    --to=rdsandiford@googlemail.com \
    --cc=anemet@caviumnetworks.com \
    --cc=ddaney@caviumnetworks.com \
    --cc=der.herr@hofr.at \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=wuzhangjin@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.