[libcxx-commits] [clang] [clang-tools-extra] [libcxx] [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (PR #89446)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 26 05:25:27 PDT 2024


================
@@ -5571,3 +5571,19 @@ but the expression has no runtime effects.
 Type- and value-dependent expressions are not supported yet.
 
 This facility is designed to aid with testing name lookup machinery.
+
+Predefined Macros
+=================
+
+`__GCC_DESTRUCTIVE_SIZE` and `__GCC_CONSTRUCTIVE_SIZE`
+------------------------------------------------------
+Specify the mimum offset between two objects to avoid false sharing and the
+maximum size of contiguous memory to promote true sharing, respectively. These
+macros are predefined in all C and C++ language modes, but can be redefined on
+the command line with ``-D`` to specify different values as needed or can be
+undefined on the command line with ``-U`` to disable support for the feature.
+
+**Note: the values the macros expand to are not stable between releases of Clang
+and do not need to match the values produced by GCC, so these macros should not
+be used from header files because they may not be stable across multiple TUs
+(the values may vary based on compiler version as well as CPU tuning).**
----------------
cor3ntin wrote:

```suggestion
**Note: the values the macros expand to are not guaranteed to be stable. They are are affected by architectures and CPU tuning flags, can change between releases of Clang and will not match the values
defined by other compilers such as GCC.
Compiling different TUs depending on these flags (or `std::hardware_constructive_interference` ,  `std::hardware_destructive_interference`)  with different compilers, defines or architecture flags will lead to ODR violations bugs and should be avoided.
```

https://github.com/llvm/llvm-project/pull/89446


More information about the libcxx-commits mailing list