[Darwin, machopic 9/n] Minor code clean-ups.
authorIain Sandoe <iain@sandoe.co.uk>
Mon, 14 Oct 2019 19:18:34 +0000 (19:18 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Mon, 14 Oct 2019 19:18:34 +0000 (19:18 +0000)
Improve some comments, replace some asserts that have been in the code
base for years with checking-asserts.

gcc/ChangeLog:

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.

From-SVN: r276967

gcc/ChangeLog
gcc/config/darwin.c

index 5db905719bac8c8d1b105696977c0ce3f29d12a0..adc3550fc39a6ac8d916591c22f4eb6cd7e67085 100644 (file)
@@ -1,3 +1,13 @@
+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
index 8635fc2b441caba4ffecc27c88915d0705d82b10..1d386e06703fac2e1f053b3bb94f17d861c1160c 100644 (file)
@@ -375,20 +375,22 @@ machopic_gen_offset (rtx orig)
     }
 }
 
-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)
        {
@@ -406,11 +408,11 @@ update_pic_label_number_if_needed (void)
 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];
@@ -418,11 +420,11 @@ 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;
 }