/* 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
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). */
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)
/* 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;