i386 string patterns vs global registers

Fergus Henderson fjh@cs.mu.OZ.AU
Wed Feb 12 09:17:00 GMT 2003


In gcc-patches, Richard Henderson <rth@redhat.com> wrote:
> One of Brad Lucier's gambit test cases appropriates esi and edi
> as global registers.  While we certainly can't do something
> similar for, well, any other x86 register, it does seem 
> reasonable to take this as a hint that we should just call
> memcpy out of line.

Thanks!

This has been a problem for the Mercury compiler for a long time.
I reported it years ago, but the response was essentially that global
register variables should not be used, because there was no way to
predict when the use of global register variables might cause GCC
to abort.

Does this mean that global register variables are now supported again?
(When I say "supported", I mean in the sense of being an official part of
the GNU C language; I don't mean that I expect free support from anyone.)
That is, if on x86 I use esi and edi as global register variables,
and otherwise I stick to code which is strictly conforming ISO C, can
I reasonably expect that the code ought to work?  If someone introduces
a patch which breaks such code, and I ask for the patch to be reverted,
can I expect that the request will be honoured?

Also, if the answer for esi and edi is yes, what about ebx?
When compiling in non-PIC mode, the Mercury compiler also uses ebx.
Empirically, that has not resulted in any additional problems other
than the issues with memcpy(), memcmp(), bzero(), and structure assignment
which are fixed by your patch, or at least none that we know about.

AFAIK the above-mentioned issues were the only ones that caused problems
for us.  We worked around those problems by not using those features of
standard C.  We also wrote a new back-end for the Mercury compiler that
does not use global register variables, but for various reasons the old
back-end is still in use, and still has more features and produces better
code for some benchmarks.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.



More information about the Gcc mailing list