From: Chen Gang <cheng...@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.5...@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 via email to