LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File fix-var-tracking.diff of Package gcc33 (Project openSUSE:Factory)

Subject: [development-gcc] Fix bug in var-tracking WRT location list for
    DW_AT_frame_base

Hello,

I'd like this patch
(http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01730.html)
to be added to SLES9 compiler.

Bootstrapped/regtested mainline ia64 and x86-64, bootstrapping hammer branch
 in progress.

Josef

2004-06-22  Josef Zlomek  <zlomekj@suse.cz>

        * var-tracking.c: Fix some comments.
        (frame_stack_adjust): New.
        (vt_stack_adjustments): Init stack_adjust of entry block to
        minus stack adjustment of function prologue.
        (vt_add_function_parameters): Do not adjust locations of
        function arguments.
        (vt_initialize): Compute the stack adjustment of function
        prologue and offset the initial "location" of frame_base_decl
        from the stack pointer after prologue.

Index: gcc/var-tracking.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/var-tracking.c,v
retrieving revision 1.1.6.23
diff -c -p -r1.1.6.23 var-tracking.c
*** gcc/var-tracking.c	28 Apr 2004 06:00:46 -0000	1.1.6.23
--- gcc/var-tracking.c	22 Jun 2004 08:00:36 -0000
*************** static bool emit_notes;
*** 265,270 ****
--- 265,273 ----
  /* Fake variable for stack pointer.  */
  GTY(()) tree frame_base_decl;
  
+ /* Stack adjust caused by function prologue.  */
+ HOST_WIDE_INT frame_stack_adjust;
+ 
  /* Local function prototypes.  */
  static void stack_adjust_offset_pre_post	PARAMS ((rtx, HOST_WIDE_INT *,
  							 HOST_WIDE_INT *));
*************** bb_stack_adjust_offset (bb)
*** 494,500 ****
    VTI (bb)->out.stack_adjust = offset;
  }
  
! /* Compute stack adjustment caused by function prolog.  */
  
  static HOST_WIDE_INT
  prologue_stack_adjust ()
--- 497,503 ----
    VTI (bb)->out.stack_adjust = offset;
  }
  
! /* Compute stack adjustment caused by function prologue.  */
  
  static HOST_WIDE_INT
  prologue_stack_adjust ()
*************** vt_stack_adjustments ()
*** 538,544 ****
  
    /* Initialize entry block.  */
    VTI (ENTRY_BLOCK_PTR)->visited = true;
!   VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = 0;
  
    /* Allocate stack for back-tracking up CFG.  */
    stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
--- 541,547 ----
  
    /* Initialize entry block.  */
    VTI (ENTRY_BLOCK_PTR)->visited = true;
!   VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = frame_stack_adjust;
  
    /* Allocate stack for back-tracking up CFG.  */
    stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
*************** variable_was_changed (var, htab)
*** 1985,1993 ****
  }
  
  /* Set the location of frame_base_decl to LOC in dataflow set SET.  This
!    function expects that
!    frame_base_decl has already one location for offset 0 in the variable table.
!  */
  
  static void
  set_frame_base_location (set, loc)
--- 1988,1995 ----
  }
  
  /* Set the location of frame_base_decl to LOC in dataflow set SET.  This
!    function expects that frame_base_decl has already one location for offset 0
!    in the variable table.  */
  
  static void
  set_frame_base_location (set, loc)
*************** static void
*** 2580,2590 ****
  vt_add_function_parameters ()
  {
    tree parm;
-   HOST_WIDE_INT stack_adjust = 0;
    
-   if (!frame_pointer_needed)
-     stack_adjust = prologue_stack_adjust ();
- 
    for (parm = DECL_ARGUMENTS (current_function_decl);
         parm; parm = TREE_CHAIN (parm))
      {
--- 2582,2588 ----
*************** vt_add_function_parameters ()
*** 2619,2626 ****
  #endif
  
        incoming = eliminate_regs (incoming, 0, NULL_RTX);
-       if (!frame_pointer_needed && GET_CODE (incoming) == MEM)
- 	incoming = adjust_stack_reference (incoming, -stack_adjust);
        out = &VTI (ENTRY_BLOCK_PTR)->out;
  
        if (GET_CODE (incoming) == REG)
--- 2617,2622 ----
*************** vt_initialize ()
*** 2786,2791 ****
--- 2782,2789 ----
      {
        rtx base;
  
+       frame_stack_adjust = -prologue_stack_adjust ();
+ 
        /* Create fake variable for tracking stack pointer changes.  */
        frame_base_decl = make_node (VAR_DECL);
        DECL_NAME (frame_base_decl) = get_identifier ("___frame_base_decl");
*************** vt_initialize ()
*** 2793,2799 ****
        DECL_ARTIFICIAL (frame_base_decl) = 1;
  
        /* Set its initial "location".  */
!       base = gen_rtx_MEM (Pmode, stack_pointer_rtx);
        set_variable_part (&VTI (ENTRY_BLOCK_PTR)->out, base, frame_base_decl, 0);
      }
    else
--- 2791,2799 ----
        DECL_ARTIFICIAL (frame_base_decl) = 1;
  
        /* Set its initial "location".  */
!       base = gen_rtx_MEM (Pmode,
! 			  gen_rtx_PLUS (Pmode, stack_pointer_rtx,
! 					GEN_INT (frame_stack_adjust)));
        set_variable_part (&VTI (ENTRY_BLOCK_PTR)->out, base, frame_base_decl, 0);
      }
    else