re PR target/71331 (target-tilegx: nested-function-4.c: r10 is conflict which is...
authorChen Gang <gang.chen.5i5j@gmail.com>
Tue, 29 Nov 2016 18:33:20 +0000 (18:33 +0000)
committerJeff Law <law@gcc.gnu.org>
Tue, 29 Nov 2016 18:33:20 +0000 (11:33 -0700)
PR target/71331
* config/tilegx/tilegx.c (tilegx_function_profiler): Save r10
to stack before call mcount.
(tilegx_can_use_return_insn_p): Clean up code.

From-SVN: r242969

gcc/ChangeLog
gcc/config/tilegx/tilegx.c

index bd8f1b0c7c8a84c35aeaef0f39138ad24d9175f9..16224c78659db85104d0b872bcee19bd45d2a68f 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-29  Chen Gang  <gang.chen.5i5j@gmail.com>
+
+       PR target/71331
+       * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10
+       to stack before call mcount.
+       (tilegx_can_use_return_insn_p): Clean up code.
+
 2016-11-29  Pitchumani Sivanupandi <pitchumani.s@atmel.com>
 
        * config/avr/avr-arch.h (avr_mcu_t): Add flash_size member.
index ab12b60567daf0e13c79114ca695c6cce7209713..d2135520a00446cca7541e461b609b79b2f7ddaf 100644 (file)
@@ -3882,8 +3882,8 @@ bool
 tilegx_can_use_return_insn_p (void)
 {
   return (reload_completed
-         && cfun->static_chain_decl == 0
-         && compute_total_frame_size () == 0
+         && !cfun->static_chain_decl
+         && !compute_total_frame_size ()
          && tilegx_current_function_is_leaf ()
          && !crtl->profile && !df_regs_ever_live_p (TILEGX_LINK_REGNUM));
 }
@@ -5512,6 +5512,15 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
       fprintf (file, "\t}\n");
     }
 
+  if (cfun->static_chain_decl)
+    {
+      fprintf (file,
+              "\t{\n"
+              "\taddi\tsp, sp, -16\n"
+              "\tst\tsp, r10\n"
+              "\t}\n");
+    }
+
   if (flag_pic)
     {
       fprintf (file,
@@ -5529,6 +5538,13 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
               "\t}\n", MCOUNT_NAME);
     }
 
+  if (cfun->static_chain_decl)
+    {
+      fprintf (file,
+              "\taddi\tsp, sp, 16\n"
+              "\tld\tr10, sp\n");
+    }
+
   tilegx_in_bundle = false;
 }