Add support for _InterlockedCompareExchangePointer, _InterlockExchangePointer,
_InterlockExchange. These are available as a compiler intrinsic on ARM and x86.
These are used directly by the Windows SDK headers without use of the intrin
header.
Details
Diff Detail
Event Timeline
lib/Sema/SemaChecking.cpp | ||
---|---|---|
139 ↗ | (On Diff #10512) | I don't think these intrinsics need the special overload handling that the __sync intrinsics require. They should just need type checking that's already described by Builtins.def. |
145–147 ↗ | (On Diff #10512) | The AST should reflect the code the user wrote, and we shouldn't be doing this kind of rewrite. The overload resolution in the existing checking code is different, it's taking something that the user wrote and annotating it with all the implicit conversions that should occur. This should have it's own lowering in CGBuiltin.cpp. |
lib/Headers/Intrin.h | ||
---|---|---|
227 | I don't see why it was necessary to get rid of cdecl. Also, Now that the definition is gone it shouldn't be static inline__ anymore. |
lib/Headers/Intrin.h | ||
---|---|---|
227 | Getting rid of __cdecl is actually quite important since this header is not x86 specific. ARM does not honour __cdecl, and thus generates a warning. Good catch about the static __inline__. I've become too accustomed to the LLVM style and didnt notice that. |
lgtm with some nits
include/clang/Basic/Builtins.def | ||
---|---|---|
690 | MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and do that anyway. | |
lib/CodeGen/CGBuiltin.cpp | ||
1523 | I'd like this to be factored better, but I can live with it as is. | |
1535 | CGM.Int32Ty doesn't seem correct for x64, it should be IntType. | |
1537 | MSDN says "Comparand" with an 'a'. | |
1540 | MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) here. |
include/clang/Basic/Builtins.def | ||
---|---|---|
690 | Id be willing to do a follow up change to disable this at the sema level in 32-bit x86 only if you like. This is available in 32-bit ARM. | |
lib/CodeGen/CGBuiltin.cpp | ||
1535 | Good catch! | |
1537 | Done. | |
1540 | Dest itself is volatile, the returned value is not. We dont strip volatility off of Destination. Oh, and I dont see a llvm::Value::setVolatile either. |
include/clang/Basic/Builtins.def | ||
---|---|---|
690 | No need. I always thought it was silly that they didn't go back and add this intrinsic for x86. | |
lib/CodeGen/CGBuiltin.cpp | ||
1540 | CreateAtomicCmpXchg should return an AtomicRMWInst* which can be made volatile. It's not the result that's volatile, it's the memory update. |
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
1540 | Done (thanks for the clarification!); although needed an additional extract value due to a recent change to the cmpxchg change. |
MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and do that anyway.