[PATCH] CodeGen: improve ms instrincics support

Reid Kleckner rnk at google.com
Wed Jun 18 13:14:57 PDT 2014


================
Comment at: include/clang/Basic/Builtins.def:690
@@ -688,1 +689,3 @@
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
----------------
Saleem Abdulrasool wrote:
> Reid Kleckner wrote:
> > MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and do that anyway.
> 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.
No need.  I always thought it was silly that they didn't go back and add this intrinsic for x86.

================
Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+    Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+                                                Exchange,
----------------
Saleem Abdulrasool wrote:
> Reid Kleckner wrote:
> > MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) here.
> 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.
CreateAtomicCmpXchg should return an AtomicRMWInst* which can be made volatile.  It's not the result that's volatile, it's the memory update.

http://reviews.llvm.org/D4182






More information about the cfe-commits mailing list