[AArch64][2/4] Generate dwarf information for -msign-return-address
authorJiong Wang <jiong.wang@arm.com>
Fri, 20 Jan 2017 00:05:30 +0000 (00:05 +0000)
committerJiong Wang <jiwang@gcc.gnu.org>
Fri, 20 Jan 2017 00:05:30 +0000 (00:05 +0000)
gcc/
* reg-notes.def (CFA_TOGGLE_RA_MANGLE): New reg-note.
* combine-stack-adj.c (no_unhandled_cfa): Handle
REG_CFA_TOGGLE_RA_MANGLE.
* dwarf2cfi.c (dwarf2out_frame_debug): Handle REG_CFA_TOGGLE_RA_MANGLE.
* config/aarch64/aarch64.c (aarch64_expand_prologue): Generates DWARF
info for return address signing.
(aarch64_expand_epilogue): Likewise.

From-SVN: r244667

gcc/ChangeLog
gcc/combine-stack-adj.c
gcc/config/aarch64/aarch64.c
gcc/dwarf2cfi.c
gcc/reg-notes.def

index 1f959bb..2abfea0 100644 (file)
@@ -1,5 +1,15 @@
 2017-01-19  Jiong Wang  <jiong.wang@arm.com>
 
+       * reg-notes.def (CFA_TOGGLE_RA_MANGLE): New reg-note.
+       * combine-stack-adj.c (no_unhandled_cfa): Handle
+       REG_CFA_TOGGLE_RA_MANGLE.
+       * dwarf2cfi.c (dwarf2out_frame_debug): Handle REG_CFA_TOGGLE_RA_MANGLE.
+       * config/aarch64/aarch64.c (aarch64_expand_prologue): Generates DWARF
+       info for return address signing.
+       (aarch64_expand_epilogue): Likewise.
+
+2017-01-19  Jiong Wang  <jiong.wang@arm.com>
+
        * config/aarch64/aarch64-opts.h (aarch64_function_type): New enum.
        * config/aarch64/aarch64-protos.h
        (aarch64_return_address_signing_enabled): New declaration.
index 20cd59a..9ec14a3 100644 (file)
@@ -208,6 +208,7 @@ no_unhandled_cfa (rtx_insn *insn)
       case REG_CFA_SET_VDRAP:
       case REG_CFA_WINDOW_SAVE:
       case REG_CFA_FLUSH_QUEUE:
+      case REG_CFA_TOGGLE_RA_MANGLE:
        return false;
       }
 
index 62baf58..c3992d8 100644 (file)
@@ -3559,7 +3559,11 @@ aarch64_expand_prologue (void)
 
   /* Sign return address for functions.  */
   if (aarch64_return_address_signing_enabled ())
-    emit_insn (gen_pacisp ());
+    {
+      insn = emit_insn (gen_pacisp ());
+      add_reg_note (insn, REG_CFA_TOGGLE_RA_MANGLE, const0_rtx);
+      RTX_FRAME_RELATED_P (insn) = 1;
+    }
 
   if (flag_stack_usage_info)
     current_function_static_stack_size = frame_size;
@@ -3714,7 +3718,11 @@ aarch64_expand_epilogue (bool for_sibcall)
     */
   if (aarch64_return_address_signing_enabled ()
       && (for_sibcall || !TARGET_ARMV8_3 || crtl->calls_eh_return))
-    emit_insn (gen_autisp ());
+    {
+      insn = emit_insn (gen_autisp ());
+      add_reg_note (insn, REG_CFA_TOGGLE_RA_MANGLE, const0_rtx);
+      RTX_FRAME_RELATED_P (insn) = 1;
+    }
 
   /* Stack adjustment for exception handler.  */
   if (crtl->calls_eh_return)
index 2748e2f..2a527c9 100644 (file)
@@ -2098,7 +2098,9 @@ dwarf2out_frame_debug (rtx_insn *insn)
        handled_one = true;
        break;
 
+      case REG_CFA_TOGGLE_RA_MANGLE:
       case REG_CFA_WINDOW_SAVE:
+       /* We overload both of these operations onto the same DWARF opcode.  */
        dwarf2out_frame_debug_cfa_window_save ();
        handled_one = true;
        break;
index ead4a9f..175da11 100644 (file)
@@ -177,6 +177,11 @@ REG_NOTE (CFA_WINDOW_SAVE)
    the rest of the compiler as a CALL_INSN.  */
 REG_NOTE (CFA_FLUSH_QUEUE)
 
+/* Attached to insns that are RTX_FRAME_RELATED_P, toggling the mangling status
+   of return address.  Currently it's only used by AArch64.  The argument is
+   ignored.  */
+REG_NOTE (CFA_TOGGLE_RA_MANGLE)
+
 /* Indicates what exception region an INSN belongs in.  This is used
    to indicate what region to which a call may throw.  REGION 0
    indicates that a call cannot throw at all.  REGION -1 indicates