incorrect warning

Richard Henderson rth@cygnus.com
Thu Jul 16 15:50:00 GMT 1998


In article <r2af7rkbt2.fsf.cygnus.egcs.bugs@happy.cygnus.com>,
Ulrich Drepper <drepper@cygnus.com> wrote:
>Hi,
>
>this little piece of code (Intel specific, but you get the idea how to
>do it on other platforms) produces a warning which isn't correct and
>cannot be avoided:
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>$ cat u.c
>int
>main ()
>{
>  register int ebp asm ("ebp");
>  return ebp != 0;
>}
>$ gcc -Wall -O -o u u.c
>u.c: In function `main':
>u.c:4: warning: `ebp' might be used uninitialized in this function
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following patch may fix this.  I only tested it with $sp on alpha.
If this is not good enough for ebp, we can add checks for the other 
special registers gcc knows about.


r~


	* flow.c (regno_uninitialized): Don't warn on fixed regs.

Index: flow.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/flow.c,v
retrieving revision 1.55
diff -c -p -d -r1.55 flow.c
*** flow.c	1998/07/08 21:15:55	1.55
--- flow.c	1998/07/16 22:46:38
*************** libcall_dead_p (x, needed, note, insn)
*** 2030,2039 ****
    return 1;
  }
  
! /* Return 1 if register REGNO was used before it was set.
!    In other words, if it is live at function entry.
!    Don't count global register variables or variables in registers
!    that can be used for function arg passing, though.  */
  
  int
  regno_uninitialized (regno)
--- 2030,2039 ----
    return 1;
  }
  
! /* Return 1 if register REGNO was used before it was set, i.e. if it is
!    live at function entry.  Don't count global register variables, variables
!    in registers that can be used for function arg passing, or variables in
!    fixed hard registers.  */
  
  int
  regno_uninitialized (regno)
*************** regno_uninitialized (regno)
*** 2041,2047 ****
  {
    if (n_basic_blocks == 0
        || (regno < FIRST_PSEUDO_REGISTER
! 	  && (global_regs[regno] || FUNCTION_ARG_REGNO_P (regno))))
      return 0;
  
    return REGNO_REG_SET_P (basic_block_live_at_start[0], regno);
--- 2041,2049 ----
  {
    if (n_basic_blocks == 0
        || (regno < FIRST_PSEUDO_REGISTER
! 	  && (global_regs[regno]
! 	      || fixed_regs[regno]
! 	      || FUNCTION_ARG_REGNO_P (regno))))
      return 0;
  
    return REGNO_REG_SET_P (basic_block_live_at_start[0], regno);



More information about the Gcc-patches mailing list