public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: chengang@emindsoft.com.cn
To: law@redhat.com
Cc: rth@redhat.com,	mikestump@comcast.net,	gcc-patches@gcc.gnu.org,
	cmetcalf@ezchip.com,	walt@tilera.com,	peter.maydell@linaro.org,
	Chen Gang <chengang@emindsoft.com.cn>
Subject: [PATCH v2] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount
Date: Thu, 02 Jun 2016 22:23:00 -0000	[thread overview]
Message-ID: <1464906189-3453-1-git-send-email-chengang@emindsoft.com.cn> (raw)

From: Chen Gang <chengang@emindsoft.com.cn>

r10 may also be as parameter stack pointer for the nested function, so
need save it before call mcount.

2016-06-03  Chen Gang  <gang.chen.5i5j@gmail.com>

	gcc/
	PR target/71331
	* config/tilegx/tilegx.c (tilegx_function_profiler): Save r10
	to stack before call mcount.
---
 gcc/config/tilegx/tilegx.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index 06c832c..bc41105 100644
--- a/gcc/config/tilegx/tilegx.c
+++ b/gcc/config/tilegx/tilegx.c
@@ -5510,18 +5510,32 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
   if (flag_pic)
     {
       fprintf (file,
+	       "\t{\n"
+	       "\taddi\tsp, sp, -8\n"
+	       "\tst\tsp, r10\n"
+	       "\t}\n"
 	       "\t{\n"
 	       "\tmove\tr10, lr\n"
 	       "\tjal\tplt(%s)\n"
-	       "\t}\n", MCOUNT_NAME);
+	       "\t}\n"
+	       "\taddi\tsp, sp, 8\n"
+	       "\tld\tr10, sp\n",
+	       MCOUNT_NAME);
     }
   else
     {
       fprintf (file,
+	       "\t{\n"
+	       "\taddi\tsp, sp, -8\n"
+	       "\tst\tsp, r10\n"
+	       "\t}\n"
 	       "\t{\n"
 	       "\tmove\tr10, lr\n"
 	       "\tjal\t%s\n"
-	       "\t}\n", MCOUNT_NAME);
+	       "\t}\n"
+	       "\taddi\tsp, sp, 8\n"
+	       "\tld\tr10, sp\n",
+	       MCOUNT_NAME);
     }
 
   tilegx_in_bundle = false;
-- 
1.9.3

             reply	other threads:[~2016-06-02 22:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 22:23 chengang [this message]
2016-06-03  1:21 ` Richard Henderson
2016-06-04 13:04   ` Chen Gang

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=1464906189-3453-1-git-send-email-chengang@emindsoft.com.cn \
    --to=chengang@emindsoft.com.cn \
    --cc=cmetcalf@ezchip.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --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).