This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, i386]: Emit cld instruction when stringops are used
On Fri, Mar 7, 2008 at 5:59 AM, Chris Lattner <clattner@apple.com> wrote:
>
>
> On Mar 6, 2008, at 12:56 PM, Richard Guenther wrote:
>
> > On Thu, Mar 6, 2008 at 6:29 PM, Chris Lattner <clattner@apple.com>
> > wrote:
> >>> No, gcc was never doing that, and there is no point to start doing
> >>> that.
> >>> If inline asm thinks it can't trust the psABI, it has to do cld on
> >>> its own.
> >>> And AFAIK inline asm that uses stos*/movs* etc. typically has cld at
> >>> the
> >>> beginning. If inline asm uses std, it must do cld before returning
> >>> back to
> >>> compiler generated code (again, from what I've seen asm that uses
> >>> std
> >>> has the corresponding cld too).
> >>
> >> 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.
Richard.