public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>,
	       Chris Metcalf <cmetcalf@mellanox.com>,
	       Chen Gang <chengang@emindsoft.com.cn>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	       Richard Henderson <rth@redhat.com>,
	Mike Stump <mikestump@comcast.net>,
	       Walter Lee <walt@tilera.com>,
	       "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	       Chen Gang <gang.chen.5i5j@gmail.com>
Subject: Re: [PATCH v3] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount
Date: Mon, 24 Oct 2016 15:28:00 -0000	[thread overview]
Message-ID: <6e750e23-8a13-4bde-2c50-6fa6d34240d9@redhat.com> (raw)
In-Reply-To: <AM4PR0701MB2162AA21ED18C7CAE954C2CFE4D60@AM4PR0701MB2162.eurprd07.prod.outlook.com>

On 10/23/2016 12:11 PM, Bernd Edlinger wrote:
> Hi,
>
> I don't know much about tilegx, but
> I think the patch should work as is.
>
> This is because the
> Save r10 code is a bundle
>
>   {
>   addi sp, sp, -8
>   st sp, r10
>   }
>
> which stores r10 at [sp] and subtracts 8 from sp.
>
> The restore r10 code is actually two bundles:
Thanks for pointing that out!  I totally missed the restore was two bundles.


>
>   addi sp, sp, 8
>   ld r10, sp
>
> This just adds 8 to sp, and loads r10 from there.
Right.  And with the restore as two bundles the semantics of the 
save/restore seem consistent/correct.

>
> I don't know how __mcount is implemented, it must
> be some asm code, almost all functions save the
> lr at [sp] when invoked, but I don't know if __mcount
> does that at all, if it doesn't do that, then the
> adjusting of sp might be unnecessary.
>
> The only thing that might be a problem is that
> the stack is always adjusted in multiples of 16
> on the tilegx platform, see tilegx.h:
>
> #define STACK_BOUNDARY 128
>
> That is counted in bits, and means 16 bytes.
> But your patch adjusts the stack only by 8.
Missed that.  Without knowing the tile ports, I can't say with any 
degree of confidence that it's safe to only adjust by 8 bytes. 
Adjusting by 16 seems safer.

>
> Furthermore, I don't see how the stack unwinding will work
> with this stack adjustment when no .cfi directives
> are emitted, but that is probably not a big problem.
I wouldn't be surprised if the tilegx isn't the only port with this 
problem.   I don't think we've ever been good about making sure the 
unwinders are correct for targets where we profile before the prologue 
and which emit the profiling bits directly rather than representing them 
as RTL.

jeff

  reply	other threads:[~2016-10-24 15:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-23 18:11 Bernd Edlinger
2016-10-24 15:28 ` Jeff Law [this message]
2016-10-29  4:26   ` Chen Gang
  -- strict thread matches above, loose matches on Subject: below --
2016-06-04 13:26 chengang
2016-10-06 13:45 ` Chen Gang
2016-10-19 22:42   ` Jeff Law
2016-10-21 22:16     ` Chen Gang
2016-10-22 22:59       ` Chris Metcalf

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=6e750e23-8a13-4bde-2c50-6fa6d34240d9@redhat.com \
    --to=law@redhat.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=chengang@emindsoft.com.cn \
    --cc=cmetcalf@mellanox.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mikestump@comcast.net \
    --cc=peter.maydell@linaro.org \
    --cc=rth@redhat.com \
    --cc=walt@tilera.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).