diff options
Diffstat (limited to 'llvm/include')
23 files changed, 148 insertions, 163 deletions
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 3eb3d6f..bccdb89 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -967,69 +967,11 @@ class APFloat : public APFloatBase { llvm_unreachable("Unexpected semantics"); } - ~Storage() { - if (usesLayout<IEEEFloat>(*semantics)) { - IEEE.~IEEEFloat(); - return; - } - if (usesLayout<DoubleAPFloat>(*semantics)) { - Double.~DoubleAPFloat(); - return; - } - llvm_unreachable("Unexpected semantics"); - } - - Storage(const Storage &RHS) { - if (usesLayout<IEEEFloat>(*RHS.semantics)) { - new (this) IEEEFloat(RHS.IEEE); - return; - } - if (usesLayout<DoubleAPFloat>(*RHS.semantics)) { - new (this) DoubleAPFloat(RHS.Double); - return; - } - llvm_unreachable("Unexpected semantics"); - } - - Storage(Storage &&RHS) { - if (usesLayout<IEEEFloat>(*RHS.semantics)) { - new (this) IEEEFloat(std::move(RHS.IEEE)); - return; - } - if (usesLayout<DoubleAPFloat>(*RHS.semantics)) { - new (this) DoubleAPFloat(std::move(RHS.Double)); - return; - } - llvm_unreachable("Unexpected semantics"); - } - - Storage &operator=(const Storage &RHS) { - if (usesLayout<IEEEFloat>(*semantics) && - usesLayout<IEEEFloat>(*RHS.semantics)) { - IEEE = RHS.IEEE; - } else if (usesLayout<DoubleAPFloat>(*semantics) && - usesLayout<DoubleAPFloat>(*RHS.semantics)) { - Double = RHS.Double; - } else if (this != &RHS) { - this->~Storage(); - new (this) Storage(RHS); - } - return *this; - } - - Storage &operator=(Storage &&RHS) { - if (usesLayout<IEEEFloat>(*semantics) && - usesLayout<IEEEFloat>(*RHS.semantics)) { - IEEE = std::move(RHS.IEEE); - } else if (usesLayout<DoubleAPFloat>(*semantics) && - usesLayout<DoubleAPFloat>(*RHS.semantics)) { - Double = std::move(RHS.Double); - } else if (this != &RHS) { - this->~Storage(); - new (this) Storage(std::move(RHS)); - } - return *this; - } + LLVM_ABI ~Storage(); + LLVM_ABI Storage(const Storage &RHS); + LLVM_ABI Storage(Storage &&RHS); + LLVM_ABI Storage &operator=(const Storage &RHS); + LLVM_ABI Storage &operator=(Storage &&RHS); } U; template <typename T> static bool usesLayout(const fltSemantics &Semantics) { diff --git a/llvm/include/llvm/ADT/Bitfields.h b/llvm/include/llvm/ADT/Bitfields.h index 1af2761..1fbc41c 100644 --- a/llvm/include/llvm/ADT/Bitfields.h +++ b/llvm/include/llvm/ADT/Bitfields.h @@ -154,12 +154,9 @@ struct ResolveUnderlyingType { using type = std::underlying_type_t<T>; }; template <typename T> struct ResolveUnderlyingType<T, false> { - using type = T; -}; -template <> struct ResolveUnderlyingType<bool, false> { - /// In case sizeof(bool) != 1, replace `void` by an additionnal - /// std::conditional. - using type = std::conditional_t<sizeof(bool) == 1, uint8_t, void>; + static_assert(!std::is_same_v<T, bool> || sizeof(bool) == 1, + "T being bool requires sizeof(bool) == 1."); + using type = std::conditional_t<std::is_same_v<T, bool>, uint8_t, T>; }; } // namespace bitfields_details diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index 4bda50f..25b5262 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -42,7 +42,7 @@ namespace detail { // We extend a pair to allow users to override the bucket type with their own // implementation without requiring two members. template <typename KeyT, typename ValueT> -struct DenseMapPair : public std::pair<KeyT, ValueT> { +struct DenseMapPair : std::pair<KeyT, ValueT> { using std::pair<KeyT, ValueT>::pair; KeyT &getFirst() { return std::pair<KeyT, ValueT>::first; } diff --git a/llvm/include/llvm/ADT/DepthFirstIterator.h b/llvm/include/llvm/ADT/DepthFirstIterator.h index 4ced758..3c54f32 100644 --- a/llvm/include/llvm/ADT/DepthFirstIterator.h +++ b/llvm/include/llvm/ADT/DepthFirstIterator.h @@ -66,8 +66,8 @@ public: // one more method, completed, which is invoked when all children of a // node have been processed. It is intended to distinguish of back and // cross edges in the spanning tree but is not used in the common case. -template <typename NodeRef, unsigned SmallSize=8> -struct df_iterator_default_set : public SmallPtrSet<NodeRef, SmallSize> { +template <typename NodeRef, unsigned SmallSize = 8> +struct df_iterator_default_set : SmallPtrSet<NodeRef, SmallSize> { using BaseSet = SmallPtrSet<NodeRef, SmallSize>; using iterator = typename BaseSet::iterator; @@ -235,8 +235,10 @@ iterator_range<df_iterator<T>> depth_first(const T& G) { } // Provide global definitions of external depth first iterators... -template <class T, class SetTy = df_iterator_default_set<typename GraphTraits<T>::NodeRef>> -struct df_ext_iterator : public df_iterator<T, SetTy, true> { +template <class T, + class SetTy = + df_iterator_default_set<typename GraphTraits<T>::NodeRef>> +struct df_ext_iterator : df_iterator<T, SetTy, true> { df_ext_iterator(const df_iterator<T, SetTy, true> &V) : df_iterator<T, SetTy, true>(V) {} }; @@ -262,7 +264,7 @@ template <class T, class SetTy = df_iterator_default_set<typename GraphTraits<T>::NodeRef>, bool External = false> -struct idf_iterator : public df_iterator<Inverse<T>, SetTy, External> { +struct idf_iterator : df_iterator<Inverse<T>, SetTy, External> { idf_iterator(const df_iterator<Inverse<T>, SetTy, External> &V) : df_iterator<Inverse<T>, SetTy, External>(V) {} }; @@ -284,8 +286,10 @@ iterator_range<idf_iterator<T>> inverse_depth_first(const T& G) { } // Provide global definitions of external inverse depth first iterators... -template <class T, class SetTy = df_iterator_default_set<typename GraphTraits<T>::NodeRef>> -struct idf_ext_iterator : public idf_iterator<T, SetTy, true> { +template <class T, + class SetTy = + df_iterator_default_set<typename GraphTraits<T>::NodeRef>> +struct idf_ext_iterator : idf_iterator<T, SetTy, true> { idf_ext_iterator(const idf_iterator<T, SetTy, true> &V) : idf_iterator<T, SetTy, true>(V) {} idf_ext_iterator(const df_iterator<Inverse<T>, SetTy, true> &V) diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h index 310539f..8b2425e 100644 --- a/llvm/include/llvm/ADT/ImmutableSet.h +++ b/llvm/include/llvm/ADT/ImmutableSet.h @@ -931,8 +931,7 @@ struct ImutProfileInfo<T*> { /// ImutContainerInfo - Generic definition of comparison operations for /// elements of immutable containers that defaults to using /// std::equal_to<> and std::less<> to perform comparison of elements. -template <typename T> -struct ImutContainerInfo : public ImutProfileInfo<T> { +template <typename T> struct ImutContainerInfo : ImutProfileInfo<T> { using value_type = typename ImutProfileInfo<T>::value_type; using value_type_ref = typename ImutProfileInfo<T>::value_type_ref; using key_type = value_type; @@ -957,8 +956,7 @@ struct ImutContainerInfo : public ImutProfileInfo<T> { /// ImutContainerInfo - Specialization for pointer values to treat pointers /// as references to unique objects. Pointers are thus compared by /// their addresses. -template <typename T> -struct ImutContainerInfo<T*> : public ImutProfileInfo<T*> { +template <typename T> struct ImutContainerInfo<T *> : ImutProfileInfo<T *> { using value_type = typename ImutProfileInfo<T*>::value_type; using value_type_ref = typename ImutProfileInfo<T*>::value_type_ref; using key_type = value_type; diff --git a/llvm/include/llvm/ADT/PackedVector.h b/llvm/include/llvm/ADT/PackedVector.h index 09c20e3..57e4197 100644 --- a/llvm/include/llvm/ADT/PackedVector.h +++ b/llvm/include/llvm/ADT/PackedVector.h @@ -29,6 +29,8 @@ namespace llvm { /// an assertion. template <typename T, unsigned BitNum, typename BitVectorTy = BitVector> class PackedVector { + static_assert(BitNum > 0, "BitNum must be > 0"); + BitVectorTy Bits; // Keep track of the number of elements on our own. // We always maintain Bits.size() == NumElements * BitNum. @@ -133,9 +135,6 @@ public: BitVectorTy &raw_bits() { return Bits; } }; -// Leave BitNum=0 undefined. -template <typename T> class PackedVector<T, 0>; - } // end namespace llvm #endif // LLVM_ADT_PACKEDVECTOR_H diff --git a/llvm/include/llvm/ADT/PagedVector.h b/llvm/include/llvm/ADT/PagedVector.h index 52ecd0b..0a691f8 100644 --- a/llvm/include/llvm/ADT/PagedVector.h +++ b/llvm/include/llvm/ADT/PagedVector.h @@ -189,8 +189,7 @@ public: while (ElementIdx < PV->Size && !PV->PageToDataPtrs[ElementIdx / PageSize]) ElementIdx += PageSize; - if (ElementIdx > PV->Size) - ElementIdx = PV->Size; + ElementIdx = std::min(ElementIdx, PV->Size); } return *this; diff --git a/llvm/include/llvm/ADT/PostOrderIterator.h b/llvm/include/llvm/ADT/PostOrderIterator.h index 1cbd3c1..d9aa452 100644 --- a/llvm/include/llvm/ADT/PostOrderIterator.h +++ b/llvm/include/llvm/ADT/PostOrderIterator.h @@ -200,7 +200,7 @@ template <class T> iterator_range<po_iterator<T>> post_order(const T &G) { // Provide global definitions of external postorder iterators... template <class T, class SetType = std::set<typename GraphTraits<T>::NodeRef>> -struct po_ext_iterator : public po_iterator<T, SetType, true> { +struct po_ext_iterator : po_iterator<T, SetType, true> { po_ext_iterator(const po_iterator<T, SetType, true> &V) : po_iterator<T, SetType, true>(V) {} }; @@ -223,7 +223,7 @@ iterator_range<po_ext_iterator<T, SetType>> post_order_ext(const T &G, SetType & // Provide global definitions of inverse post order iterators... template <class T, class SetType = std::set<typename GraphTraits<T>::NodeRef>, bool External = false> -struct ipo_iterator : public po_iterator<Inverse<T>, SetType, External> { +struct ipo_iterator : po_iterator<Inverse<T>, SetType, External> { ipo_iterator(const po_iterator<Inverse<T>, SetType, External> &V) : po_iterator<Inverse<T>, SetType, External> (V) {} }; @@ -245,7 +245,7 @@ iterator_range<ipo_iterator<T>> inverse_post_order(const T &G) { // Provide global definitions of external inverse postorder iterators... template <class T, class SetType = std::set<typename GraphTraits<T>::NodeRef>> -struct ipo_ext_iterator : public ipo_iterator<T, SetType, true> { +struct ipo_ext_iterator : ipo_iterator<T, SetType, true> { ipo_ext_iterator(const ipo_iterator<T, SetType, true> &V) : ipo_iterator<T, SetType, true>(V) {} ipo_ext_iterator(const po_iterator<Inverse<T>, SetType, true> &V) : diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index 658f262..a9841c6 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -674,7 +674,7 @@ using zip_traits = iterator_facade_base< ReferenceTupleType *, ReferenceTupleType>; template <typename ZipType, typename ReferenceTupleType, typename... Iters> -struct zip_common : public zip_traits<ZipType, ReferenceTupleType, Iters...> { +struct zip_common : zip_traits<ZipType, ReferenceTupleType, Iters...> { using Base = zip_traits<ZipType, ReferenceTupleType, Iters...>; using IndexSequence = std::index_sequence_for<Iters...>; using value_type = typename Base::value_type; diff --git a/llvm/include/llvm/ADT/STLForwardCompat.h b/llvm/include/llvm/ADT/STLForwardCompat.h index da9d3ab0..0e9bd2d 100644 --- a/llvm/include/llvm/ADT/STLForwardCompat.h +++ b/llvm/include/llvm/ADT/STLForwardCompat.h @@ -19,6 +19,7 @@ #include <optional> #include <type_traits> +#include <utility> namespace llvm { @@ -26,6 +27,54 @@ namespace llvm { // Features from C++20 //===----------------------------------------------------------------------===// +namespace numbers { +// clang-format off +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T e_v = T(0x1.5bf0a8b145769P+1); // (2.7182818284590452354) https://oeis.org/A001113 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T egamma_v = T(0x1.2788cfc6fb619P-1); // (.57721566490153286061) https://oeis.org/A001620 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T ln2_v = T(0x1.62e42fefa39efP-1); // (.69314718055994530942) https://oeis.org/A002162 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T ln10_v = T(0x1.26bb1bbb55516P+1); // (2.3025850929940456840) https://oeis.org/A002392 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T log2e_v = T(0x1.71547652b82feP+0); // (1.4426950408889634074) +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T log10e_v = T(0x1.bcb7b1526e50eP-2); // (.43429448190325182765) +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T pi_v = T(0x1.921fb54442d18P+1); // (3.1415926535897932385) https://oeis.org/A000796 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T inv_pi_v = T(0x1.45f306dc9c883P-2); // (.31830988618379067154) https://oeis.org/A049541 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T inv_sqrtpi_v = T(0x1.20dd750429b6dP-1); // (.56418958354775628695) https://oeis.org/A087197 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T sqrt2_v = T(0x1.6a09e667f3bcdP+0); // (1.4142135623730950488) https://oeis.org/A00219 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T inv_sqrt2_v = T(0x1.6a09e667f3bcdP-1); // (.70710678118654752440) +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T sqrt3_v = T(0x1.bb67ae8584caaP+0); // (1.7320508075688772935) https://oeis.org/A002194 +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T inv_sqrt3_v = T(0x1.279a74590331cP-1); // (.57735026918962576451) +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T phi_v = T(0x1.9e3779b97f4a8P+0); // (1.6180339887498948482) https://oeis.org/A001622 + +inline constexpr double e = e_v<double>; +inline constexpr double egamma = egamma_v<double>; +inline constexpr double ln2 = ln2_v<double>; +inline constexpr double ln10 = ln10_v<double>; +inline constexpr double log2e = log2e_v<double>; +inline constexpr double log10e = log10e_v<double>; +inline constexpr double pi = pi_v<double>; +inline constexpr double inv_pi = inv_pi_v<double>; +inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>; +inline constexpr double sqrt2 = sqrt2_v<double>; +inline constexpr double inv_sqrt2 = inv_sqrt2_v<double>; +inline constexpr double sqrt3 = sqrt3_v<double>; +inline constexpr double inv_sqrt3 = inv_sqrt3_v<double>; +inline constexpr double phi = phi_v<double>; +// clang-format on +} // namespace numbers + template <typename T> struct remove_cvref // NOLINT(readability-identifier-naming) { @@ -69,6 +118,15 @@ struct detector<std::void_t<Op<Args...>>, Op, Args...> { template <template <class...> class Op, class... Args> using is_detected = typename detail::detector<void, Op, Args...>::value_t; +struct identity_cxx20 // NOLINT(readability-identifier-naming) +{ + using is_transparent = void; + + template <typename T> constexpr T &&operator()(T &&self) const noexcept { + return std::forward<T>(self); + } +}; + //===----------------------------------------------------------------------===// // Features from C++23 //===----------------------------------------------------------------------===// diff --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h index f588a77..8e7c8b3 100644 --- a/llvm/include/llvm/ADT/SmallPtrSet.h +++ b/llvm/include/llvm/ADT/SmallPtrSet.h @@ -532,18 +532,8 @@ class SmallPtrSet : public SmallPtrSetImpl<PtrType> { using BaseT = SmallPtrSetImpl<PtrType>; - // A constexpr version of llvm::bit_ceil. - // TODO: Replace this with std::bit_ceil once C++20 is available. - static constexpr size_t RoundUpToPowerOfTwo(size_t X) { - size_t C = 1; - size_t CMax = C << (std::numeric_limits<size_t>::digits - 1); - while (C < X && C < CMax) - C <<= 1; - return C; - } - // Make sure that SmallSize is a power of two, round up if not. - static constexpr size_t SmallSizePowTwo = RoundUpToPowerOfTwo(SmallSize); + static constexpr size_t SmallSizePowTwo = llvm::bit_ceil_constexpr(SmallSize); /// SmallStorage - Fixed size storage used in 'small mode'. const void *SmallStorage[SmallSizePowTwo]; diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h index 66c4f94..8b60b69 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -336,34 +336,44 @@ template <typename T> [[nodiscard]] T bit_ceil(T Value) { return T(1) << llvm::bit_width<T>(Value - 1u); } -// Forward-declare rotr so that rotl can use it. -template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>> -[[nodiscard]] constexpr T rotr(T V, int R); +/// Returns the smallest integral power of two no smaller than Value if Value is +/// nonzero. Returns 1 otherwise. +/// +/// Ex. bit_ceil(5) == 8. +/// +/// The return value is undefined if the input is larger than the largest power +/// of two representable in T. +template <typename T> [[nodiscard]] constexpr T bit_ceil_constexpr(T Value) { + static_assert(std::is_unsigned_v<T>, + "Only unsigned integral types are allowed."); + if (Value < 2) + return 1; + return T(1) << llvm::bit_width_constexpr<T>(Value - 1u); +} template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>> [[nodiscard]] constexpr T rotl(T V, int R) { - unsigned N = std::numeric_limits<T>::digits; + constexpr unsigned N = std::numeric_limits<T>::digits; - R = R % N; - if (!R) - return V; + static_assert(has_single_bit(N), "& (N - 1) is only valid for powers of two"); + R = R & (N - 1); - if (R < 0) - return llvm::rotr(V, -R); + if (R == 0) + return V; return (V << R) | (V >> (N - R)); } -template <typename T, typename> [[nodiscard]] constexpr T rotr(T V, int R) { - unsigned N = std::numeric_limits<T>::digits; +template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>> +[[nodiscard]] constexpr T rotr(T V, int R) { + constexpr unsigned N = std::numeric_limits<T>::digits; + + static_assert(has_single_bit(N), "& (N - 1) is only valid for powers of two"); + R = R & (N - 1); - R = R % N; - if (!R) + if (R == 0) return V; - if (R < 0) - return llvm::rotl(V, -R); - return (V >> R) | (V << (N - R)); } diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index e5a6c8c..3d3ec14 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1345,6 +1345,7 @@ public: class LoopGuards { DenseMap<const SCEV *, const SCEV *> RewriteMap; + SmallDenseSet<std::pair<const SCEV *, const SCEV *>> NotEqual; bool PreserveNUW = false; bool PreserveNSW = false; ScalarEvolution &SE; diff --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h index a4ca54e..f9d7c76 100644 --- a/llvm/include/llvm/Support/Alignment.h +++ b/llvm/include/llvm/Support/Alignment.h @@ -103,7 +103,7 @@ inline Align assumeAligned(uint64_t Value) { /// This struct is a compact representation of a valid (power of two) or /// undefined (0) alignment. -struct MaybeAlign : public std::optional<Align> { +struct MaybeAlign : std::optional<Align> { private: using UP = std::optional<Align>; diff --git a/llvm/include/llvm/Support/Casting.h b/llvm/include/llvm/Support/Casting.h index 2a9a149..6f6df2e 100644 --- a/llvm/include/llvm/Support/Casting.h +++ b/llvm/include/llvm/Support/Casting.h @@ -340,7 +340,7 @@ struct ValueFromPointerCast /// during the cast. It's also a good example of how to implement a move-only /// cast. template <typename To, typename From, typename Derived = void> -struct UniquePtrCast : public CastIsPossible<To, From *> { +struct UniquePtrCast : CastIsPossible<To, From *> { using Self = detail::SelfType<Derived, UniquePtrCast<To, From>>; using CastResultType = std::unique_ptr< std::remove_reference_t<typename cast_retty<To, From>::ret_type>>; @@ -473,7 +473,7 @@ struct ForwardToPointerCast { // take advantage of the cast traits whenever possible! template <typename To, typename From, typename Enable = void> -struct CastInfo : public CastIsPossible<To, From> { +struct CastInfo : CastIsPossible<To, From> { using Self = CastInfo<To, From, Enable>; using CastReturnType = typename cast_retty<To, From>::ret_type; @@ -536,8 +536,7 @@ struct CastInfo<To, std::unique_ptr<From>> : public UniquePtrCast<To, From> {}; /// the input is std::optional<From> that the output can be std::optional<To>. /// If that's not the case, specialize CastInfo for your use case. template <typename To, typename From> -struct CastInfo<To, std::optional<From>> : public OptionalValueCast<To, From> { -}; +struct CastInfo<To, std::optional<From>> : OptionalValueCast<To, From> {}; /// isa<X> - Return true if the parameter to the template is an instance of one /// of the template type arguments. Used like this: diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index dd05c53..5a5f00e 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -549,7 +549,7 @@ template <class DataType> struct OptionValue; // The default value safely does nothing. Option value printing is only // best-effort. template <class DataType, bool isClass> -struct OptionValueBase : public GenericOptionValue { +struct OptionValueBase : GenericOptionValue { // Temporary storage for argument passing. using WrapperType = OptionValue<DataType>; diff --git a/llvm/include/llvm/Support/DOTGraphTraits.h b/llvm/include/llvm/Support/DOTGraphTraits.h index ffa9abe..3b9fe00 100644 --- a/llvm/include/llvm/Support/DOTGraphTraits.h +++ b/llvm/include/llvm/Support/DOTGraphTraits.h @@ -162,9 +162,8 @@ public: /// graphs are converted to 'dot' graphs. When specializing, you may inherit /// from DefaultDOTGraphTraits if you don't need to override everything. /// -template <typename Ty> -struct DOTGraphTraits : public DefaultDOTGraphTraits { - DOTGraphTraits (bool simple=false) : DefaultDOTGraphTraits (simple) {} +template <typename Ty> struct DOTGraphTraits : DefaultDOTGraphTraits { + using DefaultDOTGraphTraits::DefaultDOTGraphTraits; }; } // End llvm namespace diff --git a/llvm/include/llvm/Support/ELFAttributes.h b/llvm/include/llvm/Support/ELFAttributes.h index 270246f..5771a84 100644 --- a/llvm/include/llvm/Support/ELFAttributes.h +++ b/llvm/include/llvm/Support/ELFAttributes.h @@ -48,8 +48,6 @@ struct SubsectionAndTagToTagName { StringRef SubsectionName; unsigned Tag; StringRef TagName; - SubsectionAndTagToTagName(StringRef SN, unsigned Tg, StringRef TN) - : SubsectionName(SN), Tag(Tg), TagName(TN) {} }; namespace ELFAttrs { diff --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h index a8784ed..3bef75c 100644 --- a/llvm/include/llvm/Support/GraphWriter.h +++ b/llvm/include/llvm/Support/GraphWriter.h @@ -343,7 +343,7 @@ public: const void *DestNodeID, int DestNodePort, const std::string &Attrs) { if (SrcNodePort > 64) return; // Eminating from truncated part? - if (DestNodePort > 64) DestNodePort = 64; // Targeting the truncated part? + DestNodePort = std::min(DestNodePort, 64); // Targeting the truncated part? O << "\tNode" << SrcNodeID; if (SrcNodePort >= 0) diff --git a/llvm/include/llvm/Support/LSP/Protocol.h b/llvm/include/llvm/Support/LSP/Protocol.h index 93b82f1..e38203a 100644 --- a/llvm/include/llvm/Support/LSP/Protocol.h +++ b/llvm/include/llvm/Support/LSP/Protocol.h @@ -449,7 +449,7 @@ struct ReferenceContext { bool fromJSON(const llvm::json::Value &value, ReferenceContext &result, llvm::json::Path path); -struct ReferenceParams : public TextDocumentPositionParams { +struct ReferenceParams : TextDocumentPositionParams { ReferenceContext context; }; diff --git a/llvm/include/llvm/Support/MD5.h b/llvm/include/llvm/Support/MD5.h index ed29826..4ba3867 100644 --- a/llvm/include/llvm/Support/MD5.h +++ b/llvm/include/llvm/Support/MD5.h @@ -41,7 +41,7 @@ template <typename T> class ArrayRef; class MD5 { public: - struct MD5Result : public std::array<uint8_t, 16> { + struct MD5Result : std::array<uint8_t, 16> { LLVM_ABI SmallString<32> digest() const; uint64_t low() const { diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h index c2716a9..41232335 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -13,6 +13,7 @@ #ifndef LLVM_SUPPORT_MATHEXTRAS_H #define LLVM_SUPPORT_MATHEXTRAS_H +#include "llvm/ADT/STLForwardCompat.h" #include "llvm/ADT/bit.h" #include "llvm/Support/Compiler.h" #include <cassert> @@ -42,38 +43,28 @@ using common_sint = /// Mathematical constants. namespace numbers { -// TODO: Track C++20 std::numbers. // clang-format off -constexpr double e = 0x1.5bf0a8b145769P+1, // (2.7182818284590452354) https://oeis.org/A001113 - egamma = 0x1.2788cfc6fb619P-1, // (.57721566490153286061) https://oeis.org/A001620 - ln2 = 0x1.62e42fefa39efP-1, // (.69314718055994530942) https://oeis.org/A002162 - ln10 = 0x1.26bb1bbb55516P+1, // (2.3025850929940456840) https://oeis.org/A002392 - log2e = 0x1.71547652b82feP+0, // (1.4426950408889634074) - log10e = 0x1.bcb7b1526e50eP-2, // (.43429448190325182765) - pi = 0x1.921fb54442d18P+1, // (3.1415926535897932385) https://oeis.org/A000796 - inv_pi = 0x1.45f306dc9c883P-2, // (.31830988618379067154) https://oeis.org/A049541 - sqrtpi = 0x1.c5bf891b4ef6bP+0, // (1.7724538509055160273) https://oeis.org/A002161 - inv_sqrtpi = 0x1.20dd750429b6dP-1, // (.56418958354775628695) https://oeis.org/A087197 - sqrt2 = 0x1.6a09e667f3bcdP+0, // (1.4142135623730950488) https://oeis.org/A00219 - inv_sqrt2 = 0x1.6a09e667f3bcdP-1, // (.70710678118654752440) - sqrt3 = 0x1.bb67ae8584caaP+0, // (1.7320508075688772935) https://oeis.org/A002194 - inv_sqrt3 = 0x1.279a74590331cP-1, // (.57735026918962576451) - phi = 0x1.9e3779b97f4a8P+0; // (1.6180339887498948482) https://oeis.org/A001622 -constexpr float ef = 0x1.5bf0a8P+1F, // (2.71828183) https://oeis.org/A001113 - egammaf = 0x1.2788d0P-1F, // (.577215665) https://oeis.org/A001620 - ln2f = 0x1.62e430P-1F, // (.693147181) https://oeis.org/A002162 - ln10f = 0x1.26bb1cP+1F, // (2.30258509) https://oeis.org/A002392 - log2ef = 0x1.715476P+0F, // (1.44269504) - log10ef = 0x1.bcb7b2P-2F, // (.434294482) - pif = 0x1.921fb6P+1F, // (3.14159265) https://oeis.org/A000796 - inv_pif = 0x1.45f306P-2F, // (.318309886) https://oeis.org/A049541 - sqrtpif = 0x1.c5bf8aP+0F, // (1.77245385) https://oeis.org/A002161 - inv_sqrtpif = 0x1.20dd76P-1F, // (.564189584) https://oeis.org/A087197 - sqrt2f = 0x1.6a09e6P+0F, // (1.41421356) https://oeis.org/A002193 - inv_sqrt2f = 0x1.6a09e6P-1F, // (.707106781) - sqrt3f = 0x1.bb67aeP+0F, // (1.73205081) https://oeis.org/A002194 - inv_sqrt3f = 0x1.279a74P-1F, // (.577350269) - phif = 0x1.9e377aP+0F; // (1.61803399) https://oeis.org/A001622 +inline constexpr float ef = e_v<float>; +inline constexpr float egammaf = egamma_v<float>; +inline constexpr float ln2f = ln2_v<float>; +inline constexpr float ln10f = ln10_v<float>; +inline constexpr float log2ef = log2e_v<float>; +inline constexpr float log10ef = log10e_v<float>; +inline constexpr float pif = pi_v<float>; +inline constexpr float inv_pif = inv_pi_v<float>; +inline constexpr float inv_sqrtpif = inv_sqrtpi_v<float>; +inline constexpr float sqrt2f = sqrt2_v<float>; +inline constexpr float inv_sqrt2f = inv_sqrt2_v<float>; +inline constexpr float sqrt3f = sqrt3_v<float>; +inline constexpr float inv_sqrt3f = inv_sqrt3_v<float>; +inline constexpr float phif = phi_v<float>; + +// sqrtpi is not in C++20 std::numbers. +template <typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>> +inline constexpr T sqrtpi_v = T(0x1.c5bf891b4ef6bP+0); // (1.7724538509055160273) https://oeis.org/A002161 +inline constexpr double sqrtpi = sqrtpi_v<double>; +inline constexpr float sqrtpif = sqrtpi_v<float>; + // These string literals are taken from below: // https://github.com/bminor/glibc/blob/8543577b04ded6d979ffcc5a818930e4d74d0645/math/math.h#L1215-L1229 constexpr const char *pis = "3.141592653589793238462643383279502884", diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h index 40709d4..a4ed712 100644 --- a/llvm/include/llvm/Support/Timer.h +++ b/llvm/include/llvm/Support/Timer.h @@ -167,7 +167,7 @@ public: /// you to declare a new timer, AND specify the region to time, all in one /// statement. All timers with the same name are merged. This is primarily /// used for debugging and for hunting performance problems. -struct NamedRegionTimer : public TimeRegion { +struct NamedRegionTimer : TimeRegion { LLVM_ABI explicit NamedRegionTimer(StringRef Name, StringRef Description, StringRef GroupName, StringRef GroupDescription, |