This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

[Xtensa] speed up assembler for large inputs


I've committed this patch from Sterling Augustine to fix a performance problem for large input files. The code was O(N^2). The patch simply records the position of a frag to avoid searching repeatedly for the right position. I verified that it causes no testsuite regressions for an xtensa-elf target.

2007-06-19 Sterling Augustine <sterling@tensilica.com>

	* config/tc-xtensa.h (struct xtensa_frag_type): Update comment about
	use of literal_frag field.
	* config/tc-xtensa.c (xtensa_mark_literal_pool_location): Record frag
	in the literal_frag field.
	(xtensa_move_literals): Use it here instead of searching.  Update
	literal_frag field with new value.

Index: config/tc-xtensa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.h,v
retrieving revision 1.23
diff -u -p -r1.23 tc-xtensa.h
--- config/tc-xtensa.h	11 Jun 2007 16:53:08 -0000	1.23
+++ config/tc-xtensa.h	19 Jun 2007 18:47:11 -0000
@@ -228,7 +228,9 @@ struct xtensa_frag_type
      variable points to the frag where the literal will be stored.  For
      literal frags, this variable points to the nearest literal pool
      location frag.  This literal frag will be moved to after this
-     location.  */
+     location.  For RELAX_LITERAL_POOL_BEGIN frags, this field points
+     to the frag immediately before the corresponding RELAX_LITERAL_POOL_END
+     frag, to make moving frags for this literal pool efficient.  */
   fragS *literal_frag;
 
   /* The destination segment for literal frags.  (Note that this is only
Index: config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.82
diff -u -p -r1.82 tc-xtensa.c
--- config/tc-xtensa.c	11 Jun 2007 16:53:08 -0000	1.82
+++ config/tc-xtensa.c	19 Jun 2007 18:47:13 -0000
@@ -4548,6 +4548,7 @@ xtensa_mark_literal_pool_location (void)
      fixes into this frchain's fix list.  */
   pool_location = frag_now;
   frag_now->tc_frag_data.lit_frchain = frchain_now;
+  frag_now->tc_frag_data.literal_frag = frag_now;
   frag_variant (rs_machine_dependent, 0, 0,
 		RELAX_LITERAL_POOL_BEGIN, NULL, 0, NULL);
   xtensa_set_frag_assembly_state (frag_now);
@@ -9817,17 +9818,14 @@ xtensa_move_literals (void)
 	      frchain_to = literal_pool->tc_frag_data.lit_frchain;
 	      assert (frchain_to);
 	    }
-	  insert_after = literal_pool;
-
-	  while (insert_after->fr_next->fr_subtype != RELAX_LITERAL_POOL_END)
-	    insert_after = insert_after->fr_next;
-
+	  insert_after = literal_pool->tc_frag_data.literal_frag;
 	  dest_seg = insert_after->fr_next->tc_frag_data.lit_seg;
 
 	  *frag_splice = next_frag;
 	  search_frag->fr_next = insert_after->fr_next;
 	  insert_after->fr_next = search_frag;
 	  search_frag->tc_frag_data.lit_seg = dest_seg;
+	  literal_pool->tc_frag_data.literal_frag = search_frag;
 
 	  /* Now move any fixups associated with this frag to the
 	     right section.  */

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