[PATCH, i386]: Emit cld instruction when stringops are used

Chris Lattner clattner@apple.com
Thu Mar 6 17:29:00 GMT 2008


> 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.

-Chris



More information about the Gcc-patches mailing list