]> granicus.if.org Git - clang/commitdiff
builtins: relax __iso_volatile_{load,store}32
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sat, 22 Jun 2019 18:55:51 +0000 (18:55 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sat, 22 Jun 2019 18:55:51 +0000 (18:55 +0000)
This is reduced from MSVC's MSVCPRT 14.21.27702 atomic header.  Because
Windows is a LLP64 environment, `long`, `long int`, and `int` are all
synonymous.  Change the signature for `__iso_volatile_load32` and
`__iso_volatile_store32` to accept a `long int` instead.  This allows
an implicit cast of `int` to `long int` while also permitting `long`
to be accepted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364137 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Builtins.def
test/CodeGenCXX/ms-intrinsics.cpp [new file with mode: 0644]

index a9ca9abf50cc19cd4a772c78bdf9a91caac56433..ce79d4ac963b4819f9f468a4d246362ccd7ba502 100644 (file)
@@ -827,11 +827,11 @@ LANGBUILTIN(_interlockedbittestandset_nf,    "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_interlockedbittestandset_rel,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__iso_volatile_load8,   "ccCD*",     "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__iso_volatile_load16,  "ssCD*",     "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(__iso_volatile_load32,  "iiCD*",     "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "LiLiCD*",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__iso_volatile_store8,  "vcD*c",     "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__iso_volatile_store16, "vsD*s",     "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(__iso_volatile_store32, "viD*i",     "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store32, "vLiD*Li",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__noop,           "i.",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__lzcnt16, "UsUs",    "nc", ALL_MS_LANGUAGES)
diff --git a/test/CodeGenCXX/ms-intrinsics.cpp b/test/CodeGenCXX/ms-intrinsics.cpp
new file mode 100644 (file)
index 0000000..7afa39a
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only %s -verify
+// expected-no-diagnostics
+
+struct S {
+  mutable long _Spinlock = 0;
+  void _Unlock() {
+    __iso_volatile_store32(&_Spinlock, 0);
+  }
+  int _Reset() {
+    long v = __iso_volatile_load32(&_Spinlock);
+    __iso_volatile_store32(&_Spinlock, 0);
+    return v;
+  }
+};
+
+S s;
+