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]: Emit cld instruction when stringops are used


On Fri, Mar 7, 2008 at 8:15 PM, Chris Lattner <clattner@apple.com> wrote:
> >>>> You forget that there is a ton of code in the world that does:
>  >>>>
>  >>>> void foo() {
>  >>>>  asm ( " rep; movsb", ...)
>  >>>> }
>  >>>>
>  >>>> Knowing that the direction flag is clear on entry to the function.
>  >>>> You propose auditing all the *existing* inline asm code active in
>  >>>> the
>  >>>> world?  I thought the issue here was that *user* space can't trust
>  >>>> that the direction flag is clear because of the kernel bug: if so,
>  >>>> this isn't just about inline asm in the kernel.
>  >>>
>  >>> Such code was broken in the past anyway, no need to try to fix that
>  >>> now.
>  >>
>  >> How so?
>  >
>  > Because it relies on the direction flag clear which is neither
>  > guaranteed
>  > by the ABI, nor was ensured by GCC in previous releases.
>
>  You seem confused.  The i386 psABI explicitly states:
>
>  "EFLAGS:
>
>  The flags register contains the system ïags, such as the direction
>  flag and the carry flag. The direction flag must be set to the
>  ''forward'' (that is, zero) direction before entry and upon exit
>  from a function. Other user flags have no specified role in the
>  standard calling sequence and are not preserved. "
>
>  That is pretty unambiguous.  GCC always preserves this property as
>  well, in absence of the kernel bug.

Nothin prevents GCC from doing

 std;
 backward string op;
 asm("...");
 another backward string op;
 cld;

Richard.

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