Fixes and workarounds for warnings during autoprofiledbootstrap build

Message ID MN0PR21MB348450698DEB069F231AF92E91779@MN0PR21MB3484.namprd21.prod.outlook.com
State New
Headers
Series Fixes and workarounds for warnings during autoprofiledbootstrap build |

Commit Message

Eugene Rozenfeld May 10, 2023, 1:38 a.m. UTC
  autoprofiledbootstrap build produces new warnings since inlining decisions
are different from other builds. This patch contains fixes and workarounds
for those warnings.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:

	* config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
	-Wstringop-overflow false positive during autoprofiledbootstrap
	* ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
	warning during autoprofiledbootstrap
	* lra-eliminations.cc (setup_can_eliminate): Work around
	-Wmaybe-uninitialized false positive during autoprofiledbootstrap
	* opts-common.cc (candidates_list_and_hint): Work around
	-Wstringop-overflow false positive during autoprofiledbootstrap
	* tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
	false positive during autoprofiledbootstrap
	* wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
	positive during autoprofiledbootstrap
---
 gcc/config/i386/i386-expand.cc | 11 +++++++++++
 gcc/ipa-devirt.cc              |  3 ++-
 gcc/lra-eliminations.cc        | 11 +++++++++++
 gcc/opts-common.cc             |  1 +
 gcc/tree-ssa-ccp.cc            | 11 +++++++++++
 gcc/wide-int.h                 | 11 +++++++++++
 6 files changed, 47 insertions(+), 1 deletion(-)
  

Comments

Richard Biener May 10, 2023, 6:39 a.m. UTC | #1
On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> autoprofiledbootstrap build produces new warnings since inlining decisions
> are different from other builds. This patch contains fixes and workarounds
> for those warnings.
>
> Tested on x86_64-pc-linux-gnu.

Rather than this would it make sense to add --disable-werror to
autoprofiledbootstrap
configs like we do for others?  I also wonder how "stable" the afdo bootstrap
inlining decisions are, so applying these workarounds may not be sustainable?

> gcc/ChangeLog:
>
>         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
>         -Wstringop-overflow false positive during autoprofiledbootstrap
>         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
>         warning during autoprofiledbootstrap
>         * lra-eliminations.cc (setup_can_eliminate): Work around
>         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
>         * opts-common.cc (candidates_list_and_hint): Work around
>         -Wstringop-overflow false positive during autoprofiledbootstrap
>         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
>         false positive during autoprofiledbootstrap
>         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
>         positive during autoprofiledbootstrap
> ---
>  gcc/config/i386/i386-expand.cc | 11 +++++++++++
>  gcc/ipa-devirt.cc              |  3 ++-
>  gcc/lra-eliminations.cc        | 11 +++++++++++
>  gcc/opts-common.cc             |  1 +
>  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
>  gcc/wide-int.h                 | 11 +++++++++++
>  6 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
> index 634fe61ba79..be9f912775b 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct expand_vec_perm_d *d)
>
>  static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d *d);
>
> +/* Work around -Wstringop-overflow false positive during autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 7001
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wstringop-overflow"
> +#endif
> +
>  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>     a two vector permutation into a single vector permutation by using
>     an interleave operation to merge the vectors.  */
> @@ -20737,6 +20744,10 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d *d)
>    return true;
>  }
>
> +# if GCC_VERSION >= 7001
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>     a single vector cross-lane permutation into vpermq followed
>     by any of the single insn permutations.  */
> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
> index 819860258d1..36ea266e834 100644
> --- a/gcc/ipa-devirt.cc
> +++ b/gcc/ipa-devirt.cc
> @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
>        odr = cplus_demangle (odr, opts);
>      }
>
> -  fprintf (stderr, "%s\n", odr);
> +  if (odr != NULL)
> +    fprintf (stderr, "%s\n", odr);
>  }
>
>  /* Register ODR enum so we later stream record about its values.  */
> diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
> index 42206366669..05e2a7e0d68 100644
> --- a/gcc/lra-eliminations.cc
> +++ b/gcc/lra-eliminations.cc
> @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
>    print_elim_table (stderr);
>  }
>
> +/* Work around -Wmaybe-uninitialized false positive during autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +#endif
> +
>  /* Setup possibility of elimination in elimination table element EP to
>     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
>     pointer to stack pointer is not possible anymore.  */
> @@ -152,6 +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool value)
>      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;
>  }
>
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* Map: eliminable "from" register -> its current elimination,
>     or NULL if none.  The elimination table may contain more than
>     one elimination for the same hard register, but this map specifies
> diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
> index 23ddcaa3b55..0bb8e34e2b0 100644
> --- a/gcc/opts-common.cc
> +++ b/gcc/opts-common.cc
> @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
>        p[len] = ' ';
>        p += len + 1;
>      }
> +  gcc_assert(p > str);
>    p[-1] = '\0';
>    return find_closest_string (arg, &candidates);
>  }
> diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
> index 03a984f2adf..a54e5a90464 100644
> --- a/gcc/tree-ssa-ccp.cc
> +++ b/gcc/tree-ssa-ccp.cc
> @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
>      }
>  }
>
> +/* Work around -Wmaybe-uninitialized false positive during autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +#endif
> +
>  /* Return the propagation value when applying the operation CODE to
>     the value RHS yielding type TYPE.  */
>
> @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
>    return val;
>  }
>
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* Return the propagation value when applying the operation CODE to
>     the values RHS1 and RHS2 yielding type TYPE.  */
>
> diff --git a/gcc/wide-int.h b/gcc/wide-int.h
> index 6be343c0eb5..9c50dd869b6 100644
> --- a/gcc/wide-int.h
> +++ b/gcc/wide-int.h
> @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
>                         get_binary_result (x, y));
>  }
>
> +/* Work around -Wmaybe-uninitialized false positive during autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +#endif
> +
>  /* Copy the contents of Y to X, but keeping X's current precision.  */
>  template <typename T1, typename T2>
>  inline void
> @@ -1821,6 +1828,10 @@ wi::copy (T1 &x, const T2 &y)
>    x.set_len (len, y.is_sign_extended);
>  }
>
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* Return true if X fits in a HOST_WIDE_INT with no loss of precision.  */
>  template <typename T>
>  inline bool
> --
> 2.25.1
>
  
Martin Jambor May 10, 2023, 8:27 a.m. UTC | #2
Hello,

On Wed, May 10 2023, Eugene Rozenfeld via Gcc-patches wrote:
> autoprofiledbootstrap build produces new warnings since inlining decisions
> are different from other builds. This patch contains fixes and workarounds
> for those warnings.
>
> Tested on x86_64-pc-linux-gnu.
>
> gcc/ChangeLog:
>
> 	* config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
> 	-Wstringop-overflow false positive during autoprofiledbootstrap
> 	* ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
> 	warning during autoprofiledbootstrap
> 	* lra-eliminations.cc (setup_can_eliminate): Work around
> 	-Wmaybe-uninitialized false positive during autoprofiledbootstrap
> 	* opts-common.cc (candidates_list_and_hint): Work around
> 	-Wstringop-overflow false positive during autoprofiledbootstrap
> 	* tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
> 	false positive during autoprofiledbootstrap
> 	* wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
> 	positive during autoprofiledbootstrap
> ---
>  gcc/config/i386/i386-expand.cc | 11 +++++++++++
>  gcc/ipa-devirt.cc              |  3 ++-
>  gcc/lra-eliminations.cc        | 11 +++++++++++
>  gcc/opts-common.cc             |  1 +
>  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
>  gcc/wide-int.h                 | 11 +++++++++++
>  6 files changed, 47 insertions(+), 1 deletion(-)
>

[...]

> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
> index 819860258d1..36ea266e834 100644
> --- a/gcc/ipa-devirt.cc
> +++ b/gcc/ipa-devirt.cc
> @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
>        odr = cplus_demangle (odr, opts);
>      }
>  
> -  fprintf (stderr, "%s\n", odr);
> +  if (odr != NULL)
> +    fprintf (stderr, "%s\n", odr);
>  }

I cannot find a call to this debug function on trunk.  How exactly did
this trigger a warning?

In any case, IMHO the function should rather print something that makes
it clear that an odr name could not be obtained rather than printing
nothing.

I also think that if we want to handle the case, we should do it before
also possibly passing odr to demangler.

Thanks,

Martin
  
Eugene Rozenfeld May 11, 2023, 2:17 a.m. UTC | #3
> I cannot find a call to this debug function on trunk.  How exactly did this trigger a warning?

Here is the command during autoprofiledbootstrap build that resulted in a warning:

~/gcc1_objdir/gcc$ /home/erozen/gcc1_objdir/./prev-gcc/xg++ -B/home/erozen/gcc1_objdir/./prev-gcc/ -B/home/erozen/GCC1/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/erozen/gcc1_objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/home/erozen/gcc1_objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -I/home/erozen/gcc1_objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu  -I/home/erozen/gcc1_objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include  -I/home/erozen/gcc1/libstdc++-v3/libsupc++ -L/home/erozen/gcc1_objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/erozen/gcc1_objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -fno-PIE -c   -g -O2 -fchecking=1 -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -fauto-profile=cc1plus.fda -I. -I. -I/home/erozen/gcc1_objdir/../gcc1/gcc -I/home/erozen/gcc1_objdir/../gcc1/gcc/. -I/home/erozen/gcc1_objdir/../gcc1/gcc/../include  -I/home/erozen/gcc1_objdir/../gcc1/gcc/../libcpp/include -I/home/erozen/gcc1_objdir/../gcc1/gcc/../libcody -I/home/erozen/gcc1_objdir/./gmp -I/home/erozen/gcc1/gmp -I/home/erozen/gcc1_objdir/./mpfr/src -I/home/erozen/gcc1/mpfr/src -I/home/erozen/gcc1/mpc/src  -I/home/erozen/gcc1_objdir/../gcc1/gcc/../libdecnumber -I/home/erozen/gcc1_objdir/../gcc1/gcc/../libdecnumber/bid -I../libdecnumber -I/home/erozen/gcc1_objdir/../gcc1/gcc/../libbacktrace -I/home/erozen/gcc1_objdir/./isl/include -I/home/erozen/gcc1/isl/include  -o ipa-devirt.o -MT ipa-devirt.o -MMD -MP -MF ./.deps/ipa-devirt.TPo /home/erozen/gcc1_objdir/../gcc1/gcc/ipa-devirt.cc
/home/erozen/gcc1_objdir/../gcc1/gcc/ipa-devirt.cc: In function 'void debug_tree_odr_name(tree, bool)':
/home/erozen/gcc1_objdir/../gcc1/gcc/ipa-devirt.cc:4037:23: error: '%s' directive argument is null [-Werror=format-overflow=]
 4037 |     fprintf (stderr, "%s\n", odr);


> In any case, IMHO the function should rather print something that makes it clear that an odr name could not be obtained rather than printing nothing.

> I also think that if we want to handle the case, we should do it before also possibly passing odr to demangler.

I'll modify the fix unless we end up suppressing warnings as errors for autoprofiledbootstrap as Richard suggested.

Thanks,

Martin
  
Eugene Rozenfeld May 11, 2023, 2:22 a.m. UTC | #4
I'm ok with disabling warnings as errors for autoprofiledbootstrap. What's the proper way to do that? Searching for "--disable-werror" I see matches in lib configure files but not in gcc files.

Thanks,

Eugene

-----Original Message-----
From: Richard Biener <richard.guenther@gmail.com> 
Sent: Tuesday, May 9, 2023 11:40 PM
To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings during autoprofiledbootstrap build

On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> autoprofiledbootstrap build produces new warnings since inlining 
> decisions are different from other builds. This patch contains fixes 
> and workarounds for those warnings.
>
> Tested on x86_64-pc-linux-gnu.

Rather than this would it make sense to add --disable-werror to autoprofiledbootstrap configs like we do for others?  I also wonder how "stable" the afdo bootstrap inlining decisions are, so applying these workarounds may not be sustainable?

> gcc/ChangeLog:
>
>         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
>         -Wstringop-overflow false positive during autoprofiledbootstrap
>         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
>         warning during autoprofiledbootstrap
>         * lra-eliminations.cc (setup_can_eliminate): Work around
>         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
>         * opts-common.cc (candidates_list_and_hint): Work around
>         -Wstringop-overflow false positive during autoprofiledbootstrap
>         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
>         false positive during autoprofiledbootstrap
>         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
>         positive during autoprofiledbootstrap
> ---
>  gcc/config/i386/i386-expand.cc | 11 +++++++++++
>  gcc/ipa-devirt.cc              |  3 ++-
>  gcc/lra-eliminations.cc        | 11 +++++++++++
>  gcc/opts-common.cc             |  1 +
>  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
>  gcc/wide-int.h                 | 11 +++++++++++
>  6 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/i386/i386-expand.cc 
> b/gcc/config/i386/i386-expand.cc index 634fe61ba79..be9f912775b 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct 
> expand_vec_perm_d *d)
>
>  static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d 
> *d);
>
> +/* Work around -Wstringop-overflow false positive during 
> +autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 7001
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wstringop-overflow"
> +#endif
> +
>  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>     a two vector permutation into a single vector permutation by using
>     an interleave operation to merge the vectors.  */ @@ -20737,6 
> +20744,10 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d *d)
>    return true;
>  }
>
> +# if GCC_VERSION >= 7001
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>     a single vector cross-lane permutation into vpermq followed
>     by any of the single insn permutations.  */ diff --git 
> a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index 819860258d1..36ea266e834 
> 100644
> --- a/gcc/ipa-devirt.cc
> +++ b/gcc/ipa-devirt.cc
> @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
>        odr = cplus_demangle (odr, opts);
>      }
>
> -  fprintf (stderr, "%s\n", odr);
> +  if (odr != NULL)
> +    fprintf (stderr, "%s\n", odr);
>  }
>
>  /* Register ODR enum so we later stream record about its values.  */ 
> diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc index 
> 42206366669..05e2a7e0d68 100644
> --- a/gcc/lra-eliminations.cc
> +++ b/gcc/lra-eliminations.cc
> @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
>    print_elim_table (stderr);
>  }
>
> +/* Work around -Wmaybe-uninitialized false positive during 
> +autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +#endif
> +
>  /* Setup possibility of elimination in elimination table element EP to
>     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
>     pointer to stack pointer is not possible anymore.  */ @@ -152,6 
> +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool value)
>      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;  }
>
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* Map: eliminable "from" register -> its current elimination,
>     or NULL if none.  The elimination table may contain more than
>     one elimination for the same hard register, but this map specifies 
> diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index 
> 23ddcaa3b55..0bb8e34e2b0 100644
> --- a/gcc/opts-common.cc
> +++ b/gcc/opts-common.cc
> @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
>        p[len] = ' ';
>        p += len + 1;
>      }
> +  gcc_assert(p > str);
>    p[-1] = '\0';
>    return find_closest_string (arg, &candidates);  } diff --git 
> a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index 
> 03a984f2adf..a54e5a90464 100644
> --- a/gcc/tree-ssa-ccp.cc
> +++ b/gcc/tree-ssa-ccp.cc
> @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
>      }
>  }
>
> +/* Work around -Wmaybe-uninitialized false positive during 
> +autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +#endif
> +
>  /* Return the propagation value when applying the operation CODE to
>     the value RHS yielding type TYPE.  */
>
> @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
>    return val;
>  }
>
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* Return the propagation value when applying the operation CODE to
>     the values RHS1 and RHS2 yielding type TYPE.  */
>
> diff --git a/gcc/wide-int.h b/gcc/wide-int.h index 
> 6be343c0eb5..9c50dd869b6 100644
> --- a/gcc/wide-int.h
> +++ b/gcc/wide-int.h
> @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
>                         get_binary_result (x, y));  }
>
> +/* Work around -Wmaybe-uninitialized false positive during 
> +autoprofiledbootstrap.  */
> +
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +#endif
> +
>  /* Copy the contents of Y to X, but keeping X's current precision.  
> */  template <typename T1, typename T2>  inline void @@ -1821,6 
> +1828,10 @@ wi::copy (T1 &x, const T2 &y)
>    x.set_len (len, y.is_sign_extended);  }
>
> +# if GCC_VERSION >= 4007
> +#pragma GCC diagnostic pop
> +#endif
> +
>  /* Return true if X fits in a HOST_WIDE_INT with no loss of 
> precision.  */  template <typename T>  inline bool
> --
> 2.25.1
>
  
Richard Biener May 11, 2023, 8:57 a.m. UTC | #5
On Thu, May 11, 2023 at 4:23 AM Eugene Rozenfeld
<Eugene.Rozenfeld@microsoft.com> wrote:
>
> I'm ok with disabling warnings as errors for autoprofiledbootstrap. What's the proper way to do that? Searching for "--disable-werror" I see matches in lib configure files but not in gcc files.

We have --with-build-config selecting things like bootstrap-O3 and
configure then
disables werror by default if the build config is anything other than
the default
or bootstrap-debug.

Of course profiledbootstrap and autoprofiledbootstrap are not build configs but
make targets - that makes it more difficult (or impossible) to use the
--disable-werror machinery here.

There is

STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@

so it might be possible to filter out --enable-werror-always from
STAGEautofeedback_CONFIGURE_FLAGS?

Richard.

> Thanks,
>
> Eugene
>
> -----Original Message-----
> From: Richard Biener <richard.guenther@gmail.com>
> Sent: Tuesday, May 9, 2023 11:40 PM
> To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
> Cc: gcc-patches@gcc.gnu.org
> Subject: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings during autoprofiledbootstrap build
>
> On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >
> > autoprofiledbootstrap build produces new warnings since inlining
> > decisions are different from other builds. This patch contains fixes
> > and workarounds for those warnings.
> >
> > Tested on x86_64-pc-linux-gnu.
>
> Rather than this would it make sense to add --disable-werror to autoprofiledbootstrap configs like we do for others?  I also wonder how "stable" the afdo bootstrap inlining decisions are, so applying these workarounds may not be sustainable?
>
> > gcc/ChangeLog:
> >
> >         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
> >         -Wstringop-overflow false positive during autoprofiledbootstrap
> >         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
> >         warning during autoprofiledbootstrap
> >         * lra-eliminations.cc (setup_can_eliminate): Work around
> >         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
> >         * opts-common.cc (candidates_list_and_hint): Work around
> >         -Wstringop-overflow false positive during autoprofiledbootstrap
> >         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
> >         false positive during autoprofiledbootstrap
> >         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
> >         positive during autoprofiledbootstrap
> > ---
> >  gcc/config/i386/i386-expand.cc | 11 +++++++++++
> >  gcc/ipa-devirt.cc              |  3 ++-
> >  gcc/lra-eliminations.cc        | 11 +++++++++++
> >  gcc/opts-common.cc             |  1 +
> >  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
> >  gcc/wide-int.h                 | 11 +++++++++++
> >  6 files changed, 47 insertions(+), 1 deletion(-)
> >
> > diff --git a/gcc/config/i386/i386-expand.cc
> > b/gcc/config/i386/i386-expand.cc index 634fe61ba79..be9f912775b 100644
> > --- a/gcc/config/i386/i386-expand.cc
> > +++ b/gcc/config/i386/i386-expand.cc
> > @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct
> > expand_vec_perm_d *d)
> >
> >  static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d
> > *d);
> >
> > +/* Work around -Wstringop-overflow false positive during
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 7001
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wstringop-overflow"
> > +#endif
> > +
> >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
> >     a two vector permutation into a single vector permutation by using
> >     an interleave operation to merge the vectors.  */ @@ -20737,6
> > +20744,10 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d *d)
> >    return true;
> >  }
> >
> > +# if GCC_VERSION >= 7001
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
> >     a single vector cross-lane permutation into vpermq followed
> >     by any of the single insn permutations.  */ diff --git
> > a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index 819860258d1..36ea266e834
> > 100644
> > --- a/gcc/ipa-devirt.cc
> > +++ b/gcc/ipa-devirt.cc
> > @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
> >        odr = cplus_demangle (odr, opts);
> >      }
> >
> > -  fprintf (stderr, "%s\n", odr);
> > +  if (odr != NULL)
> > +    fprintf (stderr, "%s\n", odr);
> >  }
> >
> >  /* Register ODR enum so we later stream record about its values.  */
> > diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc index
> > 42206366669..05e2a7e0d68 100644
> > --- a/gcc/lra-eliminations.cc
> > +++ b/gcc/lra-eliminations.cc
> > @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
> >    print_elim_table (stderr);
> >  }
> >
> > +/* Work around -Wmaybe-uninitialized false positive during
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > +#endif
> > +
> >  /* Setup possibility of elimination in elimination table element EP to
> >     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
> >     pointer to stack pointer is not possible anymore.  */ @@ -152,6
> > +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool value)
> >      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;  }
> >
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* Map: eliminable "from" register -> its current elimination,
> >     or NULL if none.  The elimination table may contain more than
> >     one elimination for the same hard register, but this map specifies
> > diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index
> > 23ddcaa3b55..0bb8e34e2b0 100644
> > --- a/gcc/opts-common.cc
> > +++ b/gcc/opts-common.cc
> > @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
> >        p[len] = ' ';
> >        p += len + 1;
> >      }
> > +  gcc_assert(p > str);
> >    p[-1] = '\0';
> >    return find_closest_string (arg, &candidates);  } diff --git
> > a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index
> > 03a984f2adf..a54e5a90464 100644
> > --- a/gcc/tree-ssa-ccp.cc
> > +++ b/gcc/tree-ssa-ccp.cc
> > @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
> >      }
> >  }
> >
> > +/* Work around -Wmaybe-uninitialized false positive during
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > +#endif
> > +
> >  /* Return the propagation value when applying the operation CODE to
> >     the value RHS yielding type TYPE.  */
> >
> > @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
> >    return val;
> >  }
> >
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* Return the propagation value when applying the operation CODE to
> >     the values RHS1 and RHS2 yielding type TYPE.  */
> >
> > diff --git a/gcc/wide-int.h b/gcc/wide-int.h index
> > 6be343c0eb5..9c50dd869b6 100644
> > --- a/gcc/wide-int.h
> > +++ b/gcc/wide-int.h
> > @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
> >                         get_binary_result (x, y));  }
> >
> > +/* Work around -Wmaybe-uninitialized false positive during
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > +#endif
> > +
> >  /* Copy the contents of Y to X, but keeping X's current precision.
> > */  template <typename T1, typename T2>  inline void @@ -1821,6
> > +1828,10 @@ wi::copy (T1 &x, const T2 &y)
> >    x.set_len (len, y.is_sign_extended);  }
> >
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* Return true if X fits in a HOST_WIDE_INT with no loss of
> > precision.  */  template <typename T>  inline bool
> > --
> > 2.25.1
> >
  
Eugene Rozenfeld May 12, 2023, 8:35 p.m. UTC | #6
Thank you, Richard. I went with your suggestion. New patch:


[PATCH] Disable warnings as errors for STAGEautofeedback.

Compilation during STAGEautofeedback produces additional warnings
since inlining decisions with -fauto-profile are different from
other builds.

This patches disables warnings as errors for STAGEautofeedback.

Tested on x86_64-pc-linux-gnu.

ChangeLog:

        * Makefile.in: Disable warnings as errors for STAGEautofeedback
---
 Makefile.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 33f3c862557..4c14c73ea61 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -590,8 +590,7 @@ STAGEautofeedback_CXXFLAGS = $(CXXFLAGS)
 STAGEautofeedback_CXXFLAGS = $(STAGEautofeedback_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGEautofeedback_TFLAGS = $(STAGE_TFLAGS)
-STAGEautofeedback_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
-
+STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS))
 
 # By default, C and C++ are the only stage1 languages, because they are the
 # only ones we require to build with the bootstrap compiler, and also the
-- 
2.25.1

Thanks,

Eugene

-----Original Message-----
From: Richard Biener <richard.guenther@gmail.com> 
Sent: Thursday, May 11, 2023 1:58 AM
To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings during autoprofiledbootstrap build

On Thu, May 11, 2023 at 4:23 AM Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> wrote:
>
> I'm ok with disabling warnings as errors for autoprofiledbootstrap. What's the proper way to do that? Searching for "--disable-werror" I see matches in lib configure files but not in gcc files.

We have --with-build-config selecting things like bootstrap-O3 and configure then disables werror by default if the build config is anything other than the default or bootstrap-debug.

Of course profiledbootstrap and autoprofiledbootstrap are not build configs but make targets - that makes it more difficult (or impossible) to use the --disable-werror machinery here.

There is

STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@

so it might be possible to filter out --enable-werror-always from STAGEautofeedback_CONFIGURE_FLAGS?

Richard.

> Thanks,
>
> Eugene
>
> -----Original Message-----
> From: Richard Biener <richard.guenther@gmail.com>
> Sent: Tuesday, May 9, 2023 11:40 PM
> To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
> Cc: gcc-patches@gcc.gnu.org
> Subject: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings 
> during autoprofiledbootstrap build
>
> On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >
> > autoprofiledbootstrap build produces new warnings since inlining 
> > decisions are different from other builds. This patch contains fixes 
> > and workarounds for those warnings.
> >
> > Tested on x86_64-pc-linux-gnu.
>
> Rather than this would it make sense to add --disable-werror to autoprofiledbootstrap configs like we do for others?  I also wonder how "stable" the afdo bootstrap inlining decisions are, so applying these workarounds may not be sustainable?
>
> > gcc/ChangeLog:
> >
> >         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
> >         -Wstringop-overflow false positive during autoprofiledbootstrap
> >         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
> >         warning during autoprofiledbootstrap
> >         * lra-eliminations.cc (setup_can_eliminate): Work around
> >         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
> >         * opts-common.cc (candidates_list_and_hint): Work around
> >         -Wstringop-overflow false positive during autoprofiledbootstrap
> >         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
> >         false positive during autoprofiledbootstrap
> >         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
> >         positive during autoprofiledbootstrap
> > ---
> >  gcc/config/i386/i386-expand.cc | 11 +++++++++++
> >  gcc/ipa-devirt.cc              |  3 ++-
> >  gcc/lra-eliminations.cc        | 11 +++++++++++
> >  gcc/opts-common.cc             |  1 +
> >  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
> >  gcc/wide-int.h                 | 11 +++++++++++
> >  6 files changed, 47 insertions(+), 1 deletion(-)
> >
> > diff --git a/gcc/config/i386/i386-expand.cc 
> > b/gcc/config/i386/i386-expand.cc index 634fe61ba79..be9f912775b 
> > 100644
> > --- a/gcc/config/i386/i386-expand.cc
> > +++ b/gcc/config/i386/i386-expand.cc
> > @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct 
> > expand_vec_perm_d *d)
> >
> >  static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d 
> > *d);
> >
> > +/* Work around -Wstringop-overflow false positive during 
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 7001
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wstringop-overflow"
> > +#endif
> > +
> >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
> >     a two vector permutation into a single vector permutation by using
> >     an interleave operation to merge the vectors.  */ @@ -20737,6
> > +20744,10 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d 
> > +*d)
> >    return true;
> >  }
> >
> > +# if GCC_VERSION >= 7001
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
> >     a single vector cross-lane permutation into vpermq followed
> >     by any of the single insn permutations.  */ diff --git 
> > a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index 
> > 819860258d1..36ea266e834
> > 100644
> > --- a/gcc/ipa-devirt.cc
> > +++ b/gcc/ipa-devirt.cc
> > @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
> >        odr = cplus_demangle (odr, opts);
> >      }
> >
> > -  fprintf (stderr, "%s\n", odr);
> > +  if (odr != NULL)
> > +    fprintf (stderr, "%s\n", odr);
> >  }
> >
> >  /* Register ODR enum so we later stream record about its values.  
> > */ diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc 
> > index
> > 42206366669..05e2a7e0d68 100644
> > --- a/gcc/lra-eliminations.cc
> > +++ b/gcc/lra-eliminations.cc
> > @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
> >    print_elim_table (stderr);
> >  }
> >
> > +/* Work around -Wmaybe-uninitialized false positive during 
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > +#endif
> > +
> >  /* Setup possibility of elimination in elimination table element EP to
> >     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
> >     pointer to stack pointer is not possible anymore.  */ @@ -152,6
> > +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool 
> > +value)
> >      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;  }
> >
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* Map: eliminable "from" register -> its current elimination,
> >     or NULL if none.  The elimination table may contain more than
> >     one elimination for the same hard register, but this map 
> > specifies diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index
> > 23ddcaa3b55..0bb8e34e2b0 100644
> > --- a/gcc/opts-common.cc
> > +++ b/gcc/opts-common.cc
> > @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
> >        p[len] = ' ';
> >        p += len + 1;
> >      }
> > +  gcc_assert(p > str);
> >    p[-1] = '\0';
> >    return find_closest_string (arg, &candidates);  } diff --git 
> > a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index
> > 03a984f2adf..a54e5a90464 100644
> > --- a/gcc/tree-ssa-ccp.cc
> > +++ b/gcc/tree-ssa-ccp.cc
> > @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
> >      }
> >  }
> >
> > +/* Work around -Wmaybe-uninitialized false positive during 
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > +#endif
> > +
> >  /* Return the propagation value when applying the operation CODE to
> >     the value RHS yielding type TYPE.  */
> >
> > @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
> >    return val;
> >  }
> >
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* Return the propagation value when applying the operation CODE to
> >     the values RHS1 and RHS2 yielding type TYPE.  */
> >
> > diff --git a/gcc/wide-int.h b/gcc/wide-int.h index
> > 6be343c0eb5..9c50dd869b6 100644
> > --- a/gcc/wide-int.h
> > +++ b/gcc/wide-int.h
> > @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
> >                         get_binary_result (x, y));  }
> >
> > +/* Work around -Wmaybe-uninitialized false positive during 
> > +autoprofiledbootstrap.  */
> > +
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > +#endif
> > +
> >  /* Copy the contents of Y to X, but keeping X's current precision.
> > */  template <typename T1, typename T2>  inline void @@ -1821,6
> > +1828,10 @@ wi::copy (T1 &x, const T2 &y)
> >    x.set_len (len, y.is_sign_extended);  }
> >
> > +# if GCC_VERSION >= 4007
> > +#pragma GCC diagnostic pop
> > +#endif
> > +
> >  /* Return true if X fits in a HOST_WIDE_INT with no loss of 
> > precision.  */  template <typename T>  inline bool
> > --
> > 2.25.1
> >
  
Richard Biener May 15, 2023, 7:30 a.m. UTC | #7
On Fri, May 12, 2023 at 10:35 PM Eugene Rozenfeld
<Eugene.Rozenfeld@microsoft.com> wrote:
>
> Thank you, Richard. I went with your suggestion. New patch:
>
>
> [PATCH] Disable warnings as errors for STAGEautofeedback.
>
> Compilation during STAGEautofeedback produces additional warnings
> since inlining decisions with -fauto-profile are different from
> other builds.
>
> This patches disables warnings as errors for STAGEautofeedback.

Can you add a comment before the filtering?

Otherwise looks good to me - please leave others 24h to comment before you
commit.

Thanks,
Richard.

> Tested on x86_64-pc-linux-gnu.
>
> ChangeLog:
>
>         * Makefile.in: Disable warnings as errors for STAGEautofeedback
> ---
>  Makefile.in | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/Makefile.in b/Makefile.in
> index 33f3c862557..4c14c73ea61 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -590,8 +590,7 @@ STAGEautofeedback_CXXFLAGS = $(CXXFLAGS)
>  STAGEautofeedback_CXXFLAGS = $(STAGEautofeedback_CFLAGS)
>  @endif target-libstdc++-v3-bootstrap
>  STAGEautofeedback_TFLAGS = $(STAGE_TFLAGS)
> -STAGEautofeedback_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
> -
> +STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS))
>
>  # By default, C and C++ are the only stage1 languages, because they are the
>  # only ones we require to build with the bootstrap compiler, and also the
> --
> 2.25.1
>
> Thanks,
>
> Eugene
>
> -----Original Message-----
> From: Richard Biener <richard.guenther@gmail.com>
> Sent: Thursday, May 11, 2023 1:58 AM
> To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings during autoprofiledbootstrap build
>
> On Thu, May 11, 2023 at 4:23 AM Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> wrote:
> >
> > I'm ok with disabling warnings as errors for autoprofiledbootstrap. What's the proper way to do that? Searching for "--disable-werror" I see matches in lib configure files but not in gcc files.
>
> We have --with-build-config selecting things like bootstrap-O3 and configure then disables werror by default if the build config is anything other than the default or bootstrap-debug.
>
> Of course profiledbootstrap and autoprofiledbootstrap are not build configs but make targets - that makes it more difficult (or impossible) to use the --disable-werror machinery here.
>
> There is
>
> STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
>
> so it might be possible to filter out --enable-werror-always from STAGEautofeedback_CONFIGURE_FLAGS?
>
> Richard.
>
> > Thanks,
> >
> > Eugene
> >
> > -----Original Message-----
> > From: Richard Biener <richard.guenther@gmail.com>
> > Sent: Tuesday, May 9, 2023 11:40 PM
> > To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
> > Cc: gcc-patches@gcc.gnu.org
> > Subject: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings
> > during autoprofiledbootstrap build
> >
> > On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > autoprofiledbootstrap build produces new warnings since inlining
> > > decisions are different from other builds. This patch contains fixes
> > > and workarounds for those warnings.
> > >
> > > Tested on x86_64-pc-linux-gnu.
> >
> > Rather than this would it make sense to add --disable-werror to autoprofiledbootstrap configs like we do for others?  I also wonder how "stable" the afdo bootstrap inlining decisions are, so applying these workarounds may not be sustainable?
> >
> > > gcc/ChangeLog:
> > >
> > >         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
> > >         -Wstringop-overflow false positive during autoprofiledbootstrap
> > >         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
> > >         warning during autoprofiledbootstrap
> > >         * lra-eliminations.cc (setup_can_eliminate): Work around
> > >         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
> > >         * opts-common.cc (candidates_list_and_hint): Work around
> > >         -Wstringop-overflow false positive during autoprofiledbootstrap
> > >         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
> > >         false positive during autoprofiledbootstrap
> > >         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
> > >         positive during autoprofiledbootstrap
> > > ---
> > >  gcc/config/i386/i386-expand.cc | 11 +++++++++++
> > >  gcc/ipa-devirt.cc              |  3 ++-
> > >  gcc/lra-eliminations.cc        | 11 +++++++++++
> > >  gcc/opts-common.cc             |  1 +
> > >  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
> > >  gcc/wide-int.h                 | 11 +++++++++++
> > >  6 files changed, 47 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/gcc/config/i386/i386-expand.cc
> > > b/gcc/config/i386/i386-expand.cc index 634fe61ba79..be9f912775b
> > > 100644
> > > --- a/gcc/config/i386/i386-expand.cc
> > > +++ b/gcc/config/i386/i386-expand.cc
> > > @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct
> > > expand_vec_perm_d *d)
> > >
> > >  static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d
> > > *d);
> > >
> > > +/* Work around -Wstringop-overflow false positive during
> > > +autoprofiledbootstrap.  */
> > > +
> > > +# if GCC_VERSION >= 7001
> > > +#pragma GCC diagnostic push
> > > +#pragma GCC diagnostic ignored "-Wstringop-overflow"
> > > +#endif
> > > +
> > >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
> > >     a two vector permutation into a single vector permutation by using
> > >     an interleave operation to merge the vectors.  */ @@ -20737,6
> > > +20744,10 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d
> > > +*d)
> > >    return true;
> > >  }
> > >
> > > +# if GCC_VERSION >= 7001
> > > +#pragma GCC diagnostic pop
> > > +#endif
> > > +
> > >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
> > >     a single vector cross-lane permutation into vpermq followed
> > >     by any of the single insn permutations.  */ diff --git
> > > a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index
> > > 819860258d1..36ea266e834
> > > 100644
> > > --- a/gcc/ipa-devirt.cc
> > > +++ b/gcc/ipa-devirt.cc
> > > @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
> > >        odr = cplus_demangle (odr, opts);
> > >      }
> > >
> > > -  fprintf (stderr, "%s\n", odr);
> > > +  if (odr != NULL)
> > > +    fprintf (stderr, "%s\n", odr);
> > >  }
> > >
> > >  /* Register ODR enum so we later stream record about its values.
> > > */ diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
> > > index
> > > 42206366669..05e2a7e0d68 100644
> > > --- a/gcc/lra-eliminations.cc
> > > +++ b/gcc/lra-eliminations.cc
> > > @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
> > >    print_elim_table (stderr);
> > >  }
> > >
> > > +/* Work around -Wmaybe-uninitialized false positive during
> > > +autoprofiledbootstrap.  */
> > > +
> > > +# if GCC_VERSION >= 4007
> > > +#pragma GCC diagnostic push
> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > > +#endif
> > > +
> > >  /* Setup possibility of elimination in elimination table element EP to
> > >     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
> > >     pointer to stack pointer is not possible anymore.  */ @@ -152,6
> > > +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool
> > > +value)
> > >      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;  }
> > >
> > > +# if GCC_VERSION >= 4007
> > > +#pragma GCC diagnostic pop
> > > +#endif
> > > +
> > >  /* Map: eliminable "from" register -> its current elimination,
> > >     or NULL if none.  The elimination table may contain more than
> > >     one elimination for the same hard register, but this map
> > > specifies diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index
> > > 23ddcaa3b55..0bb8e34e2b0 100644
> > > --- a/gcc/opts-common.cc
> > > +++ b/gcc/opts-common.cc
> > > @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
> > >        p[len] = ' ';
> > >        p += len + 1;
> > >      }
> > > +  gcc_assert(p > str);
> > >    p[-1] = '\0';
> > >    return find_closest_string (arg, &candidates);  } diff --git
> > > a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index
> > > 03a984f2adf..a54e5a90464 100644
> > > --- a/gcc/tree-ssa-ccp.cc
> > > +++ b/gcc/tree-ssa-ccp.cc
> > > @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
> > >      }
> > >  }
> > >
> > > +/* Work around -Wmaybe-uninitialized false positive during
> > > +autoprofiledbootstrap.  */
> > > +
> > > +# if GCC_VERSION >= 4007
> > > +#pragma GCC diagnostic push
> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > > +#endif
> > > +
> > >  /* Return the propagation value when applying the operation CODE to
> > >     the value RHS yielding type TYPE.  */
> > >
> > > @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
> > >    return val;
> > >  }
> > >
> > > +# if GCC_VERSION >= 4007
> > > +#pragma GCC diagnostic pop
> > > +#endif
> > > +
> > >  /* Return the propagation value when applying the operation CODE to
> > >     the values RHS1 and RHS2 yielding type TYPE.  */
> > >
> > > diff --git a/gcc/wide-int.h b/gcc/wide-int.h index
> > > 6be343c0eb5..9c50dd869b6 100644
> > > --- a/gcc/wide-int.h
> > > +++ b/gcc/wide-int.h
> > > @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
> > >                         get_binary_result (x, y));  }
> > >
> > > +/* Work around -Wmaybe-uninitialized false positive during
> > > +autoprofiledbootstrap.  */
> > > +
> > > +# if GCC_VERSION >= 4007
> > > +#pragma GCC diagnostic push
> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> > > +#endif
> > > +
> > >  /* Copy the contents of Y to X, but keeping X's current precision.
> > > */  template <typename T1, typename T2>  inline void @@ -1821,6
> > > +1828,10 @@ wi::copy (T1 &x, const T2 &y)
> > >    x.set_len (len, y.is_sign_extended);  }
> > >
> > > +# if GCC_VERSION >= 4007
> > > +#pragma GCC diagnostic pop
> > > +#endif
> > > +
> > >  /* Return true if X fits in a HOST_WIDE_INT with no loss of
> > > precision.  */  template <typename T>  inline bool
> > > --
> > > 2.25.1
> > >
  
Thomas Schwinge May 17, 2023, 7:05 a.m. UTC | #8
Hi!

On 2023-05-15T09:30:35+0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> On Fri, May 12, 2023 at 10:35 PM Eugene Rozenfeld
> <Eugene.Rozenfeld@microsoft.com> wrote:
>>
>> Thank you, Richard. I went with your suggestion. New patch:
>>
>>
>> [PATCH] Disable warnings as errors for STAGEautofeedback.
>>
>> Compilation during STAGEautofeedback produces additional warnings
>> since inlining decisions with -fauto-profile are different from
>> other builds.
>>
>> This patches disables warnings as errors for STAGEautofeedback.
>
> Can you add a comment before the filtering?
>
> Otherwise looks good to me - please leave others 24h to comment before you
> commit.

>> --- a/Makefile.in
>> +++ b/Makefile.in
>> @@ -590,8 +590,7 @@ STAGEautofeedback_CXXFLAGS = $(CXXFLAGS)
>>  STAGEautofeedback_CXXFLAGS = $(STAGEautofeedback_CFLAGS)
>>  @endif target-libstdc++-v3-bootstrap
>>  STAGEautofeedback_TFLAGS = $(STAGE_TFLAGS)
>> -STAGEautofeedback_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
>> -
>> +STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS))

That's not how it works; the next person running 'autogen Makefile.def'
to regenerate 'Makefile.in' is going to undo those changes.  Instead,
modify 'Makefile.def', 'Makefile.tpl', and then 'autogen Makefile.def'.


Grüße
 Thomas


>> -----Original Message-----
>> From: Richard Biener <richard.guenther@gmail.com>
>> Sent: Thursday, May 11, 2023 1:58 AM
>> To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings during autoprofiledbootstrap build
>>
>> On Thu, May 11, 2023 at 4:23 AM Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> wrote:
>> >
>> > I'm ok with disabling warnings as errors for autoprofiledbootstrap. What's the proper way to do that? Searching for "--disable-werror" I see matches in lib configure files but not in gcc files.
>>
>> We have --with-build-config selecting things like bootstrap-O3 and configure then disables werror by default if the build config is anything other than the default or bootstrap-debug.
>>
>> Of course profiledbootstrap and autoprofiledbootstrap are not build configs but make targets - that makes it more difficult (or impossible) to use the --disable-werror machinery here.
>>
>> There is
>>
>> STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
>>
>> so it might be possible to filter out --enable-werror-always from STAGEautofeedback_CONFIGURE_FLAGS?
>>
>> Richard.
>>
>> > Thanks,
>> >
>> > Eugene
>> >
>> > -----Original Message-----
>> > From: Richard Biener <richard.guenther@gmail.com>
>> > Sent: Tuesday, May 9, 2023 11:40 PM
>> > To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
>> > Cc: gcc-patches@gcc.gnu.org
>> > Subject: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings
>> > during autoprofiledbootstrap build
>> >
>> > On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> > >
>> > > autoprofiledbootstrap build produces new warnings since inlining
>> > > decisions are different from other builds. This patch contains fixes
>> > > and workarounds for those warnings.
>> > >
>> > > Tested on x86_64-pc-linux-gnu.
>> >
>> > Rather than this would it make sense to add --disable-werror to autoprofiledbootstrap configs like we do for others?  I also wonder how "stable" the afdo bootstrap inlining decisions are, so applying these workarounds may not be sustainable?
>> >
>> > > gcc/ChangeLog:
>> > >
>> > >         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
>> > >         -Wstringop-overflow false positive during autoprofiledbootstrap
>> > >         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
>> > >         warning during autoprofiledbootstrap
>> > >         * lra-eliminations.cc (setup_can_eliminate): Work around
>> > >         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
>> > >         * opts-common.cc (candidates_list_and_hint): Work around
>> > >         -Wstringop-overflow false positive during autoprofiledbootstrap
>> > >         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
>> > >         false positive during autoprofiledbootstrap
>> > >         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
>> > >         positive during autoprofiledbootstrap
>> > > ---
>> > >  gcc/config/i386/i386-expand.cc | 11 +++++++++++
>> > >  gcc/ipa-devirt.cc              |  3 ++-
>> > >  gcc/lra-eliminations.cc        | 11 +++++++++++
>> > >  gcc/opts-common.cc             |  1 +
>> > >  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
>> > >  gcc/wide-int.h                 | 11 +++++++++++
>> > >  6 files changed, 47 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/gcc/config/i386/i386-expand.cc
>> > > b/gcc/config/i386/i386-expand.cc index 634fe61ba79..be9f912775b
>> > > 100644
>> > > --- a/gcc/config/i386/i386-expand.cc
>> > > +++ b/gcc/config/i386/i386-expand.cc
>> > > @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct
>> > > expand_vec_perm_d *d)
>> > >
>> > >  static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d
>> > > *d);
>> > >
>> > > +/* Work around -Wstringop-overflow false positive during
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 7001
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wstringop-overflow"
>> > > +#endif
>> > > +
>> > >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>> > >     a two vector permutation into a single vector permutation by using
>> > >     an interleave operation to merge the vectors.  */ @@ -20737,6
>> > > +20744,10 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d
>> > > +*d)
>> > >    return true;
>> > >  }
>> > >
>> > > +# if GCC_VERSION >= 7001
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>> > >     a single vector cross-lane permutation into vpermq followed
>> > >     by any of the single insn permutations.  */ diff --git
>> > > a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index
>> > > 819860258d1..36ea266e834
>> > > 100644
>> > > --- a/gcc/ipa-devirt.cc
>> > > +++ b/gcc/ipa-devirt.cc
>> > > @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
>> > >        odr = cplus_demangle (odr, opts);
>> > >      }
>> > >
>> > > -  fprintf (stderr, "%s\n", odr);
>> > > +  if (odr != NULL)
>> > > +    fprintf (stderr, "%s\n", odr);
>> > >  }
>> > >
>> > >  /* Register ODR enum so we later stream record about its values.
>> > > */ diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
>> > > index
>> > > 42206366669..05e2a7e0d68 100644
>> > > --- a/gcc/lra-eliminations.cc
>> > > +++ b/gcc/lra-eliminations.cc
>> > > @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
>> > >    print_elim_table (stderr);
>> > >  }
>> > >
>> > > +/* Work around -Wmaybe-uninitialized false positive during
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>> > > +#endif
>> > > +
>> > >  /* Setup possibility of elimination in elimination table element EP to
>> > >     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
>> > >     pointer to stack pointer is not possible anymore.  */ @@ -152,6
>> > > +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool
>> > > +value)
>> > >      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;  }
>> > >
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* Map: eliminable "from" register -> its current elimination,
>> > >     or NULL if none.  The elimination table may contain more than
>> > >     one elimination for the same hard register, but this map
>> > > specifies diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index
>> > > 23ddcaa3b55..0bb8e34e2b0 100644
>> > > --- a/gcc/opts-common.cc
>> > > +++ b/gcc/opts-common.cc
>> > > @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
>> > >        p[len] = ' ';
>> > >        p += len + 1;
>> > >      }
>> > > +  gcc_assert(p > str);
>> > >    p[-1] = '\0';
>> > >    return find_closest_string (arg, &candidates);  } diff --git
>> > > a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index
>> > > 03a984f2adf..a54e5a90464 100644
>> > > --- a/gcc/tree-ssa-ccp.cc
>> > > +++ b/gcc/tree-ssa-ccp.cc
>> > > @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
>> > >      }
>> > >  }
>> > >
>> > > +/* Work around -Wmaybe-uninitialized false positive during
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>> > > +#endif
>> > > +
>> > >  /* Return the propagation value when applying the operation CODE to
>> > >     the value RHS yielding type TYPE.  */
>> > >
>> > > @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
>> > >    return val;
>> > >  }
>> > >
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* Return the propagation value when applying the operation CODE to
>> > >     the values RHS1 and RHS2 yielding type TYPE.  */
>> > >
>> > > diff --git a/gcc/wide-int.h b/gcc/wide-int.h index
>> > > 6be343c0eb5..9c50dd869b6 100644
>> > > --- a/gcc/wide-int.h
>> > > +++ b/gcc/wide-int.h
>> > > @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
>> > >                         get_binary_result (x, y));  }
>> > >
>> > > +/* Work around -Wmaybe-uninitialized false positive during
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>> > > +#endif
>> > > +
>> > >  /* Copy the contents of Y to X, but keeping X's current precision.
>> > > */  template <typename T1, typename T2>  inline void @@ -1821,6
>> > > +1828,10 @@ wi::copy (T1 &x, const T2 &y)
>> > >    x.set_len (len, y.is_sign_extended);  }
>> > >
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* Return true if X fits in a HOST_WIDE_INT with no loss of
>> > > precision.  */  template <typename T>  inline bool
>> > > --
>> > > 2.25.1
>> > >
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  
Eugene Rozenfeld May 18, 2023, 5:53 a.m. UTC | #9
Thank you for catching this, Thomas!
I modified Makefile.tmp and regenerated Makefile.in.

Here is the patch I pushed:

[PATCH] Disable warnings as errors for STAGEautofeedback.

Compilation during STAGEautofeedback produces additional warnings
since inlining decisions with -fauto-profile are different from
other builds.

This patches disables warnings as errors for STAGEautofeedback.

Tested on x86_64-pc-linux-gnu.

ChangeLog:

	* Makefile.tpl: Disable warnings as errors for STAGEautofeedback
	* Makefile.in: Regenerate
---
 Makefile.in  | 8 +++++---
 Makefile.tpl | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index a89bac02351..b559454cc90 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -590,9 +590,8 @@ STAGEautofeedback_CXXFLAGS = $(CXXFLAGS)
 STAGEautofeedback_CXXFLAGS = $(STAGEautofeedback_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGEautofeedback_TFLAGS = $(STAGE_TFLAGS)
-# Disable warnings as errors since inlining decisions with -fauto-profile
-# may result in additional warnings.
-STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS))
+STAGEautofeedback_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
+
 
 # By default, C and C++ are the only stage1 languages, because they are the
 # only ones we require to build with the bootstrap compiler, and also the
@@ -641,6 +640,9 @@ STAGEautoprofile_TFLAGS = $(STAGE2_TFLAGS)
 
 STAGEautofeedback_CFLAGS = $(STAGE3_CFLAGS)
 STAGEautofeedback_TFLAGS = $(STAGE3_TFLAGS)
+# Disable warnings as errors since inlining decisions with -fauto-profile
+# may result in additional warnings.
+STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS))
 
 do-compare = @do_compare@
 do-compare3 = $(do-compare)
diff --git a/Makefile.tpl b/Makefile.tpl
index 9d8ef9cf678..6bcee3021c9 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -563,6 +563,9 @@ STAGEautoprofile_TFLAGS = $(STAGE2_TFLAGS)
 
 STAGEautofeedback_CFLAGS = $(STAGE3_CFLAGS)
 STAGEautofeedback_TFLAGS = $(STAGE3_TFLAGS)
+# Disable warnings as errors since inlining decisions with -fauto-profile
+# may result in additional warnings.
+STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out --enable-werror-always,$(STAGE_CONFIGURE_FLAGS))
 
 do-compare = @do_compare@
 do-compare3 = $(do-compare)
-- 
2.25.1

Eugene
-----Original Message-----
From: Thomas Schwinge <thomas@codesourcery.com> 
Sent: Wednesday, May 17, 2023 12:05 AM
To: Richard Biener <richard.guenther@gmail.com>; Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings during autoprofiledbootstrap build

Hi!

On 2023-05-15T09:30:35+0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> On Fri, May 12, 2023 at 10:35 PM Eugene Rozenfeld 
> <Eugene.Rozenfeld@microsoft.com> wrote:
>>
>> Thank you, Richard. I went with your suggestion. New patch:
>>
>>
>> [PATCH] Disable warnings as errors for STAGEautofeedback.
>>
>> Compilation during STAGEautofeedback produces additional warnings 
>> since inlining decisions with -fauto-profile are different from other 
>> builds.
>>
>> This patches disables warnings as errors for STAGEautofeedback.
>
> Can you add a comment before the filtering?
>
> Otherwise looks good to me - please leave others 24h to comment before 
> you commit.

>> --- a/Makefile.in
>> +++ b/Makefile.in
>> @@ -590,8 +590,7 @@ STAGEautofeedback_CXXFLAGS = $(CXXFLAGS)  
>> STAGEautofeedback_CXXFLAGS = $(STAGEautofeedback_CFLAGS)  @endif 
>> target-libstdc++-v3-bootstrap  STAGEautofeedback_TFLAGS = 
>> $(STAGE_TFLAGS) -STAGEautofeedback_CONFIGURE_FLAGS = 
>> $(STAGE_CONFIGURE_FLAGS)
>> -
>> +STAGEautofeedback_CONFIGURE_FLAGS = $(filter-out 
>> +--enable-werror-always,$(STAGE_CONFIGURE_FLAGS))

That's not how it works; the next person running 'autogen Makefile.def'
to regenerate 'Makefile.in' is going to undo those changes.  Instead, modify 'Makefile.def', 'Makefile.tpl', and then 'autogen Makefile.def'.


Grüße
 Thomas


>> -----Original Message-----
>> From: Richard Biener <richard.guenther@gmail.com>
>> Sent: Thursday, May 11, 2023 1:58 AM
>> To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [EXTERNAL] Re: [PATCH] Fixes and workarounds for 
>> warnings during autoprofiledbootstrap build
>>
>> On Thu, May 11, 2023 at 4:23 AM Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> wrote:
>> >
>> > I'm ok with disabling warnings as errors for autoprofiledbootstrap. What's the proper way to do that? Searching for "--disable-werror" I see matches in lib configure files but not in gcc files.
>>
>> We have --with-build-config selecting things like bootstrap-O3 and configure then disables werror by default if the build config is anything other than the default or bootstrap-debug.
>>
>> Of course profiledbootstrap and autoprofiledbootstrap are not build configs but make targets - that makes it more difficult (or impossible) to use the --disable-werror machinery here.
>>
>> There is
>>
>> STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
>>
>> so it might be possible to filter out --enable-werror-always from STAGEautofeedback_CONFIGURE_FLAGS?
>>
>> Richard.
>>
>> > Thanks,
>> >
>> > Eugene
>> >
>> > -----Original Message-----
>> > From: Richard Biener <richard.guenther@gmail.com>
>> > Sent: Tuesday, May 9, 2023 11:40 PM
>> > To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
>> > Cc: gcc-patches@gcc.gnu.org
>> > Subject: [EXTERNAL] Re: [PATCH] Fixes and workarounds for warnings 
>> > during autoprofiledbootstrap build
>> >
>> > On Wed, May 10, 2023 at 3:38 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> > >
>> > > autoprofiledbootstrap build produces new warnings since inlining 
>> > > decisions are different from other builds. This patch contains 
>> > > fixes and workarounds for those warnings.
>> > >
>> > > Tested on x86_64-pc-linux-gnu.
>> >
>> > Rather than this would it make sense to add --disable-werror to autoprofiledbootstrap configs like we do for others?  I also wonder how "stable" the afdo bootstrap inlining decisions are, so applying these workarounds may not be sustainable?
>> >
>> > > gcc/ChangeLog:
>> > >
>> > >         * config/i386/i386-expand.cc (expand_vec_perm_interleave2): Work around
>> > >         -Wstringop-overflow false positive during autoprofiledbootstrap
>> > >         * ipa-devirt.cc (debug_tree_odr_name): Fix for -Wformat-overflow
>> > >         warning during autoprofiledbootstrap
>> > >         * lra-eliminations.cc (setup_can_eliminate): Work around
>> > >         -Wmaybe-uninitialized false positive during autoprofiledbootstrap
>> > >         * opts-common.cc (candidates_list_and_hint): Work around
>> > >         -Wstringop-overflow false positive during autoprofiledbootstrap
>> > >         * tree-ssa-ccp.cc (bit_value_unop): Work around -Wmaybe-uninitialized
>> > >         false positive during autoprofiledbootstrap
>> > >         * wide-int.h (wi::copy): Work around -Wmaybe-uninitialized false
>> > >         positive during autoprofiledbootstrap
>> > > ---
>> > >  gcc/config/i386/i386-expand.cc | 11 +++++++++++
>> > >  gcc/ipa-devirt.cc              |  3 ++-
>> > >  gcc/lra-eliminations.cc        | 11 +++++++++++
>> > >  gcc/opts-common.cc             |  1 +
>> > >  gcc/tree-ssa-ccp.cc            | 11 +++++++++++
>> > >  gcc/wide-int.h                 | 11 +++++++++++
>> > >  6 files changed, 47 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/gcc/config/i386/i386-expand.cc 
>> > > b/gcc/config/i386/i386-expand.cc index 634fe61ba79..be9f912775b
>> > > 100644
>> > > --- a/gcc/config/i386/i386-expand.cc
>> > > +++ b/gcc/config/i386/i386-expand.cc
>> > > @@ -20419,6 +20419,13 @@ expand_vec_perm_pblendv (struct 
>> > > expand_vec_perm_d *d)
>> > >
>> > >  static bool expand_vec_perm_interleave3 (struct 
>> > > expand_vec_perm_d *d);
>> > >
>> > > +/* Work around -Wstringop-overflow false positive during 
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 7001
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wstringop-overflow"
>> > > +#endif
>> > > +
>> > >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>> > >     a two vector permutation into a single vector permutation by using
>> > >     an interleave operation to merge the vectors.  */ @@ -20737,6
>> > > +20744,10 @@ expand_vec_perm_interleave2 (struct 
>> > > +expand_vec_perm_d
>> > > +*d)
>> > >    return true;
>> > >  }
>> > >
>> > > +# if GCC_VERSION >= 7001
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
>> > >     a single vector cross-lane permutation into vpermq followed
>> > >     by any of the single insn permutations.  */ diff --git 
>> > > a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index
>> > > 819860258d1..36ea266e834
>> > > 100644
>> > > --- a/gcc/ipa-devirt.cc
>> > > +++ b/gcc/ipa-devirt.cc
>> > > @@ -4033,7 +4033,8 @@ debug_tree_odr_name (tree type, bool demangle)
>> > >        odr = cplus_demangle (odr, opts);
>> > >      }
>> > >
>> > > -  fprintf (stderr, "%s\n", odr);
>> > > +  if (odr != NULL)
>> > > +    fprintf (stderr, "%s\n", odr);
>> > >  }
>> > >
>> > >  /* Register ODR enum so we later stream record about its values.
>> > > */ diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc 
>> > > index
>> > > 42206366669..05e2a7e0d68 100644
>> > > --- a/gcc/lra-eliminations.cc
>> > > +++ b/gcc/lra-eliminations.cc
>> > > @@ -138,6 +138,13 @@ lra_debug_elim_table (void)
>> > >    print_elim_table (stderr);
>> > >  }
>> > >
>> > > +/* Work around -Wmaybe-uninitialized false positive during 
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>> > > +#endif
>> > > +
>> > >  /* Setup possibility of elimination in elimination table element EP to
>> > >     VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
>> > >     pointer to stack pointer is not possible anymore.  */ @@ 
>> > > -152,6
>> > > +159,10 @@ setup_can_eliminate (class lra_elim_table *ep, bool
>> > > +value)
>> > >      REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;  }
>> > >
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* Map: eliminable "from" register -> its current elimination,
>> > >     or NULL if none.  The elimination table may contain more than
>> > >     one elimination for the same hard register, but this map 
>> > > specifies diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc 
>> > > index
>> > > 23ddcaa3b55..0bb8e34e2b0 100644
>> > > --- a/gcc/opts-common.cc
>> > > +++ b/gcc/opts-common.cc
>> > > @@ -1388,6 +1388,7 @@ candidates_list_and_hint (const char *arg, char *&str,
>> > >        p[len] = ' ';
>> > >        p += len + 1;
>> > >      }
>> > > +  gcc_assert(p > str);
>> > >    p[-1] = '\0';
>> > >    return find_closest_string (arg, &candidates);  } diff --git 
>> > > a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index
>> > > 03a984f2adf..a54e5a90464 100644
>> > > --- a/gcc/tree-ssa-ccp.cc
>> > > +++ b/gcc/tree-ssa-ccp.cc
>> > > @@ -1976,6 +1976,13 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
>> > >      }
>> > >  }
>> > >
>> > > +/* Work around -Wmaybe-uninitialized false positive during 
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>> > > +#endif
>> > > +
>> > >  /* Return the propagation value when applying the operation CODE to
>> > >     the value RHS yielding type TYPE.  */
>> > >
>> > > @@ -2011,6 +2018,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
>> > >    return val;
>> > >  }
>> > >
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* Return the propagation value when applying the operation CODE to
>> > >     the values RHS1 and RHS2 yielding type TYPE.  */
>> > >
>> > > diff --git a/gcc/wide-int.h b/gcc/wide-int.h index
>> > > 6be343c0eb5..9c50dd869b6 100644
>> > > --- a/gcc/wide-int.h
>> > > +++ b/gcc/wide-int.h
>> > > @@ -1806,6 +1806,13 @@ wi::get_binary_precision (const T1 &x, const T2 &y)
>> > >                         get_binary_result (x, y));  }
>> > >
>> > > +/* Work around -Wmaybe-uninitialized false positive during 
>> > > +autoprofiledbootstrap.  */
>> > > +
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
>> > > +#endif
>> > > +
>> > >  /* Copy the contents of Y to X, but keeping X's current precision.
>> > > */  template <typename T1, typename T2>  inline void @@ -1821,6
>> > > +1828,10 @@ wi::copy (T1 &x, const T2 &y)
>> > >    x.set_len (len, y.is_sign_extended);  }
>> > >
>> > > +# if GCC_VERSION >= 4007
>> > > +#pragma GCC diagnostic pop
>> > > +#endif
>> > > +
>> > >  /* Return true if X fits in a HOST_WIDE_INT with no loss of 
>> > > precision.  */  template <typename T>  inline bool
>> > > --
>> > > 2.25.1
>> > >
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Patch

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 634fe61ba79..be9f912775b 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -20419,6 +20419,13 @@  expand_vec_perm_pblendv (struct expand_vec_perm_d *d)
 
 static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d *d);
 
+/* Work around -Wstringop-overflow false positive during autoprofiledbootstrap.  */
+
+# if GCC_VERSION >= 7001
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+
 /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
    a two vector permutation into a single vector permutation by using
    an interleave operation to merge the vectors.  */
@@ -20737,6 +20744,10 @@  expand_vec_perm_interleave2 (struct expand_vec_perm_d *d)
   return true;
 }
 
+# if GCC_VERSION >= 7001
+#pragma GCC diagnostic pop
+#endif
+
 /* A subroutine of ix86_expand_vec_perm_const_1.  Try to simplify
    a single vector cross-lane permutation into vpermq followed
    by any of the single insn permutations.  */
diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
index 819860258d1..36ea266e834 100644
--- a/gcc/ipa-devirt.cc
+++ b/gcc/ipa-devirt.cc
@@ -4033,7 +4033,8 @@  debug_tree_odr_name (tree type, bool demangle)
       odr = cplus_demangle (odr, opts);
     }
 
-  fprintf (stderr, "%s\n", odr);
+  if (odr != NULL)
+    fprintf (stderr, "%s\n", odr);
 }
 
 /* Register ODR enum so we later stream record about its values.  */
diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
index 42206366669..05e2a7e0d68 100644
--- a/gcc/lra-eliminations.cc
+++ b/gcc/lra-eliminations.cc
@@ -138,6 +138,13 @@  lra_debug_elim_table (void)
   print_elim_table (stderr);
 }
 
+/* Work around -Wmaybe-uninitialized false positive during autoprofiledbootstrap.  */
+
+# if GCC_VERSION >= 4007
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
 /* Setup possibility of elimination in elimination table element EP to
    VALUE.  Setup FRAME_POINTER_NEEDED if elimination from frame
    pointer to stack pointer is not possible anymore.  */
@@ -152,6 +159,10 @@  setup_can_eliminate (class lra_elim_table *ep, bool value)
     REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = 0;
 }
 
+# if GCC_VERSION >= 4007
+#pragma GCC diagnostic pop
+#endif
+
 /* Map: eliminable "from" register -> its current elimination,
    or NULL if none.  The elimination table may contain more than
    one elimination for the same hard register, but this map specifies
diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index 23ddcaa3b55..0bb8e34e2b0 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -1388,6 +1388,7 @@  candidates_list_and_hint (const char *arg, char *&str,
       p[len] = ' ';
       p += len + 1;
     }
+  gcc_assert(p > str);
   p[-1] = '\0';
   return find_closest_string (arg, &candidates);
 }
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index 03a984f2adf..a54e5a90464 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -1976,6 +1976,13 @@  bit_value_binop (enum tree_code code, signop sgn, int width,
     }
 }
 
+/* Work around -Wmaybe-uninitialized false positive during autoprofiledbootstrap.  */
+
+# if GCC_VERSION >= 4007
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
 /* Return the propagation value when applying the operation CODE to
    the value RHS yielding type TYPE.  */
 
@@ -2011,6 +2018,10 @@  bit_value_unop (enum tree_code code, tree type, tree rhs)
   return val;
 }
 
+# if GCC_VERSION >= 4007
+#pragma GCC diagnostic pop
+#endif
+
 /* Return the propagation value when applying the operation CODE to
    the values RHS1 and RHS2 yielding type TYPE.  */
 
diff --git a/gcc/wide-int.h b/gcc/wide-int.h
index 6be343c0eb5..9c50dd869b6 100644
--- a/gcc/wide-int.h
+++ b/gcc/wide-int.h
@@ -1806,6 +1806,13 @@  wi::get_binary_precision (const T1 &x, const T2 &y)
 			get_binary_result (x, y));
 }
 
+/* Work around -Wmaybe-uninitialized false positive during autoprofiledbootstrap.  */
+
+# if GCC_VERSION >= 4007
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
 /* Copy the contents of Y to X, but keeping X's current precision.  */
 template <typename T1, typename T2>
 inline void
@@ -1821,6 +1828,10 @@  wi::copy (T1 &x, const T2 &y)
   x.set_len (len, y.is_sign_extended);
 }
 
+# if GCC_VERSION >= 4007
+#pragma GCC diagnostic pop
+#endif
+
 /* Return true if X fits in a HOST_WIDE_INT with no loss of precision.  */
 template <typename T>
 inline bool