[clang] f9457f1 - [clang] Don't mark _ReadBarrier, _ReadWriteBarrier, _WriteBarrier deprecated

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 07:50:18 PDT 2021


Author: Nico Weber
Date: 2021-10-06T10:50:02-04:00
New Revision: f9457f1f88b3e835fca8942b5272f3ecf26d4e98

URL: https://github.com/llvm/llvm-project/commit/f9457f1f88b3e835fca8942b5272f3ecf26d4e98
DIFF: https://github.com/llvm/llvm-project/commit/f9457f1f88b3e835fca8942b5272f3ecf26d4e98.diff

LOG: [clang] Don't mark _ReadBarrier, _ReadWriteBarrier, _WriteBarrier deprecated

It's true that docs.microsoft.com says:

"""The _ReadBarrier, _WriteBarrier, and _ReadWriteBarrier compiler
intrinsics and the MemoryBarrier macro are all deprecated and should not
be used. For inter-thread communication, use mechanisms such as
atomic_thread_fence and std::atomic<T>, which are defined in the C++
Standard Library. For hardware access, use the /volatile:iso compiler
option together with the volatile keyword."""

And these attributes have been here since these builtins were added in
r192860.

However:

- cl.exe does not warn on them even with /Wall
- none of the replacements are useful for C code
- we don't add __attribute__((__deprecated__())) to any other
  declarations in intrin.h
- intrin0.h in the MSVC headers declares _ReadWriteBarrier() (but
  without the deprecation attribute), so you get inconsistent
  deprecation warnings depending on if you include intrin.h or intrin0.h

The motivation is that compiling sqlite.h with clang-cl produces a
deprecation warning with clang-cl for _ReadWriteBarrier(), but not with
cl.exe.

Differential Revision: https://reviews.llvm.org/D111232

Added: 
    

Modified: 
    clang/lib/Headers/intrin.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 4803277472ee..3fd6d4dc6d15 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -150,10 +150,8 @@ long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __attribute__((__deprecated__(
-    "use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void);
-void __attribute__((__deprecated__(
-    "use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void);
+void _ReadBarrier(void);
+void _ReadWriteBarrier(void);
 unsigned int _rorx_u32(unsigned int, const unsigned int);
 int _sarx_i32(int, unsigned int);
 #if __STDC_HOSTED__
@@ -164,8 +162,7 @@ unsigned int _shrx_u32(unsigned int, unsigned int);
 void _Store_HLERelease(long volatile *, long);
 void _Store64_HLERelease(__int64 volatile *, __int64);
 void _StorePointer_HLERelease(void *volatile *, void *);
-void __attribute__((__deprecated__(
-    "use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void);
+void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
 


        


More information about the cfe-commits mailing list