Test case for __asm__ problems in i386

Jeffrey A Law law@cygnus.com
Sun May 17 17:56:00 GMT 1998


  In message < 199805172156.OAA04011@rtl.cygnus.com >you write:
  > Normally, order_regs_for_reload will prevent any register explicitly
  > used in the rtl from being used as a spill register.  However, on a
  > SMALL_REGISTER_CLASSES machine we don't do this, because we would run out
  > of registers.  For your example, which explicitly clobbers 6 x86 registers,
  > there would be zero registers left after removing the explicitly used ones.
Yup.   Though I must admit when I looked at the code it seemed
to me to be a legitimate bug.

THe testcase clobbers 6 regs, but only one reg per asm.  There's
no reason "i" couldn't live in the stack and get reloaded from
the stack slot for each asm.

  > Unfortunately, this does mean that rtl that explicitly uses registers is
  > unsafe, except in carefully controlled situations.
Yup.

  > This problem is very hard to fix, so it is unlikely to be fixed anytime soo n.
Agreed.  Though it is relatively easy to catch some of the cases
which come up often in the x86 linux kernel asms.

  > Meanwhile, if you must use an asm with an explicit clobber, don't use a
  > constraint that can match the clobbered register. 
Absolutely!  This was one of the common mistakes found in the
linux x86 kernel asms. 

  > If you follow this rule, the asms will be safe.
Nope.  And Bernd's example shows that (IMHO).  He's used clobbers,
but nowhere does he explicitly set up an overlap between a clobbered
reg and another reg in the asm.

It's possible to show similar behavior with modified versions of the
x86 linux asms which try to use too many regs and don't leave a
spill reg.  The compiler will end up selecting one of the clobbered
regs as a spill, which has unfortunate consequences.

jeff



More information about the Gcc-bugs mailing list