summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2016-12-31 07:46:01 -0200
committerAlexandre Oliva <aoliva@redhat.com>2017-01-06 01:31:00 -0200
commit172df0c0ad97307f3d28b9a070c341a74dad233a (patch)
tree9a25a24357e94d8f12fa7ca3a31013c977341209
parent2dccc7c49bef10d058260151cef37bababc47d20 (diff)
downloadgcc-aoliva/non-SFN-fixes-for-GCC7.tar.gz
[-fcompare-debug] var tracking options are not optimization optionsaoliva/non-SFN-fixes-for-GCC7
If we include them in the ICF hash, they may cause congruence_groups to be processed in a different order due to different hashes, which in turn causes different funcdef_nos to be assigned to functions. Since these numbers are included in -fcompare-debug dumps, they cause failures. Since these options are not optimization options, in that they do not (or should not, save for bugs like this) affect the executable code output by the compiler, they should not be marked as such. This patch replaces the Optimization flag in the var-tracking options with the newly-introduced PerFunction flag, so that it can still be controlled on a per-function basis, but that disregards it in the hash computation used by ICF. This fixes -fcompare-debug failures in numerous LTO testcases. for gcc/ChangeLog * doc/options.texi (PerFunction): New. * opt-functions.awk (switch_flags): Map both Optimization and PerFunction to CL_OPTIMIZATION. * opth-gen.awk: Test for PerFunction flag along with Optimization. * optc-save-gen.awk: Likewise. Introduce var_opt_hash and set it only when the latter is present. Skip those that don't in the hash function generator. * common.opt (fvar-tracking): Mark as PerFunction instead of Optimization. (fvar-tracking-assignments): Likewise. (fvar-tracking-assignments-toggle): Likewise. (fvar-tracking-uninit): Likewise.
-rw-r--r--gcc/common.opt8
-rw-r--r--gcc/doc/options.texi7
-rw-r--r--gcc/opt-functions.awk2
-rw-r--r--gcc/optc-save-gen.awk7
-rw-r--r--gcc/opth-gen.awk2
5 files changed, 18 insertions, 8 deletions
diff --git a/gcc/common.opt b/gcc/common.opt
index 1872d51b417..44f7557c7b0 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2601,7 +2601,7 @@ Common Undocumented Var(flag_use_linker_plugin)
; will be set according to optimize, debug_info_level and debug_hooks
; in process_options ().
fvar-tracking
-Common Report Var(flag_var_tracking) Init(2) Optimization
+Common Report Var(flag_var_tracking) Init(2) PerFunction
Perform variable tracking.
; Positive if we should track variables at assignments, negative if
@@ -2609,13 +2609,13 @@ Perform variable tracking.
; annotations. When flag_var_tracking_assignments ==
; AUTODETECT_VALUE it will be set according to flag_var_tracking.
fvar-tracking-assignments
-Common Report Var(flag_var_tracking_assignments) Init(2) Optimization
+Common Report Var(flag_var_tracking_assignments) Init(2) PerFunction
Perform variable tracking by annotating assignments.
; Nonzero if we should toggle flag_var_tracking_assignments after
; processing options and computing its default. */
fvar-tracking-assignments-toggle
-Common Report Var(flag_var_tracking_assignments_toggle) Optimization
+Common Report Var(flag_var_tracking_assignments_toggle) PerFunction
Toggle -fvar-tracking-assignments.
; Positive if we should track uninitialized variables, negative if
@@ -2623,7 +2623,7 @@ Toggle -fvar-tracking-assignments.
; annotations. When flag_var_tracking_uninit == AUTODETECT_VALUE it
; will be set according to flag_var_tracking.
fvar-tracking-uninit
-Common Report Var(flag_var_tracking_uninit) Optimization
+Common Report Var(flag_var_tracking_uninit) PerFunction
Perform variable tracking and also tag variables that are uninitialized.
ftree-vectorize
diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 87cf6888a4b..14c149e9896 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -430,6 +430,13 @@ This is an optimization option. It should be shown as such in
@code{Var} should be saved and restored when the optimization level is
changed with @code{optimize} attributes.
+@item PerFunction
+This is an option that can be overridden on a per-function basis.
+@code{Optimization} implies @code{PerFunction}, but options that do not
+affect executable code generation may use this flag instead, so that the
+option is not taken into account in ways that might affect executable
+code generation.
+
@item Undocumented
The option is deliberately missing documentation and should not
be included in the @option{--help} output.
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index 7cf50256558..a4aeeda2474 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -105,7 +105,7 @@ function switch_flags (flags)
test_flag("Undocumented", flags, " | CL_UNDOCUMENTED") \
test_flag("NoDWARFRecord", flags, " | CL_NO_DWARF_RECORD") \
test_flag("Warning", flags, " | CL_WARNING") \
- test_flag("Optimization", flags, " | CL_OPTIMIZATION")
+ test_flag("(Optimization|PerFunction)", flags, " | CL_OPTIMIZATION")
sub( "^0 \\| ", "", result )
return result
}
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 8ce424813b5..0928d5d9f11 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -100,7 +100,7 @@ var_opt_range["optimize_debug"] = "0, 1";
# cache.
for (i = 0; i < n_opts; i++) {
- if (flag_set_p("Optimization", flags[i])) {
+ if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
name = var_name(flags[i])
if(name == "")
continue;
@@ -743,7 +743,7 @@ var_opt_val[2] = "x_optimize_debug"
var_opt_val_type[1] = "char "
var_opt_val_type[2] = "char "
for (i = 0; i < n_opts; i++) {
- if (flag_set_p("Optimization", flags[i])) {
+ if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
name = var_name(flags[i])
if(name == "")
continue;
@@ -756,6 +756,7 @@ for (i = 0; i < n_opts; i++) {
otype = var_type_struct(flags[i])
var_opt_val_type[n_opt_val] = otype;
var_opt_val[n_opt_val++] = "x_" name;
+ var_opt_hash[n_opt_val] = flag_set_p("Optimization", flags[i]);
}
}
print "";
@@ -765,6 +766,8 @@ print "cl_optimization_hash (struct cl_optimization const *ptr ATTRIBUTE_UNUSED)
print "{";
print " inchash::hash hstate;";
for (i = 0; i < n_opt_val; i++) {
+ if (!var_opt_hash[i])
+ continue;
name = var_opt_val[i]
print " hstate.add_wide_int (ptr->" name");";
}
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index c728a42ca11..69a700367d6 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -142,7 +142,7 @@ var_opt_char[1] = "unsigned char x_optimize_size";
var_opt_char[2] = "unsigned char x_optimize_debug";
for (i = 0; i < n_opts; i++) {
- if (flag_set_p("Optimization", flags[i])) {
+ if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
name = var_name(flags[i])
if(name == "")
continue;