#include "tree-ssa-address.h"
#include "output.h"
#include "builtins.h"
+#include "opts.h"
/* Some systems use __main in a way incompatible with its use in gcc, in these
cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
if (crtl->tail_call_emit)
fixup_tail_calls ();
- unsigned HOST_WIDE_INT patch_area_size = function_entry_patch_area_size;
- unsigned HOST_WIDE_INT patch_area_entry = function_entry_patch_area_start;
+ HOST_WIDE_INT patch_area_size, patch_area_entry;
+ parse_and_check_patch_area (flag_patchable_function_entry, false,
+ &patch_area_size, &patch_area_entry);
tree patchable_function_entry_attr
= lookup_attribute ("patchable_function_entry",
Variable
int flag_debug_asm
-; How many NOP insns to place at each function entry by default
-Variable
-HOST_WIDE_INT function_entry_patch_area_size
-
-; And how far the real asm entry point is into this area
-Variable
-HOST_WIDE_INT function_entry_patch_area_start
-
; Balance between GNAT encodings and standard DWARF to emit.
Variable
enum dwarf_gnat_encodings gnat_encodings = DWARF_GNAT_ENCODINGS_DEFAULT
Enable function reordering that improves code placement.
fpatchable-function-entry=
-Common Joined Optimization
+Common Var(flag_patchable_function_entry) Joined Optimization
Insert NOP instructions at each function entry.
frandom-seed
}
}
+/* Parse argument of -fpatchable-function-entry option ARG and store
+ corresponding values to PATCH_AREA_SIZE and PATCH_AREA_START.
+ If REPORT_ERROR is set to true, generate error for a problematic
+ option arguments. */
+
+void
+parse_and_check_patch_area (const char *arg, bool report_error,
+ HOST_WIDE_INT *patch_area_size,
+ HOST_WIDE_INT *patch_area_start)
+{
+ *patch_area_size = 0;
+ *patch_area_start = 0;
+
+ if (arg == NULL)
+ return;
+
+ char *patch_area_arg = xstrdup (arg);
+ char *comma = strchr (patch_area_arg, ',');
+ if (comma)
+ {
+ *comma = '\0';
+ *patch_area_size = integral_argument (patch_area_arg);
+ *patch_area_start = integral_argument (comma + 1);
+ }
+ else
+ *patch_area_size = integral_argument (patch_area_arg);
+
+ if (*patch_area_size < 0
+ || *patch_area_size > USHRT_MAX
+ || *patch_area_start < 0
+ || *patch_area_start > USHRT_MAX
+ || *patch_area_size < *patch_area_start)
+ if (report_error)
+ error ("invalid arguments for %<-fpatchable-function-entry%>");
+
+ free (patch_area_arg);
+}
+
/* Print help when OPT__help_ is set. */
void
case OPT_fpatchable_function_entry_:
{
- char *patch_area_arg = xstrdup (arg);
- char *comma = strchr (patch_area_arg, ',');
- if (comma)
- {
- *comma = '\0';
- function_entry_patch_area_size =
- integral_argument (patch_area_arg);
- function_entry_patch_area_start =
- integral_argument (comma + 1);
- }
- else
- {
- function_entry_patch_area_size =
- integral_argument (patch_area_arg);
- function_entry_patch_area_start = 0;
- }
- if (function_entry_patch_area_size < 0
- || function_entry_patch_area_size > USHRT_MAX
- || function_entry_patch_area_start < 0
- || function_entry_patch_area_start > USHRT_MAX
- || function_entry_patch_area_size
- < function_entry_patch_area_start)
- error ("invalid arguments for %<-fpatchable-function-entry%>");
- free (patch_area_arg);
+ HOST_WIDE_INT patch_area_size, patch_area_start;
+ parse_and_check_patch_area (arg, true, &patch_area_size,
+ &patch_area_start);
}
break;
flag_sanitize &= ~SANITIZE_HWADDRESS;
}
+ HOST_WIDE_INT patch_area_size, patch_area_start;
+ parse_and_check_patch_area (flag_patchable_function_entry, false,
+ &patch_area_size, &patch_area_start);
+
/* Do not use IPA optimizations for register allocation if profiler is active
or patchable function entries are inserted for run-time instrumentation
or port does not emit prologue and epilogue as RTL. */
- if (profile_flag || function_entry_patch_area_size
+ if (profile_flag || patch_area_size
|| !targetm.have_prologue () || !targetm.have_epilogue ())
flag_ipa_ra = 0;