]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow plugin dumps
authorNathan Sidwell <nathan@acm.org>
Wed, 17 May 2023 23:27:13 +0000 (19:27 -0400)
committerNathan Sidwell <nathan@acm.org>
Fri, 19 May 2023 22:48:43 +0000 (18:48 -0400)
Defer dump option parsing until plugins are initialized.  This allows one to
use plugin names for dumps.

PR other/99451
gcc/
* opts.h (handle_deferred_dump_options): Declare.
* opts-global.cc (handle_common_deferred_options): Do not handle
dump options here.
(handle_deferred_dump_options): New.
* toplev.cc (toplev::main): Call it after plugin init.

gcc/opts-global.cc
gcc/opts.h
gcc/toplev.cc

index 054169158b13ca144e4f06412968246cdf37a470..a61c701621d49f61ff9911acf53fc3ca89056fde 100644 (file)
@@ -401,7 +401,7 @@ handle_common_deferred_options (void)
          break;
 
        case OPT_fdump_:
-         g->get_dumps ()->dump_switch_p (opt->arg);
+         /* Deferred until plugins initialized.  */
          break;
 
         case OPT_fopt_info_:
@@ -494,3 +494,21 @@ handle_common_deferred_options (void)
        }
     }
 }
+
+/* Handle deferred dump options.  */
+
+void
+handle_deferred_dump_options (void)
+{
+  unsigned int i;
+  cl_deferred_option *opt;
+  vec<cl_deferred_option> v;
+
+  if (common_deferred_options)
+    v = *((vec<cl_deferred_option> *) common_deferred_options);
+  else
+    v = vNULL;
+  FOR_EACH_VEC_ELT (v, i, opt)
+    if (opt->opt_index == OPT_fdump_)
+      g->get_dumps ()->dump_switch_p (opt->arg);
+}
index 9959a440ca1beaef0c89020f5d9abdf5f5be2959..00f377f9ca7eb80a078ab22fce4186917acddbdc 100644 (file)
@@ -425,6 +425,7 @@ extern void control_warning_option (unsigned int opt_index, int kind,
 extern char *write_langs (unsigned int mask);
 extern void print_ignored_options (void);
 extern void handle_common_deferred_options (void);
+extern void handle_deferred_dump_options (void);
 unsigned int parse_sanitizer_options (const char *, location_t, int,
                                      unsigned int, int, bool);
 
index 8aec9a2de1086615d8c4974f41af016b8c86f306..6c1a6f443c16f83f5e76127499a6a8956c79ab29 100644 (file)
@@ -2253,6 +2253,10 @@ toplev::main (int argc, char **argv)
 
   initialize_plugins ();
 
+  /* Handle the dump options now that plugins have had a chance to install new
+     passes.  */
+  handle_deferred_dump_options ();
+
   if (version_flag)
     print_version (stderr, "", true);