Details
-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
Operating System: ReactOS
Platform: x86 Hardware
Description
Look at InterlockedBitTestAndSet and Co. from include/psdk/winnt.h:
_asm_ _volatile_("lock "
"btsl %2,%1\n\t"
"sbbl %0,%0\n\t"
:"=r" (OldBit),"=m" (*Base)
:"Ir" (Bit)
: "memory");
There should be "+m" instead of "=m", I believe.
Modifier "=" means that this operand is write-only for this instruction: the previous value is discarded and replaced by output data. GCC will assume that the value in this operand before the instruction is dead and need not be generated. "+" means that this operand is both read and written by the instruction.
For example:
ExInitializePushLock(Lock);
ExAcquirePushLockExclusive(Lock);
GCC may think that ExInitializePushLock() is not needed here and remove it, which is wrong.
P.S. See also intrin_x86.h