From: Saleem Abdulrasool Date: Sat, 22 Jun 2019 18:55:51 +0000 (+0000) Subject: builtins: relax __iso_volatile_{load,store}32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b006ef25d76f3f85efb5b7ab912d98d210dad31;p=clang builtins: relax __iso_volatile_{load,store}32 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 --- diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index a9ca9abf50..ce79d4ac96 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -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 index 0000000000..7afa39a97e --- /dev/null +++ b/test/CodeGenCXX/ms-intrinsics.cpp @@ -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; +