Skip to content

Commit

Permalink
[wpiutil] Upgrade to LLVM 18.1.1 (wpilibsuite#6405)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Mar 18, 2024
1 parent fd4424e commit b4674ba
Show file tree
Hide file tree
Showing 62 changed files with 964 additions and 664 deletions.
2 changes: 1 addition & 1 deletion ntcore/src/main/native/cpp/net/WebSocketConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void WebSocketConnection::SendPing(uint64_t time) {
WPI_DEBUG4(m_logger, "conn: sending ping {}", time);
auto buf = AllocBuf();
buf.len = 8;
wpi::support::endian::write64<wpi::support::native>(buf.base, time);
wpi::support::endian::write64<wpi::endianness::native>(buf.base, time);
m_ws.SendPing({buf}, [selfweak = weak_from_this()](auto bufs, auto err) {
if (auto self = selfweak.lock()) {
self->m_err = err;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <[email protected]>
Date: Sat, 7 May 2022 22:12:41 -0400
Subject: [PATCH 02/34] Wrap std::min/max calls in parens, for Windows warnings
Subject: [PATCH 02/35] Wrap std::min/max calls in parens, for Windows warnings

---
llvm/include/llvm/ADT/DenseMap.h | 4 ++--
llvm/include/llvm/ADT/SmallVector.h | 12 ++++++------
llvm/include/llvm/ADT/SmallVector.h | 6 +++---
llvm/include/llvm/Support/ConvertUTF.h | 2 +-
llvm/include/llvm/Support/MathExtras.h | 18 +++++++++---------
4 files changed, 18 insertions(+), 18 deletions(-)
4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004be6facafb 100644
Expand All @@ -33,10 +33,10 @@ index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004b
this->BaseT::initEmpty();
return;
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0489e14c9 100644
index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad62e06e973 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -55,12 +55,12 @@ protected:
@@ -55,7 +55,7 @@ protected:

/// The maximum value of the Size_T used.
static constexpr size_t SizeTypeMax() {
Expand All @@ -45,22 +45,7 @@ index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0
}

SmallVectorBase() = delete;
SmallVectorBase(void *FirstEl, size_t TotalCapacity)
- : BeginX(FirstEl), Capacity(TotalCapacity) {}
+ : BeginX(FirstEl), Capacity(static_cast<unsigned>(TotalCapacity)) {}

/// This is a helper for \a grow() that's out of line to reduce code
/// duplication. This function will report a fatal error if it can't grow at
@@ -99,7 +99,7 @@ protected:
/// This does not construct or destroy any elements in the vector.
void set_size(size_t N) {
assert(N <= capacity());
- Size = N;
+ Size = static_cast<unsigned>(N);
}
};

@@ -279,7 +279,7 @@ public:
@@ -289,7 +289,7 @@ public:

size_type size_in_bytes() const { return size() * sizeof(T); }
size_type max_size() const {
Expand All @@ -69,16 +54,7 @@ index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0
}

size_t capacity_in_bytes() const { return capacity() * sizeof(T); }
@@ -467,7 +467,7 @@ void SmallVectorTemplateBase<T, TriviallyCopyable>::takeAllocationForGrow(
free(this->begin());

this->BeginX = NewElts;
- this->Capacity = NewCapacity;
+ this->Capacity = static_cast<unsigned>(NewCapacity);
}

/// SmallVectorTemplateBase<TriviallyCopyable = true> - This is where we put
@@ -712,7 +712,7 @@ public:
@@ -721,7 +721,7 @@ public:
}

// Assign over existing elements.
Expand All @@ -101,7 +77,7 @@ index 5c0e3009c25446a34882fb98329b1d955231bb39..72321022beb373945f7935ed72944fd6
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf366215068b62f527 100644
index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c91ba725d 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -311,26 +311,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; }
Expand Down Expand Up @@ -135,7 +111,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506
}

/// A and B are either alignments or offsets. Return the minimum alignment that
@@ -479,7 +479,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
@@ -482,7 +482,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
T Z = X + Y;
Overflowed = (Z < X || Z < Y);
if (Overflowed)
Expand All @@ -144,7 +120,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506
else
return Z;
}
@@ -492,7 +492,7 @@ std::enable_if_t<std::is_unsigned_v<T>, T> SaturatingAdd(T X, T Y, T Z,
@@ -495,7 +495,7 @@ std::enable_if_t<std::is_unsigned_v<T>, T> SaturatingAdd(T X, T Y, T Z,
bool Overflowed = false;
T XY = SaturatingAdd(X, Y, &Overflowed);
if (Overflowed)
Expand All @@ -153,7 +129,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506
return SaturatingAdd(XY, Z, Args...);
}

@@ -516,7 +516,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
@@ -519,7 +519,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
// Special case: if X or Y is 0, Log2_64 gives -1, and Log2Z
// will necessarily be less than Log2Max as desired.
int Log2Z = Log2_64(X) + Log2_64(Y);
Expand All @@ -162,7 +138,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506
int Log2Max = Log2_64(Max);
if (Log2Z < Log2Max) {
return X * Y;
@@ -636,9 +636,9 @@ std::enable_if_t<std::is_signed_v<T>, T> MulOverflow(T X, T Y, T &Result) {
@@ -639,9 +639,9 @@ std::enable_if_t<std::is_signed_v<T>, T> MulOverflow(T X, T Y, T &Result) {
// Check how the max allowed absolute value (2^n for negative, 2^(n-1) for
// positive) divided by an argument compares to the other.
if (IsNegative)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <[email protected]>
Date: Sat, 7 May 2022 22:13:55 -0400
Subject: [PATCH 03/34] Change unique_function storage size
Subject: [PATCH 03/35] Change unique_function storage size

---
llvm/include/llvm/ADT/FunctionExtras.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 4cf1de488c7bde2692d4878ccb4c4d60241e3a66..9d10b16e3cbe9c0df818a3254fcd3a6032d54b39 100644
index c0bc30c7450fe4b2bc6b9b448824eedc8b132e52..5641a913d0a35ee2911cf872ad90c3dc864f20f5 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -78,7 +78,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<
@@ -79,7 +79,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<

template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
protected:
Expand All @@ -20,7 +20,7 @@ index 4cf1de488c7bde2692d4878ccb4c4d60241e3a66..9d10b16e3cbe9c0df818a3254fcd3a60

template <typename T, class = void>
struct IsSizeLessThanThresholdT : std::false_type {};
@@ -157,7 +157,7 @@ protected:
@@ -158,7 +158,7 @@ protected:
"Should always use all of the out-of-line storage for inline storage!");

// For in-line storage, we just provide an aligned character buffer. We
Expand Down
8 changes: 4 additions & 4 deletions upstream_utils/llvm_patches/0004-Threading-updates.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <[email protected]>
Date: Sat, 7 May 2022 22:17:19 -0400
Subject: [PATCH 04/34] Threading updates
Subject: [PATCH 04/35] Threading updates

- Remove guards for threads and exception
- Prefer scope gaurd over lock gaurd
Expand All @@ -12,18 +12,18 @@ Subject: [PATCH 04/34] Threading updates
3 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 92376629c607461061bc60597a47aed1e535af52..2662839b27bf368cd5da0668099c4b44cbc6435d 100644
index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab527d512bb 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -530,7 +530,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -555,7 +555,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// initialize to some constant value. In almost all circumstances this is most
/// appropriate for use with a pointer, integer, or small aggregation of
/// pointers and integers.
-#if LLVM_ENABLE_THREADS
#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
#define LLVM_THREAD_LOCAL thread_local
#else
@@ -538,11 +537,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -563,11 +562,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
// we only need the restricted functionality that provides.
#define LLVM_THREAD_LOCAL __thread
#endif
Expand Down
46 changes: 23 additions & 23 deletions upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <[email protected]>
Date: Sat, 7 May 2022 22:28:13 -0400
Subject: [PATCH 05/34] \#ifdef guard safety
Subject: [PATCH 05/35] \#ifdef guard safety

Prevents redefinition if someone is pulling in real LLVM, since the macros are in global namespace
---
llvm/include/llvm/Support/Compiler.h | 42 ++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e848519998685b 100644
index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2a451c037 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -90,6 +90,7 @@
Expand Down Expand Up @@ -50,7 +50,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851

#if defined(__clang__)
#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
@@ -178,11 +184,13 @@
@@ -197,11 +203,13 @@
// more portable solution:
// (void)unused_var_name;
// Prefer cast-to-void wherever it is sufficient.
Expand All @@ -64,15 +64,15 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851

// FIXME: Provide this for PE/COFF targets.
#if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \
@@ -192,6 +200,7 @@
@@ -211,6 +219,7 @@
#define LLVM_ATTRIBUTE_WEAK
#endif

+#ifndef LLVM_READNONE
// Prior to clang 3.2, clang did not accept any spelling of
// __has_attribute(const), so assume it is supported.
#if defined(__clang__) || defined(__GNUC__)
@@ -200,13 +209,16 @@
@@ -219,13 +228,16 @@
#else
#define LLVM_READNONE
#endif
Expand All @@ -89,15 +89,15 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851

#if __has_attribute(minsize)
#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize))
@@ -214,6 +226,7 @@
@@ -233,6 +245,7 @@
#define LLVM_ATTRIBUTE_MINSIZE
#endif

+#ifndef LLVM_LIKELY
#if __has_builtin(__builtin_expect) || defined(__GNUC__)
#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
@@ -221,9 +234,11 @@
@@ -240,9 +253,11 @@
#define LLVM_LIKELY(EXPR) (EXPR)
#define LLVM_UNLIKELY(EXPR) (EXPR)
#endif
Expand All @@ -109,7 +109,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if __has_attribute(noinline)
#define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
@@ -231,9 +246,11 @@
@@ -250,9 +265,11 @@
#else
#define LLVM_ATTRIBUTE_NOINLINE
#endif
Expand All @@ -121,23 +121,23 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if __has_attribute(always_inline)
#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline))
#elif defined(_MSC_VER)
@@ -241,6 +258,7 @@
@@ -260,6 +277,7 @@
#else
#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
#endif
+#endif

/// LLVM_ATTRIBUTE_NO_DEBUG - On compilers where we have a directive to do
/// so, mark a method "no debug" because debug info makes the debugger
@@ -251,6 +269,7 @@
@@ -270,6 +288,7 @@
#define LLVM_ATTRIBUTE_NODEBUG
#endif

+#ifndef LLVM_ATTRIBUTE_RETURNS_NONNULL
#if __has_attribute(returns_nonnull)
#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
#elif defined(_MSC_VER)
@@ -258,9 +277,11 @@
@@ -277,9 +296,11 @@
#else
#define LLVM_ATTRIBUTE_RETURNS_NONNULL
#endif
Expand All @@ -149,7 +149,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#ifdef __GNUC__
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
#elif defined(_MSC_VER)
@@ -268,8 +289,10 @@
@@ -287,8 +308,10 @@
#else
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
#endif
Expand All @@ -160,15 +160,15 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
#define LLVM_FALLTHROUGH [[fallthrough]]
#elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
@@ -281,6 +304,7 @@
@@ -300,6 +323,7 @@
#else
#define LLVM_FALLTHROUGH
#endif
+#endif

/// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that
/// they are constant initialized.
@@ -309,11 +333,13 @@
@@ -334,11 +358,13 @@

/// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
/// pedantic diagnostics.
Expand All @@ -182,7 +182,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851

/// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
/// to an expression which states that it is undefined behavior for the
@@ -322,14 +348,17 @@
@@ -347,14 +373,17 @@
/// '#else' is intentionally left out so that other macro logic (e.g.,
/// LLVM_ASSUME_ALIGNED and llvm_unreachable()) can detect whether
/// LLVM_BUILTIN_UNREACHABLE has a definition.
Expand All @@ -200,7 +200,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if __has_builtin(__builtin_trap) || defined(__GNUC__)
# define LLVM_BUILTIN_TRAP __builtin_trap()
#elif defined(_MSC_VER)
@@ -341,10 +370,12 @@
@@ -366,10 +395,12 @@
#else
# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
#endif
Expand All @@ -213,7 +213,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if __has_builtin(__builtin_debugtrap)
# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
#elif defined(_MSC_VER)
@@ -358,9 +389,11 @@
@@ -383,9 +414,11 @@
// program to abort if encountered.
# define LLVM_BUILTIN_DEBUGTRAP
#endif
Expand All @@ -225,31 +225,31 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__)
# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
#elif defined(LLVM_BUILTIN_UNREACHABLE)
@@ -369,6 +402,7 @@
@@ -394,6 +427,7 @@
#else
# define LLVM_ASSUME_ALIGNED(p, a) (p)
#endif
+#endif

/// \macro LLVM_PACKED
/// Used to specify a packed structure.
@@ -388,6 +422,7 @@
@@ -413,6 +447,7 @@
/// long long l;
/// };
/// LLVM_PACKED_END
+#ifndef LLVM_PACKED
#ifdef _MSC_VER
# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
# define LLVM_PACKED_START __pragma(pack(push, 1))
@@ -397,6 +432,7 @@
@@ -422,6 +457,7 @@
# define LLVM_PACKED_START _Pragma("pack(push, 1)")
# define LLVM_PACKED_END _Pragma("pack(pop)")
#endif
+#endif

/// \macro LLVM_MEMORY_SANITIZER_BUILD
/// Whether LLVM itself is built with MemorySanitizer instrumentation.
@@ -488,11 +524,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -513,11 +549,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);

/// \macro LLVM_NO_SANITIZE
/// Disable a particular sanitizer for a function.
Expand All @@ -263,7 +263,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851

/// Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds.
@@ -500,17 +538,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -525,17 +563,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
/// get stripped in release builds.
// FIXME: Move this to a private config.h as it's not usable in public headers.
Expand All @@ -284,7 +284,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851
#if defined(_MSC_VER)
#define LLVM_PRETTY_FUNCTION __FUNCSIG__
#elif defined(__GNUC__) || defined(__clang__)
@@ -518,6 +559,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -543,6 +584,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
#else
#define LLVM_PRETTY_FUNCTION __func__
#endif
Expand Down
Loading

0 comments on commit b4674ba

Please sign in to comment.