* [PATCH 1/2] libstdc++: Use diagnose_as attribute to improve string diagnostics
2021-11-15 17:04 [PATCH 0/2] Make use of the diagnose_as attribute to improve libstdc++ diagnostics Matthias Kretz
@ 2021-11-15 17:05 ` Matthias Kretz
2021-11-15 17:05 ` [PATCH 2/2] libstdc++: Use diagnose_as attribute to improve simd diagnostics Matthias Kretz
1 sibling, 0 replies; 3+ messages in thread
From: Matthias Kretz @ 2021-11-15 17:05 UTC (permalink / raw)
To: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]
This hides the basic_string template in all diagnostics, reducing the
signal-to-noise ratio significantly. It also hides the std::__cxx11
namespace from users by presenting it as std.
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:
PR c++/89370
* include/bits/c++config: Diagnose std::__cxx11:: as std:: using
the diagnose_as attribute.
* include/bits/stringfwd.h: Add diagnose_as attribute to string,
wstring, u8string, u16string, and u32string.
* include/debug/string: Ditto.
* include/experimental/string: Ditto.
* include/std/string: Ditto.
---
libstdc++-v3/include/bits/c++config | 3 ++-
libstdc++-v3/include/bits/stringfwd.h | 10 +++++-----
libstdc++-v3/include/debug/string | 10 +++++-----
libstdc++-v3/include/experimental/string | 10 +++++-----
libstdc++-v3/include/std/string | 10 +++++-----
5 files changed, 22 insertions(+), 21 deletions(-)
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
stdₓ::simd
──────────────────────────────────────────────────────────────────────────
[-- Attachment #2: 0001-libstdc-Use-diagnose_as-attribute-to-improve-string-.patch --]
[-- Type: text/x-patch, Size: 4940 bytes --]
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index a6495809671..02d11afc1aa 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -318,7 +318,8 @@ namespace std
#if _GLIBCXX_USE_CXX11_ABI
namespace std
{
- inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
+ inline namespace __cxx11
+ __attribute__((__abi_tag__ ("cxx11"), __diagnose_as__("std"))) { }
}
namespace __gnu_cxx
{
diff --git a/libstdc++-v3/include/bits/stringfwd.h b/libstdc++-v3/include/bits/stringfwd.h
index bcfd350e505..3f653feae14 100644
--- a/libstdc++-v3/include/bits/stringfwd.h
+++ b/libstdc++-v3/include/bits/stringfwd.h
@@ -74,22 +74,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_GLIBCXX_END_NAMESPACE_CXX11
/// A string of @c char
- typedef basic_string<char> string;
+ typedef basic_string<char> string __attribute__((__diagnose_as__));
/// A string of @c wchar_t
- typedef basic_string<wchar_t> wstring;
+ typedef basic_string<wchar_t> wstring __attribute__((__diagnose_as__));
#ifdef _GLIBCXX_USE_CHAR8_T
/// A string of @c char8_t
- typedef basic_string<char8_t> u8string;
+ typedef basic_string<char8_t> u8string __attribute__((__diagnose_as__));
#endif
#if __cplusplus >= 201103L
/// A string of @c char16_t
- typedef basic_string<char16_t> u16string;
+ typedef basic_string<char16_t> u16string __attribute__((__diagnose_as__));
/// A string of @c char32_t
- typedef basic_string<char32_t> u32string;
+ typedef basic_string<char32_t> u32string __attribute__((__diagnose_as__));
#endif
/** @} */
diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string
index a8389528001..d6299e5552f 100644
--- a/libstdc++-v3/include/debug/string
+++ b/libstdc++-v3/include/debug/string
@@ -1296,21 +1296,21 @@ namespace __gnu_debug
return __res;
}
- typedef basic_string<char> string;
+ typedef basic_string<char> string __attribute__((__diagnose_as__));
- typedef basic_string<wchar_t> wstring;
+ typedef basic_string<wchar_t> wstring __attribute__((__diagnose_as__));
#ifdef _GLIBCXX_USE_CHAR8_T
/// A string of @c char8_t
- typedef basic_string<char8_t> u8string;
+ typedef basic_string<char8_t> u8string __attribute__((__diagnose_as__));
#endif
#if __cplusplus >= 201103L
/// A string of @c char16_t
- typedef basic_string<char16_t> u16string;
+ typedef basic_string<char16_t> u16string __attribute__((__diagnose_as__));
/// A string of @c char32_t
- typedef basic_string<char32_t> u32string;
+ typedef basic_string<char32_t> u32string __attribute__((__diagnose_as__));
#endif
template<typename _CharT, typename _Traits, typename _Allocator>
diff --git a/libstdc++-v3/include/experimental/string b/libstdc++-v3/include/experimental/string
index 4d92a7e39cc..91a9dd8b164 100644
--- a/libstdc++-v3/include/experimental/string
+++ b/libstdc++-v3/include/experimental/string
@@ -73,13 +73,13 @@ inline namespace fundamentals_v2
// basic_string typedef names using polymorphic allocator in namespace
// std::experimental::pmr
- typedef basic_string<char> string;
+ typedef basic_string<char> string __attribute__((__diagnose_as__));
#ifdef _GLIBCXX_USE_CHAR8_T
- typedef basic_string<char8_t> u8string;
+ typedef basic_string<char8_t> u8string __attribute__((__diagnose_as__));
#endif
- typedef basic_string<char16_t> u16string;
- typedef basic_string<char32_t> u32string;
- typedef basic_string<wchar_t> wstring;
+ typedef basic_string<char16_t> u16string __attribute__((__diagnose_as__));
+ typedef basic_string<char32_t> u32string __attribute__((__diagnose_as__));
+ typedef basic_string<wchar_t> wstring __attribute__((__diagnose_as__));
} // namespace pmr
#endif
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index af840e887d5..03a3c68050f 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -62,13 +62,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits = char_traits<_CharT>>
using basic_string = std::basic_string<_CharT, _Traits,
polymorphic_allocator<_CharT>>;
- using string = basic_string<char>;
+ using string [[__gnu__::__diagnose_as__]] = basic_string<char>;
#ifdef _GLIBCXX_USE_CHAR8_T
- using u8string = basic_string<char8_t>;
+ using u8string [[__gnu__::__diagnose_as__]] = basic_string<char8_t>;
#endif
- using u16string = basic_string<char16_t>;
- using u32string = basic_string<char32_t>;
- using wstring = basic_string<wchar_t>;
+ using u16string [[__gnu__::__diagnose_as__]] = basic_string<char16_t>;
+ using u32string [[__gnu__::__diagnose_as__]] = basic_string<char32_t>;
+ using wstring [[__gnu__::__diagnose_as__]] = basic_string<wchar_t>;
} // namespace pmr
template<typename _Str>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] libstdc++: Use diagnose_as attribute to improve simd diagnostics
2021-11-15 17:04 [PATCH 0/2] Make use of the diagnose_as attribute to improve libstdc++ diagnostics Matthias Kretz
2021-11-15 17:05 ` [PATCH 1/2] libstdc++: Use diagnose_as attribute to improve string diagnostics Matthias Kretz
@ 2021-11-15 17:05 ` Matthias Kretz
1 sibling, 0 replies; 3+ messages in thread
From: Matthias Kretz @ 2021-11-15 17:05 UTC (permalink / raw)
To: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:
* include/experimental/bits/simd.h: Diagnose
'std::experimental::parallelism_v2::simd_abi' as 'simd_abi'.
On x86, diagnose _VecBuiltin<16>, _VecBuiltin<32>, and
_VecBltnBtmsk<64> as 'simd_abi::[SSE]', 'simd_abi::[AVX]', and
'simd_abi::AVX512' respectively.
(simd_abi::_Scalar): Diagnose as 'simd_abi::scalar'.
(simd_abi::_Fixed): Diagnose as 'simd_abi::fixed_size<N>'.
(__odr_helper): Shorten implementation details (effectively
hiding them).
* include/experimental/bits/simd_detail.h: Diagnose
'std::experimental::parallelism_v2' as 'stdₓ'.
---
libstdc++-v3/include/experimental/bits/simd.h | 37 +++++--------------
.../include/experimental/bits/simd_detail.h | 2 +-
2 files changed, 11 insertions(+), 28 deletions(-)
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
stdₓ::simd
──────────────────────────────────────────────────────────────────────────
[-- Attachment #2: 0002-libstdc-Use-diagnose_as-attribute-to-improve-simd-di.patch --]
[-- Type: text/x-patch, Size: 3454 bytes --]
diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h
index 4fbad7d67b5..f581b46fbd8 100644
--- a/libstdc++-v3/include/experimental/bits/simd.h
+++ b/libstdc++-v3/include/experimental/bits/simd.h
@@ -83,13 +83,13 @@ using __m512d [[__gnu__::__vector_size__(64)]] = double;
using __m512i [[__gnu__::__vector_size__(64)]] = long long;
#endif
-namespace simd_abi {
+namespace simd_abi [[__gnu__::__diagnose_as__("simd_abi")]] {
// simd_abi forward declarations {{{
// implementation details:
-struct _Scalar;
+ struct [[__gnu__::__diagnose_as__("scalar")]] _Scalar;
template <int _Np>
- struct _Fixed;
+ struct [[__gnu__::__diagnose_as__("fixed_size")]] _Fixed;
// There are two major ABIs that appear on different architectures.
// Both have non-boolean values packed into an N Byte register
@@ -108,28 +108,11 @@ template <int _UsedBytes>
template <int _UsedBytes>
struct _VecBltnBtmsk;
-template <typename _Tp, int _Np>
- using _VecN = _VecBuiltin<sizeof(_Tp) * _Np>;
-
-template <int _UsedBytes = 16>
- using _Sse = _VecBuiltin<_UsedBytes>;
-
-template <int _UsedBytes = 32>
- using _Avx = _VecBuiltin<_UsedBytes>;
-
-template <int _UsedBytes = 64>
- using _Avx512 = _VecBltnBtmsk<_UsedBytes>;
-
-template <int _UsedBytes = 16>
- using _Neon = _VecBuiltin<_UsedBytes>;
-
-// implementation-defined:
-using __sse = _Sse<>;
-using __avx = _Avx<>;
-using __avx512 = _Avx512<>;
-using __neon = _Neon<>;
-using __neon128 = _Neon<16>;
-using __neon64 = _Neon<8>;
+#if defined __i386__ || defined __x86_64__
+using __sse [[__gnu__::__diagnose_as__("[SSE]")]] = _VecBuiltin<16>;
+using __avx [[__gnu__::__diagnose_as__("[AVX]")]] = _VecBuiltin<32>;
+using __avx512 [[__gnu__::__diagnose_as__("[AVX512]")]] = _VecBltnBtmsk<64>;
+#endif
// standard:
template <typename _Tp, size_t _Np, typename...>
@@ -367,7 +350,7 @@ namespace __detail
* users link TUs compiled with different flags. This is especially important
* for using simd in libraries.
*/
- using __odr_helper
+ using __odr_helper [[__gnu__::__diagnose_as__("[ODR helper]")]]
= conditional_t<__machine_flags() == 0, _OdrEnforcer,
_MachineFlagsTemplate<__machine_flags(), __floating_point_flags()>>;
@@ -692,7 +675,7 @@ template <typename _Abi>
__is_avx512_abi()
{
constexpr auto _Bytes = __abi_bytes_v<_Abi>;
- return _Bytes <= 64 && is_same_v<simd_abi::_Avx512<_Bytes>, _Abi>;
+ return _Bytes <= 64 && is_same_v<simd_abi::_VecBltnBtmsk<_Bytes>, _Abi>;
}
// }}}
diff --git a/libstdc++-v3/include/experimental/bits/simd_detail.h b/libstdc++-v3/include/experimental/bits/simd_detail.h
index 198c925c133..437f1ddb278 100644
--- a/libstdc++-v3/include/experimental/bits/simd_detail.h
+++ b/libstdc++-v3/include/experimental/bits/simd_detail.h
@@ -37,7 +37,7 @@
{ \
_GLIBCXX_BEGIN_NAMESPACE_VERSION \
namespace experimental { \
- inline namespace parallelism_v2 {
+ inline namespace parallelism_v2 [[__gnu__::__diagnose_as__("std\u2093")]] {
#define _GLIBCXX_SIMD_END_NAMESPACE \
} \
} \
^ permalink raw reply [flat|nested] 3+ messages in thread