This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question on -Werror usage in Makefiles...


> This is not just a wierd corner case for -Wuninitialized where one
> might expect a false positive, look at the code:
> 
> 	DWtype
> 	__negvdi2 (DWtype a)
> 	{
> 	  DWtype w;
> 	
> 	  w  = -a;
> 	
> 	  if (a >= 0 ? w > 0 : w < 0)
> 	    abort ();
> 	
> 	  return w;
> 	}
> 
> It should be trivial for GCC to determine that `w' is always
> initialized.  This error looks very similar to gcc.dg/uninit-C.c and
> IMO indicates a bug more serious that a simple warning problem.

sh.md has a negdi expander so that the DImode value is manipulated as
two SImode subregs.  There is no clobber at the start of this operation,
so the lame-brained dataflow is lost:

(insn 10 9 11 0 ../../srcw/gcc/libgcc2.c:177 (set (reg:SI t)
        (const_int 0 [0x0])) 120 {clrt} (nil)
    (nil))

(insn 11 10 12 0 ../../srcw/gcc/libgcc2.c:177 (parallel [
            (set (subreg:SI (reg/v:DI 160 [ w ]) 4)
                (neg:SI (plus:SI (reg:SI t)
                        (subreg:SI (reg/v:DI 159 [ a ]) 4))))
            (set (reg:SI t)
                (ne:SI (ior:SI (reg:SI t)
                        (subreg:SI (reg/v:DI 159 [ a ]) 4))
                    (const_int 0 [0x0])))
        ]) 94 {negc} (insn_list 3 (insn_list 10 (nil)))
    (nil))

(insn 12 11 13 0 ../../srcw/gcc/libgcc2.c:177 (parallel [
            (set (subreg:SI (reg/v:DI 160 [ w ]) 0)
                (neg:SI (plus:SI (reg:SI t)
                        (subreg:SI (reg/v:DI 159 [ a ]) 0))))
            (set (reg:SI t)
                (ne:SI (ior:SI (reg:SI t)
                        (subreg:SI (reg/v:DI 159 [ a ]) 0))
                    (const_int 0 [0x0])))
        ]) 94 {negc} (insn_list 11 (insn_list 11 (nil)))
    (expr_list:REG_UNUSED (reg:SI t)
        (nil)))

AFAICR putting in clobbers generally pessimizes code, because
opportunities for cse and instruction combination are lost.

There is no correctness problem with the optimizers here.  But there
is a problem with -Wuninitialized -Werror.  This just doesn't happen
to be one of the corner cases where -Wuninitialized works on multi-word
values.

Now, if you implemented -Wuninitialized at the tree level, you could make
it work for a somewhat larger class of programs, and with less
target-dependent variance.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]