This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [PATCH, i386]: Insert "cld" via optimize mode switching



Hmm, do we or the ABI guarantee to save/restore the necessary state
on entry/exit of signal handlers?  So, is this optimization safe for
synchronous signals and/or exceptions?

If you have


  cld
  rep movsb

this is not an atomic pair anyway. If the ABI does not require that DF be cleared on exit from a subroutine, then there is no guarantee that a signal handler occurring between the cld and "rep movsb" doesn't set the direction flag.

In principle, Uros' patch may make the circumstance more likely, since for example something like

  for (;;)
    memcpy (b, a, 10000);  /* and a signal may occur here */

will be compiled with a single cld instruction. But the code is not safe to begin with.

I think it would have been good that the ABI mandated that the flag be cleared...

Paolo


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