public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/remove-AUTODETECT_VALUE-opt-value-v2)] Eliminate AUTODETECT_VALUE usage in options.
@ 2021-10-13 14:18 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-10-13 14:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:705c28bf1caf320599741ff9d7eb7c6dd8eccf5d

commit 705c28bf1caf320599741ff9d7eb7c6dd8eccf5d
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Oct 12 14:31:50 2021 +0200

    Eliminate AUTODETECT_VALUE usage in options.
    
    gcc/ChangeLog:
    
            * common.opt: Stop using AUTODETECT_VALUE as Init value.
            * toplev.c (AUTODETECT_VALUE): Remove it.
            (process_options): Do not compare option values to
            AUTODETECT_VALUE, but use rather OPTION_SET_P macro.
            For flag_var_tracking, do not reset it if it is already set
            based on flag_var_tracking_uninit.

Diff:
---
 gcc/common.opt   | 26 +++++++++++---------------
 gcc/optc-gen.awk |  8 ++++++++
 gcc/opts.c       |  1 +
 gcc/toplev.c     | 39 +++++++++++----------------------------
 4 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 1eedfeaf539..83489a83d43 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3003,19 +3003,16 @@ Common Undocumented Var(flag_use_linker_plugin)
 
 ; Positive if we should track variables, negative if we should run
 ; the var-tracking pass only to discard debug annotations, zero if
-; we're not to run it.  When flag_var_tracking == 2 (AUTODETECT_VALUE) it
-; will be set according to optimize, debug_info_level and debug_hooks
-; in process_options ().
+; we're not to run it.
 fvar-tracking
-Common Var(flag_var_tracking) Init(2) PerFunction
+Common Var(flag_var_tracking) PerFunction EnabledBy(fvar-tracking-uninit)
 Perform variable tracking.
 
 ; Positive if we should track variables at assignments, negative if
 ; we should run the var-tracking pass only to discard debug
-; annotations.  When flag_var_tracking_assignments ==
-; AUTODETECT_VALUE it will be set according to flag_var_tracking.
+; annotations.
 fvar-tracking-assignments
-Common Var(flag_var_tracking_assignments) Init(2) PerFunction
+Common Var(flag_var_tracking_assignments) PerFunction
 Perform variable tracking by annotating assignments.
 
 ; Nonzero if we should toggle flag_var_tracking_assignments after
@@ -3026,10 +3023,9 @@ Toggle -fvar-tracking-assignments.
 
 ; Positive if we should track uninitialized variables, negative if
 ; we should run the var-tracking pass only to discard debug
-; annotations.  When flag_var_tracking_uninit == AUTODETECT_VALUE it
-; will be set according to flag_var_tracking.
+; annotations.
 fvar-tracking-uninit
-Common Var(flag_var_tracking_uninit) PerFunction
+Common Var(flag_var_tracking_uninit) PerFunction EnabledBy(fvar-tracking)
 Perform variable tracking and also tag variables that are uninitialized.
 
 ; Alias to enable both -ftree-loop-vectorize and -ftree-slp-vectorize.
@@ -3190,11 +3186,11 @@ Common Driver RejectNegative JoinedOrMissing
 Generate debug information in default format.
 
 gas-loc-support
-Common Driver Var(dwarf2out_as_loc_support) Init(2)
+Common Driver Var(dwarf2out_as_loc_support)
 Assume assembler support for (DWARF2+) .loc directives.
 
 gas-locview-support
-Common Driver Var(dwarf2out_as_locview_support) Init(2)
+Common Driver Var(dwarf2out_as_locview_support)
 Assume assembler support for view in (DWARF2+) .loc directives.
 
 gcoff
@@ -3248,7 +3244,7 @@ Common Driver JoinedOrMissing
 Generate debug information in default extended format.
 
 ginline-points
-Common Driver Var(debug_inline_points) Init(2)
+Common Driver Var(debug_inline_points)
 Generate extended entry point information for inlined functions.
 
 ginternal-reset-location-views
@@ -3288,7 +3284,7 @@ Common Driver JoinedOrMissing Negative(gvms)
 Generate debug information in extended STABS format.
 
 gstatement-frontiers
-Common Driver Var(debug_nonbind_markers_p) Init(2)
+Common Driver Var(debug_nonbind_markers_p)
 Emit progressive recommended breakpoint locations.
 
 gstrict-dwarf
@@ -3304,7 +3300,7 @@ Common Driver Var(flag_gtoggle)
 Toggle debug information generation.
 
 gvariable-location-views
-Common Driver Var(debug_variable_location_views, 1) Init(2)
+Common Driver Var(debug_variable_location_views, 1)
 Augment variable location lists with progressive views.
 
 gvariable-location-views=incompat5
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 77e598efd60..ba97a637607 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -118,6 +118,7 @@ for (i = 1; i <= n_headers; i++)
 print "#include " quote "opts.h" quote
 print "#include " quote "intl.h" quote
 print "#include " quote "insn-attr-common.h" quote
+print "#include " quote "sbitmap.h" quote
 print ""
 
 if (n_extra_c_includes > 0) {
@@ -445,6 +446,12 @@ print "  HOST_WIDE_INT value = decoded->value;                               "
 print "  enum opt_code code = (enum opt_code) scode;                         "
 print "                                                                      "
 print "  gcc_assert (decoded->canonical_option_num_elements <= 2);           "
+print "  static auto_sbitmap processed_codes (N_OPTS);                       "
+print "                                                                      "
+print "  if (bitmap_bit_p (processed_codes, code))                           "
+print "    return true;                                                      "
+print "                                                                      "
+print "  bitmap_set_bit (processed_codes, code);                             "
 print "                                                                      "
 print "  switch (code)                                                       "
 print "    {                                                                 "
@@ -479,6 +486,7 @@ for (i = 0; i < n_enabledby; i++) {
 print "    default:    "
 print "      break;    "
 print "    }           "
+print "  bitmap_clear_bit (processed_codes, code); "
 print "  return true;  "
 print "}               "
 
diff --git a/gcc/opts.c b/gcc/opts.c
index fc71b6e4242..65fe192a198 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -581,6 +581,7 @@ static const struct default_options default_options_table[] =
     { OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 },
     { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 },
     { OPT_LEVELS_1_PLUS, OPT_ftree_ter, NULL, 1 },
+    { OPT_LEVELS_1_PLUS, OPT_fvar_tracking, NULL, 1 },
 
     /* -O1 (and not -Og) optimizations.  */
     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fbranch_count_reg, NULL, 1 },
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 81546b19e91..e4f6488fac2 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -119,10 +119,6 @@ unsigned int save_decoded_options_count;
 /* Vector of saved Optimization decoded command line options.  */
 vec<cl_decoded_option> *save_opt_decoded_options;
 
-/* Used to enable -fvar-tracking, -fweb and -frename-registers according
-   to optimize in process_options ().  */
-#define AUTODETECT_VALUE 2
-
 /* Debug hooks - dependent upon command line options.  */
 
 const struct gcc_debug_hooks *debug_hooks;
@@ -1483,8 +1479,9 @@ process_options (bool no_backend)
       || !dwarf_debuginfo_p ()
       || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
     {
-      if (flag_var_tracking == 1
-	  || flag_var_tracking_uninit == 1)
+      if ((OPTION_SET_P (flag_var_tracking) && flag_var_tracking == 1)
+	  || (OPTION_SET_P (flag_var_tracking_uninit)
+	      && flag_var_tracking_uninit == 1))
         {
 	  if (debug_info_level < DINFO_LEVEL_NORMAL)
 	    warning_at (UNKNOWN_LOCATION, 0,
@@ -1505,19 +1502,7 @@ process_options (bool no_backend)
   if (flag_dump_go_spec != NULL)
     debug_hooks = dump_go_spec_init (flag_dump_go_spec, debug_hooks);
 
-  /* If the user specifically requested variable tracking with tagging
-     uninitialized variables, we need to turn on variable tracking.
-     (We already determined above that variable tracking is feasible.)  */
-  if (flag_var_tracking_uninit == 1)
-    flag_var_tracking = 1;
-
-  if (flag_var_tracking == AUTODETECT_VALUE)
-    flag_var_tracking = optimize >= 1;
-
-  if (flag_var_tracking_uninit == AUTODETECT_VALUE)
-    flag_var_tracking_uninit = flag_var_tracking;
-
-  if (flag_var_tracking_assignments == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (flag_var_tracking_assignments))
     flag_var_tracking_assignments
       = (flag_var_tracking
 	 && !(flag_selective_scheduling || flag_selective_scheduling2));
@@ -1533,21 +1518,19 @@ process_options (bool no_backend)
     warning_at (UNKNOWN_LOCATION, 0,
 		"var-tracking-assignments changes selective scheduling");
 
-  if (debug_nonbind_markers_p == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (debug_nonbind_markers_p))
     debug_nonbind_markers_p
       = (optimize
 	 && debug_info_level >= DINFO_LEVEL_NORMAL
 	 && dwarf_debuginfo_p ()
 	 && !(flag_selective_scheduling || flag_selective_scheduling2));
 
-  if (dwarf2out_as_loc_support == AUTODETECT_VALUE)
-    dwarf2out_as_loc_support
-      = dwarf2out_default_as_loc_support ();
-  if (dwarf2out_as_locview_support == AUTODETECT_VALUE)
-    dwarf2out_as_locview_support
-      = dwarf2out_default_as_locview_support ();
+  if (!OPTION_SET_P (dwarf2out_as_loc_support))
+    dwarf2out_as_loc_support = dwarf2out_default_as_loc_support ();
+  if (!OPTION_SET_P (dwarf2out_as_locview_support))
+    dwarf2out_as_locview_support = dwarf2out_default_as_locview_support ();
 
-  if (debug_variable_location_views == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (debug_variable_location_views))
     {
       debug_variable_location_views
 	= (flag_var_tracking
@@ -1581,7 +1564,7 @@ process_options (bool no_backend)
       debug_internal_reset_location_views = 0;
     }
 
-  if (debug_inline_points == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (debug_inline_points))
     debug_inline_points = debug_variable_location_views;
   else if (debug_inline_points && !debug_nonbind_markers_p)
     {


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/marxin/heads/remove-AUTODETECT_VALUE-opt-value-v2)] Eliminate AUTODETECT_VALUE usage in options.
@ 2021-10-13 15:50 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-10-13 15:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4ab51fa0e1705201420d87b601bd92bc643b3d52

commit 4ab51fa0e1705201420d87b601bd92bc643b3d52
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Oct 12 14:31:50 2021 +0200

    Eliminate AUTODETECT_VALUE usage in options.
    
    gcc/ChangeLog:
    
            * common.opt: Stop using AUTODETECT_VALUE as Init value.
            * toplev.c (AUTODETECT_VALUE): Remove it.
            (process_options): Do not compare option values to
            AUTODETECT_VALUE, but use rather OPTION_SET_P macro.
            For flag_var_tracking, do not reset it if it is already set
            based on flag_var_tracking_uninit.

Diff:
---
 gcc/common.opt   | 26 +++++++++++---------------
 gcc/optc-gen.awk |  8 ++++++++
 gcc/opts.c       |  1 +
 gcc/toplev.c     | 39 +++++++++++----------------------------
 4 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 1eedfeaf539..83489a83d43 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3003,19 +3003,16 @@ Common Undocumented Var(flag_use_linker_plugin)
 
 ; Positive if we should track variables, negative if we should run
 ; the var-tracking pass only to discard debug annotations, zero if
-; we're not to run it.  When flag_var_tracking == 2 (AUTODETECT_VALUE) it
-; will be set according to optimize, debug_info_level and debug_hooks
-; in process_options ().
+; we're not to run it.
 fvar-tracking
-Common Var(flag_var_tracking) Init(2) PerFunction
+Common Var(flag_var_tracking) PerFunction EnabledBy(fvar-tracking-uninit)
 Perform variable tracking.
 
 ; Positive if we should track variables at assignments, negative if
 ; we should run the var-tracking pass only to discard debug
-; annotations.  When flag_var_tracking_assignments ==
-; AUTODETECT_VALUE it will be set according to flag_var_tracking.
+; annotations.
 fvar-tracking-assignments
-Common Var(flag_var_tracking_assignments) Init(2) PerFunction
+Common Var(flag_var_tracking_assignments) PerFunction
 Perform variable tracking by annotating assignments.
 
 ; Nonzero if we should toggle flag_var_tracking_assignments after
@@ -3026,10 +3023,9 @@ Toggle -fvar-tracking-assignments.
 
 ; Positive if we should track uninitialized variables, negative if
 ; we should run the var-tracking pass only to discard debug
-; annotations.  When flag_var_tracking_uninit == AUTODETECT_VALUE it
-; will be set according to flag_var_tracking.
+; annotations.
 fvar-tracking-uninit
-Common Var(flag_var_tracking_uninit) PerFunction
+Common Var(flag_var_tracking_uninit) PerFunction EnabledBy(fvar-tracking)
 Perform variable tracking and also tag variables that are uninitialized.
 
 ; Alias to enable both -ftree-loop-vectorize and -ftree-slp-vectorize.
@@ -3190,11 +3186,11 @@ Common Driver RejectNegative JoinedOrMissing
 Generate debug information in default format.
 
 gas-loc-support
-Common Driver Var(dwarf2out_as_loc_support) Init(2)
+Common Driver Var(dwarf2out_as_loc_support)
 Assume assembler support for (DWARF2+) .loc directives.
 
 gas-locview-support
-Common Driver Var(dwarf2out_as_locview_support) Init(2)
+Common Driver Var(dwarf2out_as_locview_support)
 Assume assembler support for view in (DWARF2+) .loc directives.
 
 gcoff
@@ -3248,7 +3244,7 @@ Common Driver JoinedOrMissing
 Generate debug information in default extended format.
 
 ginline-points
-Common Driver Var(debug_inline_points) Init(2)
+Common Driver Var(debug_inline_points)
 Generate extended entry point information for inlined functions.
 
 ginternal-reset-location-views
@@ -3288,7 +3284,7 @@ Common Driver JoinedOrMissing Negative(gvms)
 Generate debug information in extended STABS format.
 
 gstatement-frontiers
-Common Driver Var(debug_nonbind_markers_p) Init(2)
+Common Driver Var(debug_nonbind_markers_p)
 Emit progressive recommended breakpoint locations.
 
 gstrict-dwarf
@@ -3304,7 +3300,7 @@ Common Driver Var(flag_gtoggle)
 Toggle debug information generation.
 
 gvariable-location-views
-Common Driver Var(debug_variable_location_views, 1) Init(2)
+Common Driver Var(debug_variable_location_views, 1)
 Augment variable location lists with progressive views.
 
 gvariable-location-views=incompat5
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 77e598efd60..ba97a637607 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -118,6 +118,7 @@ for (i = 1; i <= n_headers; i++)
 print "#include " quote "opts.h" quote
 print "#include " quote "intl.h" quote
 print "#include " quote "insn-attr-common.h" quote
+print "#include " quote "sbitmap.h" quote
 print ""
 
 if (n_extra_c_includes > 0) {
@@ -445,6 +446,12 @@ print "  HOST_WIDE_INT value = decoded->value;                               "
 print "  enum opt_code code = (enum opt_code) scode;                         "
 print "                                                                      "
 print "  gcc_assert (decoded->canonical_option_num_elements <= 2);           "
+print "  static auto_sbitmap processed_codes (N_OPTS);                       "
+print "                                                                      "
+print "  if (bitmap_bit_p (processed_codes, code))                           "
+print "    return true;                                                      "
+print "                                                                      "
+print "  bitmap_set_bit (processed_codes, code);                             "
 print "                                                                      "
 print "  switch (code)                                                       "
 print "    {                                                                 "
@@ -479,6 +486,7 @@ for (i = 0; i < n_enabledby; i++) {
 print "    default:    "
 print "      break;    "
 print "    }           "
+print "  bitmap_clear_bit (processed_codes, code); "
 print "  return true;  "
 print "}               "
 
diff --git a/gcc/opts.c b/gcc/opts.c
index fc71b6e4242..65fe192a198 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -581,6 +581,7 @@ static const struct default_options default_options_table[] =
     { OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 },
     { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 },
     { OPT_LEVELS_1_PLUS, OPT_ftree_ter, NULL, 1 },
+    { OPT_LEVELS_1_PLUS, OPT_fvar_tracking, NULL, 1 },
 
     /* -O1 (and not -Og) optimizations.  */
     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fbranch_count_reg, NULL, 1 },
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 81546b19e91..e4f6488fac2 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -119,10 +119,6 @@ unsigned int save_decoded_options_count;
 /* Vector of saved Optimization decoded command line options.  */
 vec<cl_decoded_option> *save_opt_decoded_options;
 
-/* Used to enable -fvar-tracking, -fweb and -frename-registers according
-   to optimize in process_options ().  */
-#define AUTODETECT_VALUE 2
-
 /* Debug hooks - dependent upon command line options.  */
 
 const struct gcc_debug_hooks *debug_hooks;
@@ -1483,8 +1479,9 @@ process_options (bool no_backend)
       || !dwarf_debuginfo_p ()
       || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
     {
-      if (flag_var_tracking == 1
-	  || flag_var_tracking_uninit == 1)
+      if ((OPTION_SET_P (flag_var_tracking) && flag_var_tracking == 1)
+	  || (OPTION_SET_P (flag_var_tracking_uninit)
+	      && flag_var_tracking_uninit == 1))
         {
 	  if (debug_info_level < DINFO_LEVEL_NORMAL)
 	    warning_at (UNKNOWN_LOCATION, 0,
@@ -1505,19 +1502,7 @@ process_options (bool no_backend)
   if (flag_dump_go_spec != NULL)
     debug_hooks = dump_go_spec_init (flag_dump_go_spec, debug_hooks);
 
-  /* If the user specifically requested variable tracking with tagging
-     uninitialized variables, we need to turn on variable tracking.
-     (We already determined above that variable tracking is feasible.)  */
-  if (flag_var_tracking_uninit == 1)
-    flag_var_tracking = 1;
-
-  if (flag_var_tracking == AUTODETECT_VALUE)
-    flag_var_tracking = optimize >= 1;
-
-  if (flag_var_tracking_uninit == AUTODETECT_VALUE)
-    flag_var_tracking_uninit = flag_var_tracking;
-
-  if (flag_var_tracking_assignments == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (flag_var_tracking_assignments))
     flag_var_tracking_assignments
       = (flag_var_tracking
 	 && !(flag_selective_scheduling || flag_selective_scheduling2));
@@ -1533,21 +1518,19 @@ process_options (bool no_backend)
     warning_at (UNKNOWN_LOCATION, 0,
 		"var-tracking-assignments changes selective scheduling");
 
-  if (debug_nonbind_markers_p == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (debug_nonbind_markers_p))
     debug_nonbind_markers_p
       = (optimize
 	 && debug_info_level >= DINFO_LEVEL_NORMAL
 	 && dwarf_debuginfo_p ()
 	 && !(flag_selective_scheduling || flag_selective_scheduling2));
 
-  if (dwarf2out_as_loc_support == AUTODETECT_VALUE)
-    dwarf2out_as_loc_support
-      = dwarf2out_default_as_loc_support ();
-  if (dwarf2out_as_locview_support == AUTODETECT_VALUE)
-    dwarf2out_as_locview_support
-      = dwarf2out_default_as_locview_support ();
+  if (!OPTION_SET_P (dwarf2out_as_loc_support))
+    dwarf2out_as_loc_support = dwarf2out_default_as_loc_support ();
+  if (!OPTION_SET_P (dwarf2out_as_locview_support))
+    dwarf2out_as_locview_support = dwarf2out_default_as_locview_support ();
 
-  if (debug_variable_location_views == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (debug_variable_location_views))
     {
       debug_variable_location_views
 	= (flag_var_tracking
@@ -1581,7 +1564,7 @@ process_options (bool no_backend)
       debug_internal_reset_location_views = 0;
     }
 
-  if (debug_inline_points == AUTODETECT_VALUE)
+  if (!OPTION_SET_P (debug_inline_points))
     debug_inline_points = debug_variable_location_views;
   else if (debug_inline_points && !debug_nonbind_markers_p)
     {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-13 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 14:18 [gcc(refs/users/marxin/heads/remove-AUTODETECT_VALUE-opt-value-v2)] Eliminate AUTODETECT_VALUE usage in options Martin Liska
2021-10-13 15:50 Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).