public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c
@ 2022-01-04 5:50 pinskia at gcc dot gnu.org
2022-01-04 6:01 ` [Bug bootstrap/103899] " pinskia at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-04 5:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
Bug ID: 103899
Summary: make profiledbootstrap fails due to uninitialized
warning in expr.c
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: build, diagnostic
Severity: normal
Priority: P3
Component: bootstrap
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
I am filing this and will attach the preprocessed source in a few minutes:
/home/apinski/src/upstream-gcc/gcc/objdir1/./prev-gcc/xg++
-B/home/apinski/src/upstream-gcc/gcc/objdir1/./prev-gcc/
-B/usr/local/x86_64-pc-linux-gnu/bin/ -nostdinc++
-B/home/apinski/src/upstream-gcc/gcc/objdir1/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs
-B/home/apinski/src/upstream-gcc/gcc/objdir1/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs
-I/home/apinski/src/upstream-gcc/gcc/objdir1/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu
-I/home/apinski/src/upstream-gcc/gcc/objdir1/prev-x86_64-pc-linux-gnu/libstdc++-v3/include
-I/home/apinski/src/upstream-gcc/gcc/libstdc++-v3/libsupc++
-L/home/apinski/src/upstream-gcc/gcc/objdir1/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs
-L/home/apinski/src/upstream-gcc/gcc/objdir1/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs
-fno-PIE -c -g -O2 -fno-checking -gtoggle -fprofile-generate -DIN_GCC
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing
-Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I.
-I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include
-I../../gcc/../libcody -I/home/apinski/src/upstream-gcc/gcc/objdir1/./gmp
-I/home/apinski/src/upstream-gcc/gcc/gmp
-I/home/apinski/src/upstream-gcc/gcc/objdir1/./mpfr/src
-I/home/apinski/src/upstream-gcc/gcc/mpfr/src
-I/home/apinski/src/upstream-gcc/gcc/mpc/src -I../../gcc/../libdecnumber
-I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace
-I/home/apinski/src/upstream-gcc/gcc/objdir1/./isl/include
-I/home/apinski/src/upstream-gcc/gcc/isl/include -o expr.o -MT expr.o -MMD -MP
-MF ./.deps/expr.TPo ../../gcc/expr.c
In file included from ../../gcc/expr.c:26:
../../gcc/tree.h: In function ‘rtx_def* expand_expr_real_1(tree, rtx,
machine_mode, expand_modifier, rtx_def**, bool)’:
../../gcc/tree.h:244:56: error: ‘context’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
244 | #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code)
| ^~~~
../../gcc/expr.c:10343:8: note: ‘context’ was declared here
10343 | tree context;
| ^~~~~~~
cc1plus: all warnings being treated as errors
Makefile:1143: recipe for target 'expr.o' failed
make[3]: *** [expr.o] Error 1
I just did:
mkdir objdir1
cd objdir1
../configure
make profiledbootstrap
I tried to get a reduced testcase but I think there is a missing jump threading
so it just happen to work for the reduced testcase I tried.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug bootstrap/103899] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
@ 2022-01-04 6:01 ` pinskia at gcc dot gnu.org
2022-01-04 6:05 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-04 6:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 52113
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52113&action=edit
unreduced testcase
../prev-gcc/cc1plus expr-warning.ii -fpreprocessed -fno-PIE -g -O2
-fno-checking -gtoggle -fprofile-generate -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Werror -fno-common -Wno-implicit-fallthrough -quiet
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug bootstrap/103899] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
2022-01-04 6:01 ` [Bug bootstrap/103899] " pinskia at gcc dot gnu.org
@ 2022-01-04 6:05 ` pinskia at gcc dot gnu.org
2022-01-04 6:44 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-04 6:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am going to try to reduce the issue as I know without -fprofile-generate, GCC
does not warn .
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug bootstrap/103899] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
2022-01-04 6:01 ` [Bug bootstrap/103899] " pinskia at gcc dot gnu.org
2022-01-04 6:05 ` pinskia at gcc dot gnu.org
@ 2022-01-04 6:44 ` pinskia at gcc dot gnu.org
2022-01-05 8:17 ` [Bug tree-optimization/103899] [12 Regression] " pinskia at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-04 6:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect this is a regression and one caused by some of the jump threading
patches. Let me finish up reducing the testcase and I will test the reduced one
on different versions of GCC.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2022-01-04 6:44 ` pinskia at gcc dot gnu.org
@ 2022-01-05 8:17 ` pinskia at gcc dot gnu.org
2022-01-05 8:25 ` marxin at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-05 8:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization,
| |needs-bisection
Host|x86_64-linux-gnu |
Component|bootstrap |tree-optimization
Build|x86_64-linux-gnu |
Summary|make profiledbootstrap |[12 Regression] make
|fails due to uninitialized |profiledbootstrap fails due
|warning in expr.c |to uninitialized warning in
| |expr.c
Target Milestone|--- |12.0
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
int h;
int l ();
int *k ();
void nn ();
void expand_expr_real_1 (int *exp)
{
int m;
int *context;
m = 2;
if (h || !exp)
m = l ();
if (exp)
context = k ();
if (exp && context && context[0] == 0)
if (m == 0)
nn ();
}
----- CUT ----
Compile with "-O2 -W -Wall -Werror", there is no warning but once you add
-fprofile-generate there is an uninitialized warning for context.
There is a missing jump threading on the trunk which is causing the warning to
show up.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (3 preceding siblings ...)
2022-01-05 8:17 ` [Bug tree-optimization/103899] [12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-05 8:25 ` marxin at gcc dot gnu.org
2022-01-05 13:55 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-05 8:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-01-05
CC| |aldyh at gcc dot gnu.org
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Reduced testcase:
> int h;
> int l ();
> int *k ();
> void nn ();
> void expand_expr_real_1 (int *exp)
> {
> int m;
> int *context;
> m = 2;
> if (h || !exp)
> m = l ();
> if (exp)
> context = k ();
> if (exp && context && context[0] == 0)
> if (m == 0)
> nn ();
> }
> ----- CUT ----
> Compile with "-O2 -W -Wall -Werror", there is no warning but once you add
> -fprofile-generate there is an uninitialized warning for context.
> There is a missing jump threading on the trunk which is causing the warning
> to show up.
Started with r12-4790-g4b3a325f07acebf4, may I remove needs-bisection Keyword?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (4 preceding siblings ...)
2022-01-05 8:25 ` marxin at gcc dot gnu.org
@ 2022-01-05 13:55 ` jakub at gcc dot gnu.org
2022-01-05 14:06 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-05 13:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
While we should fix uninit warning to deal with this if possible, I think we
should also try to work around this in expr.c.
If following works, then I think it would be even a cleanup (as it moves the
context variable declaration to the sole spot where it is used):
--- gcc/expr.c.jj 2022-01-03 10:40:41.203164211 +0100
+++ gcc/expr.c 2022-01-05 14:47:47.684660031 +0100
@@ -10340,7 +10340,6 @@ expand_expr_real_1 (tree exp, rtx target
enum tree_code code = TREE_CODE (exp);
rtx subtarget, original_target;
int ignore;
- tree context;
bool reduce_bit_field;
location_t loc = EXPR_LOCATION (exp);
struct separate_ops ops;
@@ -10579,14 +10578,16 @@ expand_expr_real_1 (tree exp, rtx target
/* Variables inherited from containing functions should have
been lowered by this point. */
if (exp)
- context = decl_function_context (exp);
- gcc_assert (!exp
- || SCOPE_FILE_SCOPE_P (context)
- || context == current_function_decl
- || TREE_STATIC (exp)
- || DECL_EXTERNAL (exp)
- /* ??? C++ creates functions that are not TREE_STATIC. */
- || TREE_CODE (exp) == FUNCTION_DECL);
+ {
+ tree context = decl_function_context (exp);
+ gcc_assert (SCOPE_FILE_SCOPE_P (context)
+ || context == current_function_decl
+ || TREE_STATIC (exp)
+ || DECL_EXTERNAL (exp)
+ /* ??? C++ creates functions that are not
+ TREE_STATIC. */
+ || TREE_CODE (exp) == FUNCTION_DECL);
+ }
/* This is the case of an array whose size is to be determined
from its initializer, while the initializer is still being parsed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (5 preceding siblings ...)
2022-01-05 13:55 ` jakub at gcc dot gnu.org
@ 2022-01-05 14:06 ` jakub at gcc dot gnu.org
2022-01-05 21:28 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-05 14:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Confirmed it does help.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (6 preceding siblings ...)
2022-01-05 14:06 ` jakub at gcc dot gnu.org
@ 2022-01-05 21:28 ` pinskia at gcc dot gnu.org
2022-01-06 14:33 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-05 21:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #6)
> While we should fix uninit warning to deal with this if possible, I think we
> should also try to work around this in expr.c.
>
> If following works, then I think it would be even a cleanup (as it moves the
> context variable declaration to the sole spot where it is used):
Yes I do think we should improve the code in expr.c to better express this and
have this cleanup.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (7 preceding siblings ...)
2022-01-05 21:28 ` pinskia at gcc dot gnu.org
@ 2022-01-06 14:33 ` cvs-commit at gcc dot gnu.org
2022-01-06 14:46 ` jakub at gcc dot gnu.org
2022-01-18 13:56 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-06 14:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:db33b1059bcee3eeb36d174d59abf19f2bef5d66
commit r12-6280-gdb33b1059bcee3eeb36d174d59abf19f2bef5d66
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Jan 6 15:32:57 2022 +0100
expr: Workaround profiledbootstrap uninit false positive [PR103899]
The threader changes resulted in a false positive warning during
profiledbootstrap:
In file included from ../../gcc/expr.c:26:
../../gcc/tree.h: In function ârtx_def* expand_expr_real_1(tree, rtx,
machine_mode, expand_modifier, rtx_def**, bool)â:
../../gcc/tree.h:244:56: error: âcontextâ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
244 | #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code)
| ^~~~
../../gcc/expr.c:10343:8: note: âcontextâ was declared here
10343 | tree context;
| ^~~~~~~
While it will be nice to improve the uninit pass to handle it if possible
(I do not want to close the PR until that is done), doing profiledbootstrap
is a common thing to do, so a workaround is handy, especially as in this
case when the workaround seems to be the right thing to do, as it moves
a variable declaration to the only place where it is set and used and
avoids
the weird and for uninit asking
tree context;
...
if (exp)
context = ...;
gcc_assert (!exp
|| use (context)
|| use_some_more (context));
2022-01-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103899
* expr.c (expand_expr_real_1): Add a workaround for bogus uninit
warning by moving context variable to the only spot where it is
used
and moving gcc_assert into if body.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (8 preceding siblings ...)
2022-01-06 14:33 ` cvs-commit at gcc dot gnu.org
@ 2022-01-06 14:46 ` jakub at gcc dot gnu.org
2022-01-18 13:56 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-06 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Workaround applied, tree-ssa-uninit.c should be improved if possible though.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103899] [12 Regression] make profiledbootstrap fails due to uninitialized warning in expr.c
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
` (9 preceding siblings ...)
2022-01-06 14:46 ` jakub at gcc dot gnu.org
@ 2022-01-18 13:56 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-18 13:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103899
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
The build regression is fixed. If there's interest please file the comment#4
testcase in a separate enhancement bugreport (and yeah, -fprofile-generate
added CFG counters can twist costs of optimizations).
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-01-18 13:56 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 5:50 [Bug bootstrap/103899] New: make profiledbootstrap fails due to uninitialized warning in expr.c pinskia at gcc dot gnu.org
2022-01-04 6:01 ` [Bug bootstrap/103899] " pinskia at gcc dot gnu.org
2022-01-04 6:05 ` pinskia at gcc dot gnu.org
2022-01-04 6:44 ` pinskia at gcc dot gnu.org
2022-01-05 8:17 ` [Bug tree-optimization/103899] [12 Regression] " pinskia at gcc dot gnu.org
2022-01-05 8:25 ` marxin at gcc dot gnu.org
2022-01-05 13:55 ` jakub at gcc dot gnu.org
2022-01-05 14:06 ` jakub at gcc dot gnu.org
2022-01-05 21:28 ` pinskia at gcc dot gnu.org
2022-01-06 14:33 ` cvs-commit at gcc dot gnu.org
2022-01-06 14:46 ` jakub at gcc dot gnu.org
2022-01-18 13:56 ` rguenth at gcc dot gnu.org
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).