On Sun, 31 Jul 2022, Iain Sandoe wrote:

> Hi Richi,
> 
> > On 29 Jul 2022, at 09:54, Richard Biener via Gcc-patches 
> > <gcc-patches@gcc.gnu.org> wrote:
> > 
> > The following makes the backward threader reject threads whose entry
> > edge is probably never executed according to the profile.  That in
> > particular, for the testcase, avoids threading the irq == 1 check
> > on the path where irq > 31, thereby avoiding spurious -Warray-bounds
> > diagnostics
> 
> This breaks bootstrap on i686-darwin{9,17} with what looks like a valid  
> warning (werrors on stage2)
> 
> cc1plus  … -O2 -Wall … is enough to.
> 
> I can repeat it on a cross from x86_64-darwin19, so I can probably reduce the 
> .ii (it’s like 2M5 raw) and file a PR if you like - depends if the solution 
> might be obvious to you …

Can you open a bugreport and attach full preprocessed source at start?

Note at the start of the function we have

  if (m_path.length () <= 1)
      return false;

so

      edge entry = find_edge (m_path[m_path.length () - 1],
                              m_path[m_path.length () - 2]);

is known to not access m_path out-of-bounds ...

Thanks,
Richard.

> 
> thanks
> Iain
> 
> --------
> 
> In file included from /src-local/gcc-master/gcc/hash-table.h:248,
>                  from /src-local/gcc-master/gcc/coretypes.h:486,
>                  from /src-local/gcc-master/gcc/tree-ssa-threadbackward.cc:22:
> In member function ‘T& vec<T, A, vl_embed>::operator[](unsigned int) [with T 
> = basic_block_def*; A = va_heap]’,
>     inlined from ‘const T& vec<T>::operator[](unsigned int) const [with T = 
> basic_block_def*]’ at /src-local/gcc-master/gcc/vec.h:1486:20,
>     inlined from ‘bool back_threader_profitability::profitable_path_p(const 
> vec<basic_block_def*>&, tree, edge, bool*)’ at 
> /src-local/gcc-master/gcc/tree-ssa-threadbackward.cc:781:37:
> /src-local/gcc-master/gcc/vec.h:890:19: warning: array subscript 4294967294 
> is above array bounds of ‘basic_block_def* [1]’ [-Warray-bounds]
>   890 |   return m_vecdata[ix];
>       |          ~~~~~~~~~^
> /src-local/gcc-master/gcc/vec.h: In member function ‘bool 
> back_threader_profitability::profitable_path_p(const vec<basic_block_def*>&, 
> tree, edge, bool*)’:
> /src-local/gcc-master/gcc/vec.h:635:5: note: while referencing 
> ‘vec<basic_block_def*, va_heap, vl_embed>::m_vecdata’
>   635 |   T m_vecdata[1];
>       |     ^~~~~~~~~
> 
> =====

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

Reply via email to