Why does gas put a stop bit in a bundle?

Jim Wilson wilson@tuliptree.org
Thu May 1 20:39:00 GMT 2003


On Thu, 2003-05-01 at 12:05, H. J. Lu wrote:
> Intel ia64 assembler doesn't add a stop bit. I consider it unfortunate
> for gas. Can you create a testcase which shows dependency violation
> doesn't with section switch? I'd like to add it to gas and I will take
> a look at it when I find time.

First you have to patch gas to turn off this feature.

Index: tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.82
diff -p -r1.82 tc-ia64.c
*** tc-ia64.c	21 Mar 2003 14:02:09 -0000	1.82
--- tc-ia64.c	1 May 2003 20:10:46 -0000
*************** ia64_flush_pending_output ()
*** 7064,7072 ****
--- 7064,7074 ----
    if (!md.keep_pending_output
        && bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE)
      {
+ #if 0
        /* ??? This causes many unnecessary stop bits to be emitted.
  	 Unfortunately, it isn't clear if it is safe to remove this.  */
        insn_group_break (1, 0, 0);
+ #endif
        ia64_flush_insns ();
      }
  }

Here are two short examples.  Assemble the first one with as -x and you get
no DV warning even though the 1st and 3rd instructions conflict.  Assemble
the second one with as -x and you get a warning for a conflict between the
second and third one even though they are in different sections.

First example:
	.text
	add r3 = r2, r1
	.section .text2, "ax", @progbits
	add r6 = r4, r5
	;; 
	.text
	add r1 = r3, r2

Second example:
	.text
	add r3 = r2, r1
	;; 
	.section .text2, "ax", @progbits
	add r2 = r1, r3
	.text
	add r1 = r3, r2

Fixing this means all DV state needs to be associated with sections
instead of in a global variable, so that we can arbitrarily switch
between sections without losing state.

You mentioned that ias doesn't add a stop bit on section switches, but
how does it handle examples like this?  Does it get the right?  Or does
it give a warning/error?

The problem just isn't DV info.  The problem is all info that is synthesized
by the assembler.  This include DV info, but it also includes bundling info,
unwind info, and dwarf2 debug info.  All of the state for all of these things
would need to be section specific, otherwise we run into trouble.  The
complexity of doing this doesn't seem worth the benefit to me.

For the second example above, note that the two add instructions in text
go into two bundles, when they could have gone into one bundle.  This is
only a performance issue not a correctness issue, but it is a problem.
If people will get accidental hidden performance loss from section switching
then it is probably better to not let them do it, or at least warn them
about it.

I could also construct examples that show unwind info failures by
overlapping two function definitions.  This would be a correctness problem.
There is currently no solution for this.

Note that the xdata directives avoid a section switch, and this is
probably why it is there.

Another issue to consider is what happens when the linker merges text
sections together.  The linker isn't going to do DV checking.  This implies
that do need a stop bit at the end of each text section when we reach the
end of the input assembly file.

Jim




More information about the Binutils mailing list