From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16062 invoked by alias); 10 Sep 2013 23:08:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 16018 invoked by uid 48); 10 Sep 2013 23:08:28 -0000 From: "davidxl at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58377] spurious "may be used uninitialized" warning with -Og Date: Tue, 10 Sep 2013 23:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: davidxl at google dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-09/txt/msg00770.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58377 --- Comment #10 from davidxl at google dot com --- When an incoming edge to a phi is a critical edge, the 'use BB' for the phi arg should be in the split BB of the edge. Pushing the use into either the Source BB or the dest BB will result in extending the 'use' falsely in more BBs. In this case, simply use the PHI's BB won't solve the problem, as there is an incoming path introduced not guarded by if (iftmp.1_3 != 0) I don't see a good way to fix it unless splitting the edge. David (In reply to davidxl from comment #9) > (In reply to Richard Biener from comment #5) > > Confirmed with the C++ FE, works with the C FE. Does not warn on trunk (for > > no good reason I think, the reason seems to be presence of loop structure > > and thus some extra BBs). > > > > Difference: > > > > trunk: > > > > [WORKLIST]: add to initial list: out_2 = PHI > > [CHECK]: examining phi: out_2 = PHI > > > > Use in stmt out_1 = PHI > > is guarded by : > > if (pop_first_bucket.2_10 != 0) > > > > [CHECK] Found def edge 0 in out_1 = PHI > > > > [CHECK] Found def edge 1 in out_1 = PHI > > Operand defs of phi out_2 = PHI > > is guarded by : > > if (out_12 != 0) > > [CHECK]: Found unguarded use: out_1 = PHI > > [WORKLIST]: Update worklist with phi: out_1 = PHI > out_2(3)> > > [CHECK]: examining phi: out_1 = PHI > > > > Use in stmt out_2 = PHI > > is guarded by : > > (.NOT.) if (iftmp.1_3 != 0) > > > > [CHECK] Found def edge 0 in out_1 = PHI > > > > [CHECK] Found def edge 1 in out_1 = PHI > > Operand defs of phi out_1 = PHI > > is guarded by : > > if (pop_first_bucket.2_10 != 0) > > (.AND.) > > if (out_12 != 0) > > (.OR.) > > if (pop_first_bucket.2_10 != 0) > > (.AND.) > > (.NOT.) if (out_12 != 0) > > > > Normalized to > > Operand defs of phi out_1 = PHI > > is guarded by : > > if (pop_first_bucket.2_10 != 0) > > ... > > > > vs. 4.8 branch: > > > > [WORKLIST]: add to initial list: out_2 = PHI > > [CHECK]: examining phi: out_2 = PHI > > > > Use in stmt out_1 = PHI > > is guarded by : > > if (pop_first_bucket.2_10 != 0) > > > > [CHECK] Found def edge 0 in out_1 = PHI > > > > [CHECK] Found def edge 1 in out_1 = PHI > > Operand defs of phi out_2 = PHI > > is guarded by : > > if (out_12 != 0) > > [CHECK]: Found unguarded use: out_1 = PHI > > [WORKLIST]: Update worklist with phi: out_1 = PHI > out_2(3)> > > [CHECK]: examining phi: out_1 = PHI > > [CHECK]: Found unguarded use: out_2 = PHI > > [CHECK]: Found unguarded use: _4 = PHI > > [WORKLIST]: Update worklist with phi: _4 = PHI > > [CHECK]: examining phi: _4 = PHI > > [CHECK]: Found unguarded use: return _4; > > > > The IL difference is that we have > > > > : > > # out_1 = PHI > > # iftmp.1_3 = PHI <1(4), 0(5), 0(3)> > > if (iftmp.1_3 != 0) > > goto ; > > else > > goto ; > > > > : > > out_13 = out_1; > > goto ; > > ... > > : > > # _4 = PHI > > return _4; > > > > which doesn't warn vs. > > > > : > > # out_1 = PHI > > # iftmp.1_3 = PHI <1(4), 0(5), 0(3)> > > if (iftmp.1_3 != 0) > > goto ; > > else > > goto ; > > ... > > : > > # _4 = PHI > > return _4; > > > > which does. The issue seems to be that the analysis doesn't consider > > the PHI uses in > > > > if (iftmp.1_3 != 0) > > goto ; > > else > > goto ; > > > > : > > # out_2 = PHI > > > > guarded by anything (the out_1 use is guarded by iftmp.1_3 == 0). > > > > David - the code does > > > > if (gimple_code (use_stmt) == GIMPLE_PHI) > > use_bb = gimple_phi_arg_edge (use_stmt, > > PHI_ARG_INDEX_FROM_USE (use_p))->src; > > else > > use_bb = gimple_bb (use_stmt); > > > > if (is_use_properly_guarded (use_stmt, > > use_bb, > > ... > > > > so it chooses the source block (as approximation?). > > > > Splitting all edges results in us no longer warning here and: > > > > Use in stmt out_2 = PHI > > is guarded by : > > (.NOT.) if (iftmp.1_3 != 0) > > > > Can you see to fix that please? Thanks. > > > Your analysis is correct -- the use is indeed guarded. I forgot why I chose > to use the phi arg's source BB. Will take a look. > > David