This is the mail archive of the gcc-bugs@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]

Re: BUG alloca used as argument to function.


>>>>> "grahams" == grahams  <grahams@rcp.co.uk> writes:

    grahams> alloca () should not be used as an argument to a
    grahams> function.

Right you are.  Since we're basically trying to remove alloca from the
GCC source base anyhow, this is the easy fix.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-03-05  Mark Mitchell  <mark@codesourcery.com>

	* basic-block.h (ALLOCA_REG_SET): Remove.
	(INITIALIZE_REG_SET): New macro.
	* flow.c (update_life_info): Use it.
	(calculate_global_regs_live): Likewise.
	(propagate_block): Likewise.
	* global.c (build_insn_chain): Likewise.
	* haifa-sched.c (schedule_region): Likewise.

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/basic-block.h,v
retrieving revision 1.54
diff -c -p -r1.54 basic-block.h
*** basic-block.h	2000/02/17 04:16:40	1.54
--- basic-block.h	2000/03/05 22:29:44
*************** do {									\
*** 98,105 ****
  /* Allocate a register set with oballoc.  */
  #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
  
! /* Allocate a register set with alloca.  */
! #define ALLOCA_REG_SET() BITMAP_ALLOCA ()
  
  /* Do any cleanup needed on a regset when it is no longer used.  */
  #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET)
--- 98,105 ----
  /* Allocate a register set with oballoc.  */
  #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
  
! /* Initialize a register set.  Returns the new register set.  */
! #define INITIALIZE_REG_SET(HEAD) bitmap_initialize (&HEAD)
  
  /* Do any cleanup needed on a regset when it is no longer used.  */
  #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET)
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.227
diff -c -p -r1.227 flow.c
*** flow.c	2000/02/26 06:23:30	1.227
--- flow.c	2000/03/05 22:29:49
*************** update_life_info (blocks, extent, prop_f
*** 2643,2651 ****
       int prop_flags;
  {
    regset tmp;
    int i;
  
!   tmp = ALLOCA_REG_SET ();
  
    /* For a global update, we go through the relaxation process again.  */
    if (extent != UPDATE_LIFE_LOCAL)
--- 2643,2652 ----
       int prop_flags;
  {
    regset tmp;
+   regset_head tmp_head;
    int i;
  
!   tmp = INITIALIZE_REG_SET (tmp_head);
  
    /* For a global update, we go through the relaxation process again.  */
    if (extent != UPDATE_LIFE_LOCAL)
*************** calculate_global_regs_live (blocks_in, b
*** 2949,2958 ****
  {
    basic_block *queue, *qhead, *qtail, *qend;
    regset tmp, new_live_at_end;
    int i;
  
!   tmp = ALLOCA_REG_SET ();
!   new_live_at_end = ALLOCA_REG_SET ();
  
    /* Create a worklist.  Allocate an extra slot for ENTRY_BLOCK, and one
       because the `head == tail' style test for an empty queue doesn't 
--- 2950,2961 ----
  {
    basic_block *queue, *qhead, *qtail, *qend;
    regset tmp, new_live_at_end;
+   regset_head tmp_head;
+   regset_head new_live_at_end_head;
    int i;
  
!   tmp = INITIALIZE_REG_SET (tmp_head);
!   new_live_at_end = INITIALIZE_REG_SET (new_live_at_end_head);
  
    /* Create a worklist.  Allocate an extra slot for ENTRY_BLOCK, and one
       because the `head == tail' style test for an empty queue doesn't 
*************** propagate_block (bb, old, significant, f
*** 3177,3183 ****
--- 3180,3188 ----
    register rtx insn;
    rtx prev;
    regset live;
+   regset_head live_head;
    regset dead;
+   regset_head dead_head;
  
    /* Find the loop depth for this block.  Ignore loop level changes in the
       middle of the basic block -- for register allocation purposes, the 
*************** propagate_block (bb, old, significant, f
*** 3185,3192 ****
       not in the loop pre-header or post-trailer.  */
    loop_depth = bb->loop_depth;
  
!   dead = ALLOCA_REG_SET ();
!   live = ALLOCA_REG_SET ();
  
    cc0_live = 0;
  
--- 3190,3197 ----
       not in the loop pre-header or post-trailer.  */
    loop_depth = bb->loop_depth;
  
!   dead = INITIALIZE_REG_SET (live_head);
!   live = INITIALIZE_REG_SET (dead_head);
  
    cc0_live = 0;
  
Index: global.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/global.c,v
retrieving revision 1.56
diff -c -p -r1.56 global.c
*** global.c	2000/02/26 13:50:42	1.56
--- global.c	2000/03/05 22:29:51
*************** build_insn_chain (first)
*** 1764,1771 ****
    struct insn_chain **p = &reload_insn_chain;
    struct insn_chain *prev = 0;
    int b = 0;
  
!   live_relevant_regs = ALLOCA_REG_SET ();
  
    for (; first; first = NEXT_INSN (first))
      {
--- 1764,1772 ----
    struct insn_chain **p = &reload_insn_chain;
    struct insn_chain *prev = 0;
    int b = 0;
+   regset_head live_relevant_regs_head;
  
!   live_relevant_regs = INITIALIZE_REG_SET (live_relevant_regs_head);
  
    for (; first; first = NEXT_INSN (first))
      {
Index: haifa-sched.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/haifa-sched.c,v
retrieving revision 1.145
diff -c -p -r1.145 haifa-sched.c
*** haifa-sched.c	2000/02/26 13:50:42	1.145
--- haifa-sched.c	2000/03/05 22:29:55
*************** schedule_region (rgn)
*** 6631,6643 ****
    int bb;
    int rgn_n_insns = 0;
    int sched_rgn_n_insns = 0;
  
    /* Set variables for the current region.  */
    current_nr_blocks = RGN_NR_BLOCKS (rgn);
    current_blocks = RGN_BLOCKS (rgn);
  
!   reg_pending_sets = ALLOCA_REG_SET ();
!   reg_pending_clobbers = ALLOCA_REG_SET ();
    reg_pending_sets_all = 0;
  
    /* Initializations for region data dependence analyisis.  */
--- 6631,6645 ----
    int bb;
    int rgn_n_insns = 0;
    int sched_rgn_n_insns = 0;
+   regset_head reg_pending_sets_head;
+   regset_head reg_pending_clobbers_head;
  
    /* Set variables for the current region.  */
    current_nr_blocks = RGN_NR_BLOCKS (rgn);
    current_blocks = RGN_BLOCKS (rgn);
  
!   reg_pending_sets = INITIALIZE_REG_SET (reg_pending_sets_head);
!   reg_pending_clobbers = INITIALIZE_REG_SET (reg_pending_clobbers_head);
    reg_pending_sets_all = 0;
  
    /* Initializations for region data dependence analyisis.  */

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