]> gcc.gnu.org Git - gcc.git/commitdiff
[AArch64] Simplify frame pointer logic
authorWilco Dijkstra <wdijkstr@arm.com>
Wed, 23 May 2018 12:28:43 +0000 (12:28 +0000)
committerWilco Dijkstra <wilco@gcc.gnu.org>
Wed, 23 May 2018 12:28:43 +0000 (12:28 +0000)
Simplify frame pointer logic.  Add aarch64_needs_frame_chain to
decide when to emit the frame chain using clearer logic.
Introduce aarch64_use_frame_pointer which contains the value of
-fno-omit-frame-pointer (flag_omit_frame_pointer is set to a magic
value so that the mid-end won't force the frame pointer in all
cases, and leaf frame pointer emission can't be supported).

    gcc/
* config/aarch64/aarch64.c (aarch64_use_frame_pointer):
Add new boolean.
(aarch64_needs_frame_chain): New function.
(aarch64_parse_override_string): Set aarch64_use_frame_pointer.

From-SVN: r260606

gcc/ChangeLog
gcc/config/aarch64/aarch64.c

index 439b8300003c5030584d5a09609bbb88246230f5..04b42be972699d35d68c6756b5083824f69b5a38 100644 (file)
@@ -1,3 +1,10 @@
+2018-05-23  Wilco Dijkstra  <wdijkstr@arm.com>
+
+       * config/aarch64/aarch64.c (aarch64_use_frame_pointer):
+       Add new boolean.
+       (aarch64_needs_frame_chain): New function.
+       (aarch64_parse_override_string): Set aarch64_use_frame_pointer.
+
 2018-05-23  Sudakshina Das  <sudi.das@arm.com>
 
        PR target/84882
index 1df8d620527dea4f4227d226b51557d69ba6132d..774519236663144ce133046177f9fac986e563f1 100644 (file)
@@ -220,6 +220,9 @@ unsigned long aarch64_tune_flags = 0;
 /* Global flag for PC relative loads.  */
 bool aarch64_pcrelative_literal_loads;
 
+/* Global flag for whether frame pointer is enabled.  */
+bool aarch64_use_frame_pointer;
+
 /* Support for command line parsing of boolean flags in the tuning
    structures.  */
 struct aarch64_flag_desc
@@ -3950,6 +3953,25 @@ aarch64_output_probe_stack_range (rtx reg1, rtx reg2)
   return "";
 }
 
+/* Determine whether a frame chain needs to be generated.  */
+static bool
+aarch64_needs_frame_chain (void)
+{
+  /* Force a frame chain for EH returns so the return address is at FP+8.  */
+  if (frame_pointer_needed || crtl->calls_eh_return)
+    return true;
+
+  /* A leaf function cannot have calls or write LR.  */
+  bool is_leaf = crtl->is_leaf && !df_regs_ever_live_p (LR_REGNUM);
+
+  /* Don't use a frame chain in leaf functions if leaf frame pointers
+     are disabled.  */
+  if (flag_omit_leaf_frame_pointer && is_leaf)
+    return false;
+
+  return aarch64_use_frame_pointer;
+}
+
 /* Mark the registers that need to be saved by the callee and calculate
    the size of the callee-saved registers area and frame record (both FP
    and LR may be omitted).  */
@@ -3962,17 +3984,7 @@ aarch64_layout_frame (void)
   if (reload_completed && cfun->machine->frame.laid_out)
     return;
 
-  /* Force a frame chain for EH returns so the return address is at FP+8.  */
-  cfun->machine->frame.emit_frame_chain
-    = frame_pointer_needed || crtl->calls_eh_return;
-
-  /* Emit a frame chain if the frame pointer is enabled.
-     If -momit-leaf-frame-pointer is used, do not use a frame chain
-     in leaf functions which do not use LR.  */
-  if (flag_omit_frame_pointer == 2
-      && !(flag_omit_leaf_frame_pointer && crtl->is_leaf
-          && !df_regs_ever_live_p (LR_REGNUM)))
-    cfun->machine->frame.emit_frame_chain = true;
+  cfun->machine->frame.emit_frame_chain = aarch64_needs_frame_chain ();
 
 #define SLOT_NOT_REQUIRED (-2)
 #define SLOT_REQUIRED     (-1)
@@ -10502,12 +10514,12 @@ aarch64_override_options_after_change_1 (struct gcc_options *opts)
   /* PR 70044: We have to be careful about being called multiple times for the
      same function.  This means all changes should be repeatable.  */
 
-  /* If the frame pointer is enabled, set it to a special value that behaves
-     similar to frame pointer omission.  If we don't do this all leaf functions
-     will get a frame pointer even if flag_omit_leaf_frame_pointer is set.
-     If flag_omit_frame_pointer has this special value, we must force the
-     frame pointer if not in a leaf function.  We also need to force it in a
-     leaf function if flag_omit_frame_pointer is not set or if LR is used.  */
+  /* Set aarch64_use_frame_pointer based on -fno-omit-frame-pointer.
+     Disable the frame pointer flag so the mid-end will not use a frame
+     pointer in leaf functions in order to support -fomit-leaf-frame-pointer.
+     Set x_flag_omit_frame_pointer to the special value 2 to differentiate
+     between -fomit-frame-pointer (1) and -fno-omit-frame-pointer (2).  */
+  aarch64_use_frame_pointer = opts->x_flag_omit_frame_pointer != 1;
   if (opts->x_flag_omit_frame_pointer == 0)
     opts->x_flag_omit_frame_pointer = 2;
 
This page took 0.109465 seconds and 5 git commands to generate.