+2019-10-14 Iain Sandoe <iain@sandoe.co.uk>
+
+ * config/darwin.c: Use unsigned ints for the picbase label
+ counters, initialise the vars explicitly.
+ (update_pic_label_number_if_needed): Move a variable declaration
+ to where it's needed.
+ (machopic_output_function_base_name): Use a more strict checking
+ assert, and and unsigned int for the picbase label counter.
+ (machopic_get_function_picbase): Likewise.
+
2019-10-14 Richard Biener <rguenther@suse.de>
PR middle-end/92046
}
}
-static GTY(()) const char * function_base_func_name;
-static GTY(()) int current_pic_label_num;
-static GTY(()) int emitted_pic_label_num;
-
+static GTY(()) const char * function_base_func_name = NULL;
+static GTY(()) unsigned current_pic_label_num = 0;
+static GTY(()) unsigned emitted_pic_label_num = 0;
+
+/* We need to keep one picbase label per function, but (when we emit code
+ to reload the picbase for setjump receiver) we might need to check for
+ a second use. So, only update the picbase label counter when we see a
+ new function. When there's no function decl, we assume that the call is
+ from the x86 stub generation code. */
static void
update_pic_label_number_if_needed (void)
{
- const char *current_name;
-
- /* When we are generating _get_pc thunks within stubs, there is no current
- function. */
if (current_function_decl)
{
- current_name =
+
+ const char *current_name =
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
if (function_base_func_name != current_name)
{
void
machopic_output_function_base_name (FILE *file)
{
- /* If dynamic-no-pic is on, we should not get here. */
- gcc_assert (!MACHO_DYNAMIC_NO_PIC_P);
+ /* We should only get here for -fPIC. */
+ gcc_checking_assert (MACHOPIC_PURE);
update_pic_label_number_if_needed ();
- fprintf (file, "L%d$pb", current_pic_label_num);
+ fprintf (file, "L%u$pb", current_pic_label_num);
}
char curr_picbasename[32];
const char *
machopic_get_function_picbase (void)
{
- /* If dynamic-no-pic is on, we should not get here. */
- gcc_assert (!MACHO_DYNAMIC_NO_PIC_P);
+ /* We should only get here for -fPIC. */
+ gcc_checking_assert (MACHOPIC_PURE);
update_pic_label_number_if_needed ();
- snprintf (curr_picbasename, 32, "L%d$pb", current_pic_label_num);
+ snprintf (curr_picbasename, 32, "L%u$pb", current_pic_label_num);
return (const char *) curr_picbasename;
}