]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
-fuse-caller-save - Add new reg-note REG_CALL_DECL
authorRadovan Obradovic <robradovic@mips.com>
Thu, 24 Apr 2014 09:34:15 +0000 (09:34 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Thu, 24 Apr 2014 09:34:15 +0000 (09:34 +0000)
2014-04-24  Radovan Obradovic  <robradovic@mips.com>
            Tom de Vries  <tom@codesourcery.com>

* reg-notes.def (REG_NOTE (CALL_DECL)): New reg-note REG_CALL_DECL.
* calls.c (expand_call, emit_library_call_value_1): Add REG_CALL_DECL
reg-note.
* combine.c (distribute_notes): Handle REG_CALL_DECL reg-note.
* emit-rtl.c (try_split): Same.

Co-Authored-By: Tom de Vries <tom@codesourcery.com>
From-SVN: r209744

gcc/ChangeLog
gcc/calls.c
gcc/combine.c
gcc/emit-rtl.c
gcc/reg-notes.def

index edf0467334dd3424182e63dbf42ceceb23c6df42..662e08377eed463b0cd2327fe20d50c9d57df2e3 100644 (file)
@@ -1,3 +1,12 @@
+2014-04-24  Radovan Obradovic  <robradovic@mips.com>
+            Tom de Vries  <tom@codesourcery.com>
+
+       * reg-notes.def (REG_NOTE (CALL_DECL)): New reg-note REG_CALL_DECL.
+       * calls.c (expand_call, emit_library_call_value_1): Add REG_CALL_DECL
+       reg-note.
+       * combine.c (distribute_notes): Handle REG_CALL_DECL reg-note.
+       * emit-rtl.c (try_split): Same.
+
 2014-04-24  Radovan Obradovic  <robradovic@mips.com>
             Tom de Vries  <tom@codesourcery.com>
 
index f0c92ddc0182d3216a90e0dc06e9b3a40bca9a45..e798c7a03494576c4f9c446bc34f6758a3977dbf 100644 (file)
@@ -3178,6 +3178,19 @@ expand_call (tree exp, rtx target, int ignore)
                   next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
                   flags, args_so_far);
 
+      if (flag_use_caller_save)
+       {
+         rtx last, datum = NULL_RTX;
+         if (fndecl != NULL_TREE)
+           {
+             datum = XEXP (DECL_RTL (fndecl), 0);
+             gcc_assert (datum != NULL_RTX
+                         && GET_CODE (datum) == SYMBOL_REF);
+           }
+         last = last_call_insn ();
+         add_reg_note (last, REG_CALL_DECL, datum);
+       }
+
       /* If the call setup or the call itself overlaps with anything
         of the argument setup we probably clobbered our call address.
         In that case we can't do sibcalls.  */
@@ -4205,6 +4218,14 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
               valreg,
               old_inhibit_defer_pop + 1, call_fusage, flags, args_so_far);
 
+  if (flag_use_caller_save)
+    {
+      rtx last, datum = orgfun;
+      gcc_assert (GET_CODE (datum) == SYMBOL_REF);
+      last = last_call_insn ();
+      add_reg_note (last, REG_CALL_DECL, datum);
+    }
+
   /* Right-shift returned value if necessary.  */
   if (!pcc_struct_value
       && TYPE_MODE (tfom) != BLKmode
index 9a78c064945c03ea095fe6c9e4b91fca9a0587cc..e051f5e4d1fe38067e266826181366e450c3d2a4 100644 (file)
@@ -13269,6 +13269,7 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2,
        case REG_NORETURN:
        case REG_SETJMP:
        case REG_TM:
+       case REG_CALL_DECL:
          /* These notes must remain with the call.  It should not be
             possible for both I2 and I3 to be a call.  */
          if (CALL_P (i3))
index 4736f8d0dccdcbab1a6da41620df64243ab7e61f..e3fd0a5132b41311f9581fb320b6b04cd90fdc8f 100644 (file)
@@ -3427,6 +3427,7 @@ try_split (rtx pat, rtx trial, int last)
   int probability;
   rtx insn_last, insn;
   int njumps = 0;
+  rtx call_insn = NULL_RTX;
 
   /* We're not good at redistributing frame information.  */
   if (RTX_FRAME_RELATED_P (trial))
@@ -3499,6 +3500,9 @@ try_split (rtx pat, rtx trial, int last)
          {
            rtx next, *p;
 
+           gcc_assert (call_insn == NULL_RTX);
+           call_insn = insn;
+
            /* Add the old CALL_INSN_FUNCTION_USAGE to whatever the
               target may have explicitly specified.  */
            p = &CALL_INSN_FUNCTION_USAGE (insn);
@@ -3571,6 +3575,11 @@ try_split (rtx pat, rtx trial, int last)
          fixup_args_size_notes (NULL_RTX, insn_last, INTVAL (XEXP (note, 0)));
          break;
 
+       case REG_CALL_DECL:
+         gcc_assert (call_insn != NULL_RTX);
+         add_reg_note (call_insn, REG_NOTE_KIND (note), XEXP (note, 0));
+         break;
+
        default:
          break;
        }
index 31cd171b54268e1b81c609fa07415af0f15ee6f5..831fe82272aa2b4dfd91d7c28fadf6ba60e33a29 100644 (file)
@@ -211,3 +211,8 @@ REG_NOTE (ARGS_SIZE)
    that the return value of a call can be used to reinitialize a
    pseudo reg.  */
 REG_NOTE (RETURNED)
+
+/* Used to mark a call with the function decl called by the call.
+   The decl might not be available in the call due to splitting of the call
+   insn.  This note is a SYMBOL_REF.  */
+REG_NOTE (CALL_DECL)