On Tue, 21 Feb 2017, Jakub Jelinek wrote: > On Tue, Feb 21, 2017 at 02:53:32PM +0100, Richard Biener wrote: > > > > The following fixes a bit-load.c bug as well as avoids the warnings > > for two other cases. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > Ok? > > > > Thanks, > > Richard. > > > > 2017-02-21 Richard Biener <rguent...@suse.de> > > > > * bt-load.c (compute_defs_uses_and_gen): Clear call_saved. > > * fixed-value.c (fixed_from_string): Use wi::ulow and wi::uhigh. > > (fixed_convert_from_real): Likewise. > > * ipa-cp.c (ipcp_store_vr_results): Do not uselessly initialize > > VR_VARYING min/max. > > > > Index: gcc/bt-load.c > > =================================================================== > > --- gcc/bt-load.c (revision 245620) > > +++ gcc/bt-load.c (working copy) > > @@ -543,6 +543,7 @@ compute_defs_uses_and_gen (btr_heap_t *a > > int i; > > > > /* Check for sibcall. */ > > + CLEAR_HARD_REG_SET (call_saved); > > if (GET_CODE (pat) == PARALLEL) > > for (i = XVECLEN (pat, 0) - 1; i >= 0; i--) > > if (ANY_RETURN_P (XVECEXP (pat, 0, i))) > > Why do we warn here? > HARD_REG_SET *clobbered = &call_used_reg_set; > HARD_REG_SET call_saved; > rtx pat = PATTERN (insn); > int i; > > /* Check for sibcall. */ > if (GET_CODE (pat) == PARALLEL) > for (i = XVECLEN (pat, 0) - 1; i >= 0; i--) > if (ANY_RETURN_P (XVECEXP (pat, 0, i))) > { > COMPL_HARD_REG_SET (call_saved, > call_used_reg_set); > clobbered = &call_saved; > } > > for (regno = first_btr; regno <= last_btr; regno++) > if (TEST_HARD_REG_BIT (*clobbered, regno)) > note_btr_set (regno_reg_rtx[regno], NULL_RTX, > &info); > COMPL_HARD_REG_SET should always overwrite all of call_saved (it is > call_saved = ~call_used_reg_set).
Not sure why we warn, didn't fully investigate. > > --- gcc/fixed-value.c (revision 245620) > > +++ gcc/fixed-value.c (working copy) > > @@ -130,8 +130,8 @@ fixed_from_string (FIXED_VALUE_TYPE *f, > > real_arithmetic (&fixed_value, MULT_EXPR, &real_value, &base_value); > > wide_int w = real_to_integer (&fixed_value, &fail, > > GET_MODE_PRECISION (mode)); > > - f->data.low = w.elt (0); > > - f->data.high = w.elt (1); > > + f->data.low = w.ulow (); > > + f->data.high = w.uhigh (); > > Is this for the case when the wide_int has only a single uhwi (or more than > two)? This is for the case where elt (0) does template <typename storage> inline HOST_WIDE_INT generic_wide_int <storage>::elt (unsigned int i) const { if (i >= this->get_len ()) return sign_mask (); turning that into 0 == this->get_len () and sign_mask has inline HOST_WIDE_INT generic_wide_int <storage>::sign_mask () const { unsigned int len = this->get_len (); unsigned HOST_WIDE_INT high = this->get_val ()[len - 1]; so we propagate len == 0 here and access this out-of-bound (and nothing knows len is never zero). > > --- gcc/ipa-cp.c (revision 245620) > > +++ gcc/ipa-cp.c (working copy) > > @@ -4959,7 +4959,6 @@ ipcp_store_vr_results (void) > > { > > vr.known = false; > > vr.type = VR_VARYING; > > - vr.min = vr.max = wi::zero (INT_TYPE_SIZE); > > } > > ts->m_vr->quick_push (vr); > > } > > It is strange to see removing initialization of something as a work-around > to uninitialized warning. Is that because of the vr.min = vr.max assignment > and that wi::zero doesn't initialize everything? didn't fully track this down but it looks like the assignment from wi::hwi_with_prec somehow accesses uninitialized memory. I can only spend more time with this later this week (or next week). Changing the warning patch to add a %K helps (you get at least an idea of the inline stack): + /* We didn't find any may-defs so on all paths either + reached function entry or a killing clobber. */ if (always_executed) - warn_uninit (OPT_Wuninitialized, use, gimple_assign_rhs1 (stmt), - base, "%qE is used uninitialized in this function", - stmt, UNKNOWN_LOCATION); + warning_at (gimple_location (stmt), OPT_Wuninitialized, + "%K%qE is used uninitialized in this function", + rhs, rhs); else if (warn_possibly_uninitialized) - warn_uninit (OPT_Wmaybe_uninitialized, use, - gimple_assign_rhs1 (stmt), base, - "%qE may be used uninitialized in this function", - stmt, UNKNOWN_LOCATION); + warning_at (gimple_location (stmt), OPT_Wmaybe_uninitialized, + "%K%qE may be used uninitialized in this function", + rhs, rhs); Richard.