aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2018-05-23 12:28:43 +0000
committerWilco Dijkstra <wilco@gcc.gnu.org>2018-05-23 12:28:43 +0000
commitd6cb6d6a1c2279deebb45e658cde66f1f91cae05 (patch)
treea9528dadde928e8289c84df482ee2af0c713cd29 /gcc
parent675d044c852044111c656f86c273a0c5f11ad3d5 (diff)
downloadgcc-d6cb6d6a1c2279deebb45e658cde66f1f91cae05.zip
gcc-d6cb6d6a1c2279deebb45e658cde66f1f91cae05.tar.gz
gcc-d6cb6d6a1c2279deebb45e658cde66f1f91cae05.tar.bz2
[AArch64] Simplify frame pointer logic
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/aarch64/aarch64.c46
2 files changed, 36 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 439b830..04b42be 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 1df8d62..7745192 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -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;