diff mbox

[v2] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount

Message ID 1464906189-3453-1-git-send-email-chengang@emindsoft.com.cn
State New
Headers show

Commit Message

Chen Gang June 2, 2016, 10:23 p.m. UTC
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(-)

Comments

Richard Henderson June 3, 2016, 1:21 a.m. UTC | #1
On 06/02/2016 03:23 PM, chengang@emindsoft.com.cn wrote:
>        fprintf (file,
> +	       "\t{\n"
> +	       "\taddi\tsp, sp, -8\n"
> +	       "\tst\tsp, r10\n"
> +	       "\t}\n"
>  	       "\t{\n"

You need only do this if cfun->static_chain_decl is set.


r~
Chen Gang June 4, 2016, 1:10 p.m. UTC | #2
On 6/3/16 09:21, Richard Henderson wrote:
> On 06/02/2016 03:23 PM, chengang@emindsoft.com.cn wrote:
>>        fprintf (file,
>> +           "\t{\n"
>> +           "\taddi\tsp, sp, -8\n"
>> +           "\tst\tsp, r10\n"
>> +           "\t}\n"
>>             "\t{\n"
> 
> You need only do this if cfun->static_chain_decl is set.
> 

OK, thanks, I shall send patch v3 for it, within this week end.

Thanks.
diff mbox

Patch

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;