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]

[cfg patch] Set locators properly


Hi,
this patch corrects the ordering of updating the current location and then
storing it in an insn.  In particular this will set the epilogue_loc
correctly.

Currently the epilogue_loc gets the location of the last real insn
(which might have come from an inlined function, for instance), rather
than the location of the closing }.  This happens because the
final insn is a line number note specifying that }'s loc, but you'll
notice that we set epilogue_loc *before* updating from the note.

A similar issue could happen with block_change, so I've moved that too.

I'm not sure why we don't update the location for ADDR_VEC and
ADDR_DIFF_VEC insns, but do set their locations, this seems inconsistent
and I've changed that to make it consistent -- if this is incorrect
could some one explain so I can add a comment there.

built & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-07-30  Nathan Sidwell  <nathan@codesourcery.com>

	* cfglayout.c (insn_locators_initialize): Update the current
	location before initializing a location.

Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.67
diff -c -3 -p -r1.67 cfglayout.c
*** cfglayout.c	26 Jul 2004 14:34:15 -0000	1.67
--- cfglayout.c	30 Jul 2004 07:44:21 -0000
*************** insn_locators_initialize (void)
*** 267,278 ****
  
    for (insn = get_insns (); insn; insn = next)
      {
        next = NEXT_INSN (insn);
  
!       if ((active_insn_p (insn)
! 	   && GET_CODE (PATTERN (insn)) != ADDR_VEC
! 	   && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
! 	  || !NEXT_INSN (insn)
  	  || (!prologue_locator && file_name))
  	{
  	  if (last_block != block)
--- 267,304 ----
  
    for (insn = get_insns (); insn; insn = next)
      {
+       int active = 0;
+       
        next = NEXT_INSN (insn);
  
!       if (NOTE_P (insn))
! 	{
! 	  switch (NOTE_LINE_NUMBER (insn))
! 	    {
! 	    case NOTE_INSN_BLOCK_BEG:
! 	    case NOTE_INSN_BLOCK_END:
! 	      abort ();
! 	      
! 	    default:
! 	      if (NOTE_LINE_NUMBER (insn) > 0)
! 		{
! 		  expanded_location xloc;
! 		  NOTE_EXPANDED_LOCATION (xloc, insn);
! 		  line_number = xloc.line;
! 		  file_name = xloc.file;
! 		}
! 	      break;
! 	    }
! 	}
!       else
! 	active = (active_insn_p (insn)
! 		  && GET_CODE (PATTERN (insn)) != ADDR_VEC
! 		  && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC);
!       
!       check_block_change (insn, &block);
! 
!       if (active
! 	  || !next
  	  || (!prologue_locator && file_name))
  	{
  	  if (last_block != block)
*************** insn_locators_initialize (void)
*** 296,329 ****
  	      VARRAY_PUSH_CHAR_PTR (file_locators_files, (char *) file_name);
  	      last_file_name = file_name;
  	    }
  	}
-       if (!prologue_locator && file_name)
- 	prologue_locator = loc;
-       if (!NEXT_INSN (insn))
- 	epilogue_locator = loc;
-       if (active_insn_p (insn))
-         INSN_LOCATOR (insn) = loc;
-       else if (NOTE_P (insn))
- 	{
- 	  switch (NOTE_LINE_NUMBER (insn))
- 	    {
- 	    case NOTE_INSN_BLOCK_BEG:
- 	    case NOTE_INSN_BLOCK_END:
- 	      abort ();
- 
- 	    default:
- 	      if (NOTE_LINE_NUMBER (insn) > 0)
- 		{
- 		  expanded_location xloc;
- 		  NOTE_EXPANDED_LOCATION (xloc, insn);
- 		  line_number = xloc.line;
- 		  file_name = xloc.file;
- 		}
- 	      break;
- 	    }
- 	}
- 
-       check_block_change (insn, &block);
      }
  
    /* Tag the blocks with a depth number so that change_scope can find
--- 322,334 ----
  	      VARRAY_PUSH_CHAR_PTR (file_locators_files, (char *) file_name);
  	      last_file_name = file_name;
  	    }
+ 	  if (!prologue_locator && file_name)
+ 	    prologue_locator = loc;
+ 	  if (!next)
+ 	    epilogue_locator = loc;
+ 	  if (active)
+ 	    INSN_LOCATOR (insn) = loc;
  	}
      }
  
    /* Tag the blocks with a depth number so that change_scope can find

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