aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-10-14 14:57:18 +0200
committerMartin Liska <mliska@suse.cz>2021-10-21 15:20:09 +0200
commitb4702276615ff8d43bc910e7a54fdd850ad8d461 (patch)
tree755b63565fd478c74216b8af60e208ed96220740 /gcc
parent701ee067807b80957c65bd7ff94b6099a27181de (diff)
downloadgcc-b4702276615ff8d43bc910e7a54fdd850ad8d461.zip
gcc-b4702276615ff8d43bc910e7a54fdd850ad8d461.tar.gz
gcc-b4702276615ff8d43bc910e7a54fdd850ad8d461.tar.bz2
options: Fix variable tracking option processing.
PR debug/102585 PR bootstrap/102766 gcc/ChangeLog: * opts.c (finish_options): Process flag_var_tracking* options here as they can be adjusted by optimize attribute. Process also flag_syntax_only and flag_gtoggle. * toplev.c (process_options): Remove it here. * common.opt: Make debug_nonbind_markers_p as PerFunction attribute as it depends on optimization level. gcc/testsuite/ChangeLog: * gcc.dg/pr102585.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/common.opt2
-rw-r--r--gcc/opts.c45
-rw-r--r--gcc/testsuite/gcc.dg/pr102585.c6
-rw-r--r--gcc/toplev.c47
4 files changed, 53 insertions, 47 deletions
diff --git a/gcc/common.opt b/gcc/common.opt
index a2af7fb..c4a77f6 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3284,7 +3284,7 @@ Common Driver JoinedOrMissing Negative(gvms)
Generate debug information in extended STABS format.
gstatement-frontiers
-Common Driver Var(debug_nonbind_markers_p)
+Common Driver Var(debug_nonbind_markers_p) PerFunction
Emit progressive recommended breakpoint locations.
gstrict-dwarf
diff --git a/gcc/opts.c b/gcc/opts.c
index 65fe192..4472cec 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1349,6 +1349,51 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
VECT_COST_MODEL_CHEAP);
+ /* One could use EnabledBy, but it would lead to a circular dependency. */
+ if (!OPTION_SET_P (flag_var_tracking_uninit))
+ flag_var_tracking_uninit = flag_var_tracking;
+
+ if (!OPTION_SET_P (flag_var_tracking_assignments))
+ flag_var_tracking_assignments
+ = (flag_var_tracking
+ && !(flag_selective_scheduling || flag_selective_scheduling2));
+
+ if (flag_var_tracking_assignments_toggle)
+ flag_var_tracking_assignments = !flag_var_tracking_assignments;
+
+ if (flag_var_tracking_assignments && !flag_var_tracking)
+ flag_var_tracking = flag_var_tracking_assignments = -1;
+
+ if (flag_var_tracking_assignments
+ && (flag_selective_scheduling || flag_selective_scheduling2))
+ warning_at (loc, 0,
+ "var-tracking-assignments changes selective scheduling");
+
+ if (flag_syntax_only)
+ {
+ write_symbols = NO_DEBUG;
+ profile_flag = 0;
+ }
+
+ if (flag_gtoggle)
+ {
+ if (debug_info_level == DINFO_LEVEL_NONE)
+ {
+ debug_info_level = DINFO_LEVEL_NORMAL;
+
+ if (write_symbols == NO_DEBUG)
+ write_symbols = PREFERRED_DEBUGGING_TYPE;
+ }
+ else
+ debug_info_level = DINFO_LEVEL_NONE;
+ }
+
+ 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));
}
#define LEFT_COLUMN 27
diff --git a/gcc/testsuite/gcc.dg/pr102585.c b/gcc/testsuite/gcc.dg/pr102585.c
new file mode 100644
index 0000000..efd066b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102585.c
@@ -0,0 +1,6 @@
+/* PR debug/102585 */
+/* { dg-do compile } */
+/* { dg-options "-fvar-tracking-assignments -fno-var-tracking" } */
+
+#pragma GCC optimize 0
+void d_demangle_callback_Og() { int c = 0; }
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 67fb716..e91f083 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1375,25 +1375,6 @@ process_options (bool no_backend)
}
}
- if (flag_syntax_only)
- {
- write_symbols = NO_DEBUG;
- profile_flag = 0;
- }
-
- if (flag_gtoggle)
- {
- if (debug_info_level == DINFO_LEVEL_NONE)
- {
- debug_info_level = DINFO_LEVEL_NORMAL;
-
- if (write_symbols == NO_DEBUG)
- write_symbols = PREFERRED_DEBUGGING_TYPE;
- }
- else
- debug_info_level = DINFO_LEVEL_NONE;
- }
-
/* CTF is supported for only C at this time. */
if (!lang_GNU_C ()
&& ctf_debug_info_level > CTFINFO_LEVEL_NONE)
@@ -1496,6 +1477,7 @@ process_options (bool no_backend)
}
flag_var_tracking = 0;
flag_var_tracking_uninit = 0;
+ flag_var_tracking_assignments = 0;
}
/* The debug hooks are used to implement -fdump-go-spec because it
@@ -1504,33 +1486,6 @@ process_options (bool no_backend)
if (flag_dump_go_spec != NULL)
debug_hooks = dump_go_spec_init (flag_dump_go_spec, debug_hooks);
- /* One could use EnabledBy, but it would lead to a circular dependency. */
- if (!OPTION_SET_P (flag_var_tracking_uninit))
- flag_var_tracking_uninit = flag_var_tracking;
-
- if (!OPTION_SET_P (flag_var_tracking_assignments))
- flag_var_tracking_assignments
- = (flag_var_tracking
- && !(flag_selective_scheduling || flag_selective_scheduling2));
-
- if (flag_var_tracking_assignments_toggle)
- flag_var_tracking_assignments = !flag_var_tracking_assignments;
-
- if (flag_var_tracking_assignments && !flag_var_tracking)
- flag_var_tracking = flag_var_tracking_assignments = -1;
-
- if (flag_var_tracking_assignments
- && (flag_selective_scheduling || flag_selective_scheduling2))
- warning_at (UNKNOWN_LOCATION, 0,
- "var-tracking-assignments changes selective scheduling");
-
- 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 (!OPTION_SET_P (dwarf2out_as_loc_support))
dwarf2out_as_loc_support = dwarf2out_default_as_loc_support ();
if (!OPTION_SET_P (dwarf2out_as_locview_support))