infinite loop in mips16 assembler relaxation

Alexandre Oliva aoliva@redhat.com
Mon Mar 18 10:55:00 GMT 2002


The attached assembly output of gcc.c-torture/execute/gofast.c,
compiled with the flags -mel -mabi=32 -mlong32 -mips16 -msoft-float
-O3 -fomit-frame-pointer causes the assembler, called with the flags
-EL -mips16 -O3 -32 -mabi=32, to enter an endless loop.  The problem
is that, after some initial relaxations, estimate_size_before_relax
and mips_relax_frag start undoing each other's effects, growing and
shrinking the same frags over and over.  Since mips_relax_frag
introduces changes in each round, the cycle is restarted, and never
ends.

I get the impression that there still is something wrong, as I don't
see why a frag would ever shrink, if we started with all frags with
the EXTENDED bit clear, and only extended those as they were found to
overflow.

However, this simple approach doesn't work, for some reason I can't
understand.  I've modified the code so as to verify that all frags
start out with the EXTENDED bit clear, and only grow if
mips16_extended_frag() says it's necessary.  Even in this case, I
still got one frag that had to be shrunk in the second round of
relaxation.  The difference, it seems, stems from the fact that the
stretch passed to mips16_extended_frag() was much larger in the first
round, and the code that adjusts the stretch according to subsequent
align directives doesn't seem to be doing an exact job.  It seems to
be good enough, though; in the worst case, we get a few additional
rounds of relaxation.  I *think* it wouldn't enter an endless loop
like the original code did, but I couldn't prove it to myself.  :-(

Here's the simplest patch I could come up with.  Eric Chistopher
approved the patch, so I'm checking it in.  Tested with a Red
Hat-internal MIPS port and with athlon-pc-linux-gnu-x-mips-elf (does
this really test mips16?)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mips16-gas-inf-loop.patch
Type: text/x-patch
Size: 1156 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20020318/b24529d7/attachment.bin>
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gofast.s
Type: text/x-asm
Size: 20251 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20020318/b24529d7/attachment-0001.bin>
-------------- next part --------------

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


More information about the Binutils mailing list