[PATCH] CodeGen: improve ms instrincics support

Saleem Abdulrasool abdulras at fb.com
Wed Jun 18 12:54:04 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)
----------------
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.

================
Comment at: lib/CodeGen/CGBuiltin.cpp:1535
@@ +1534,3 @@
+    RTy = Exchange->getType();
+    Exchange = Builder.CreatePtrToInt(Exchange, CGM.Int32Ty);
+
----------------
Reid Kleckner wrote:
> CGM.Int32Ty doesn't seem correct for x64, it should be IntType.
Good catch!

================
Comment at: lib/CodeGen/CGBuiltin.cpp:1537
@@ +1536,3 @@
+
+    llvm::Value *Comparend =
+      Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), CGM.Int32Ty);
----------------
Reid Kleckner wrote:
> MSDN says "Comparand" with an 'a'.
Done.

================
Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+    Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+                                                Exchange,
----------------
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.

http://reviews.llvm.org/D4182






More information about the cfe-commits mailing list