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]

[patch] fix df_bb_regno_last_{def,use}_find


Hi,

This patch fixes the functions mentioned in the subject, which would
return bogus results in many cases.  These functions are not used on
mainline AFAICT, but we use them a lot in the new forward propagation
pass for RTL.  Does anyone mind if I apply this to mainline?

Gr.
Steven

        * df.c (df_local_def_available_p): Handle SUBREG refs.
	(df_bb_regno_last_use_find): Fix to make it return
	what it is supposed to.
	(df_bb_regno_last_def_find): Likewise.

Index: df.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/df.c,v
retrieving revision 1.87
diff -c -3 -p -r1.87 df.c
*** df.c	28 Jul 2005 01:47:06 -0000	1.87
--- df.c	7 Oct 2005 16:13:12 -0000
*************** df_local_def_available_p (struct df *df,
*** 3262,3268 ****
    struct df_link *link;
    int def_luid = DF_INSN_LUID (df, DF_REF_INSN (def));
    int in_bb = 0;
!   unsigned int regno = REGNO (def->reg);
    basic_block bb;
  
    /* The regs must be local to BB.  */
--- 3262,3268 ----
    struct df_link *link;
    int def_luid = DF_INSN_LUID (df, DF_REF_INSN (def));
    int in_bb = 0;
!   unsigned int regno = DF_REF_REGNO (def);
    basic_block bb;
  
    /* The regs must be local to BB.  */
*************** struct ref *
*** 3300,3305 ****
--- 3300,3307 ----
  df_bb_regno_last_use_find (struct df *df, basic_block bb, unsigned int regno)
  {
    struct df_link *link;
+   struct ref *last_use = NULL;
+   bool in_bb = false;
  
    /* This assumes that the reg-use list is ordered such that for any
       BB, the last use is found first.  However, since the BBs are not
*************** df_bb_regno_last_use_find (struct df *df
*** 3309,3318 ****
      {
        struct ref *use = link->ref;
  
        if (DF_REF_BB (use) == bb)
! 	return use;
      }
!   return 0;
  }
  
  
--- 3311,3327 ----
      {
        struct ref *use = link->ref;
  
+       /* The first use in the desired block.  */
        if (DF_REF_BB (use) == bb)
! 	{
! 	  in_bb = true;
! 	  last_use = use;
! 	}
!       /* We are past the last use in the desired block.  */
!       else if (in_bb)
! 	break;
      }
!   return last_use;
  }
  
  
*************** df_bb_regno_last_def_find (struct df *df
*** 3351,3363 ****
    for (link = df->regs[regno].defs; link; link = link->next)
      {
        struct ref *def = link->ref;
!       /* The first time in the desired block.  */ 
        if (DF_REF_BB (def) == bb)
! 	  in_bb = 1;
!       /* The last def in the desired block.  */
        else if (in_bb)
!         return last_def;
!       last_def = def;
      }
    return last_def;
  }
--- 3360,3375 ----
    for (link = df->regs[regno].defs; link; link = link->next)
      {
        struct ref *def = link->ref;
! 
!       /* The first def in the desired block.  */
        if (DF_REF_BB (def) == bb)
! 	{
! 	  in_bb = true;
! 	  last_def = def;
! 	}
!       /* We are past the last def in the desired block.  */
        else if (in_bb)
! 	break;
      }
    return last_def;
  }


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