Skip to content

Commit

Permalink
[upstream_utils] Upgrade to LLVM 19.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Nov 9, 2024
1 parent 280d2c7 commit 15eb98c
Show file tree
Hide file tree
Showing 69 changed files with 2,104 additions and 807 deletions.
2 changes: 1 addition & 1 deletion upstream_utils/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def copy_upstream_src(wpilib_root):
def main():
name = "llvm"
url = "https://github.com/llvm/llvm-project"
tag = "llvmorg-18.1.8"
tag = "llvmorg-19.1.3"

patch_options = {
"use_threeway": True,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:12:41 -0400
Subject: [PATCH 02/38] Wrap std::min/max calls in parens, for Windows warnings
Subject: [PATCH 02/36] Wrap std::min/max calls in parens, for Windows warnings

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

diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004be6facafb 100644
index 7ccc9445c0a7b882b424b2431858ea596d0eb58f..c4764fffa845a7f9eb69f262aa0ee728d08b1655 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -416,7 +416,7 @@ protected:
@@ -432,7 +432,7 @@ protected:
return 0;
// +1 is required because of the strict equality.
// For example if NumEntries is 48, we need to return 401.
Expand All @@ -23,7 +23,7 @@ index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004b
}

void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) {
@@ -852,7 +852,7 @@ public:
@@ -868,7 +868,7 @@ public:
// Reduce the number of buckets.
unsigned NewNumBuckets = 0;
if (OldNumEntries)
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 c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad62e06e973 100644
index 94d8da059f4f8bad50039b0d0b7993396707829c..85bf5172e419b1b58f53d3cf00d4aabb58877c33 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -55,7 +55,7 @@ protected:
@@ -56,7 +56,7 @@ protected:

/// The maximum value of the Size_T used.
static constexpr size_t SizeTypeMax() {
Expand All @@ -45,7 +45,7 @@ index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad6
}

SmallVectorBase() = delete;
@@ -289,7 +289,7 @@ public:
@@ -290,7 +290,7 @@ public:

size_type size_in_bytes() const { return size() * sizeof(T); }
size_type max_size() const {
Expand All @@ -54,7 +54,7 @@ index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad6
}

size_t capacity_in_bytes() const { return capacity() * sizeof(T); }
@@ -721,7 +721,7 @@ public:
@@ -722,7 +722,7 @@ public:
}

// Assign over existing elements.
Expand All @@ -77,10 +77,10 @@ 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 aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c91ba725d 100644
index e568e42afcf4d20dba137346953ff4be9d27ffc7..d9de2e92d5b07bce1d02ffcfda614b9079d2df91 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; }
@@ -338,26 +338,26 @@ template <> constexpr size_t CTLog2<1>() { return 0; }
/// (32 bit edition.)
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
inline unsigned Log2_32(uint32_t Value) {
Expand Down Expand Up @@ -111,7 +111,16 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
}

/// A and B are either alignments or offsets. Return the minimum alignment that
@@ -482,7 +482,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
@@ -417,7 +417,7 @@ constexpr uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator) {
// happens only when Numerator = INT_MIN and Denominator = -1.
template <typename U, typename V>
constexpr bool divideSignedWouldOverflow(U Numerator, V Denominator) {
- return Numerator == std::numeric_limits<U>::min() && Denominator == -1;
+ return Numerator == (std::numeric_limits<U>::min)() && Denominator == -1;
}

/// Returns the integer ceil(Numerator / Denominator). Signed version.
@@ -605,7 +605,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
T Z = X + Y;
Overflowed = (Z < X || Z < Y);
if (Overflowed)
Expand All @@ -120,7 +129,7 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
else
return Z;
}
@@ -495,7 +495,7 @@ std::enable_if_t<std::is_unsigned_v<T>, T> SaturatingAdd(T X, T Y, T Z,
@@ -618,7 +618,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 @@ -129,7 +138,7 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
return SaturatingAdd(XY, Z, Args...);
}

@@ -519,7 +519,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
@@ -642,7 +642,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 @@ -138,7 +147,7 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
int Log2Max = Log2_64(Max);
if (Log2Z < Log2Max) {
return X * Y;
@@ -639,9 +639,9 @@ std::enable_if_t<std::is_signed_v<T>, T> MulOverflow(T X, T Y, T &Result) {
@@ -764,9 +764,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 All @@ -147,6 +156,6 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
else
- return UX > (static_cast<U>(std::numeric_limits<T>::max())) / UY;
+ return UX > (static_cast<U>((std::numeric_limits<T>::max)())) / UY;
#endif
}

} // End llvm namespace
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 <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:13:55 -0400
Subject: [PATCH 03/38] Change unique_function storage size
Subject: [PATCH 03/36] 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 c0bc30c7450fe4b2bc6b9b448824eedc8b132e52..5641a913d0a35ee2911cf872ad90c3dc864f20f5 100644
index 49e0e8ab0db400d0a362746342099578257b2eea..3ce85530b718666afa1dafbf60699c1add423ea6 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -79,7 +79,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<
Expand All @@ -28,4 +28,4 @@ index c0bc30c7450fe4b2bc6b9b448824eedc8b132e52..5641a913d0a35ee2911cf872ad90c3dc
+ // provide four pointers worth of storage here.
// This is mutable as an inlined `const unique_function<void() const>` may
// still modify its own mutable members.
mutable std::aligned_storage_t<InlineStorageSize, alignof(void *)>
alignas(void *) mutable std::byte InlineStorage[InlineStorageSize];
35 changes: 17 additions & 18 deletions upstream_utils/llvm_patches/0004-Threading-updates.patch
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:17:19 -0400
Subject: [PATCH 04/38] Threading updates
Subject: [PATCH 04/36] Threading updates

- Remove guards for threads and exception
- Prefer scope gaurd over lock gaurd
---
llvm/include/llvm/Support/Compiler.h | 6 -----
llvm/lib/Support/ErrorHandling.cpp | 38 +++++-----------------------
llvm/lib/Support/ErrorHandling.cpp | 36 +++++-----------------------
llvm/lib/Support/ManagedStatic.cpp | 10 ++++----
3 files changed, 11 insertions(+), 43 deletions(-)
3 files changed, 11 insertions(+), 41 deletions(-)

diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab527d512bb 100644
index 7710bd9a08148289b5ba3b1f2dae5cccc4f26d4d..2a6accec1e74c9869d724c7733cc75ab6af9dc8d 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -555,7 +555,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -563,7 +563,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
@@ -563,11 +562,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -571,11 +570,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
// we only need the restricted functionality that provides.
#define LLVM_THREAD_LOCAL __thread
#endif
Expand All @@ -36,7 +36,7 @@ index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab5
/// \macro LLVM_ENABLE_EXCEPTIONS
/// Whether LLVM is built with exception support.
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb8ba1276e 100644
index 561509e0efdf15f6e534f0621a5964d92511114c..fbd903ed86f65dbdec5ddd69c541e2fc37a484a6 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -44,7 +44,6 @@ static void *ErrorHandlerUserData = nullptr;
Expand Down Expand Up @@ -83,17 +83,16 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
handler = ErrorHandler;
handlerData = ErrorHandlerUserData;
}
@@ -126,18 +118,14 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {

@@ -127,7 +119,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
void *user_data) {
-#if LLVM_ENABLE_THREADS == 1
#if LLVM_ENABLE_THREADS == 1
- std::lock_guard<std::mutex> Lock(BadAllocErrorHandlerMutex);
-#endif
+ std::scoped_lock Lock(BadAllocErrorHandlerMutex);
assert(!ErrorHandler && "Bad alloc error handler already registered!\n");
BadAllocErrorHandler = handler;
BadAllocErrorHandlerUserData = user_data;
#endif
assert(!BadAllocErrorHandler &&
"Bad alloc error handler already registered!\n");
@@ -136,9 +128,7 @@ void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
}

void llvm::remove_bad_alloc_error_handler() {
Expand All @@ -104,7 +103,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
BadAllocErrorHandler = nullptr;
BadAllocErrorHandlerUserData = nullptr;
}
@@ -148,9 +136,7 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
@@ -149,9 +139,7 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
{
// Only acquire the mutex while reading the handler, so as not to invoke a
// user-supplied callback under a lock.
Expand All @@ -115,7 +114,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
Handler = BadAllocErrorHandler;
HandlerData = BadAllocErrorHandlerUserData;
}
@@ -160,10 +146,6 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
@@ -161,10 +149,6 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
llvm_unreachable("bad alloc handler should not return");
}

Expand All @@ -126,7 +125,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
// Don't call the normal error handler. It may allocate memory. Directly write
// an OOM to stderr and abort.
const char *OOMMessage = "LLVM ERROR: out of memory\n";
@@ -172,15 +154,8 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
@@ -173,15 +157,8 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
(void)!::write(2, Reason, strlen(Reason));
(void)!::write(2, Newline, strlen(Newline));
abort();
Expand All @@ -142,7 +141,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
// Causes crash on allocation failure. It is called prior to the handler set by
// 'install_bad_alloc_error_handler'.
static void out_of_memory_new_handler() {
@@ -195,7 +170,6 @@ void llvm::install_out_of_memory_new_handler() {
@@ -196,7 +173,6 @@ void llvm::install_out_of_memory_new_handler() {
assert((old == nullptr || old == out_of_memory_new_handler) &&
"new-handler already installed");
}
Expand Down
Loading

0 comments on commit 15eb98c

Please sign in to comment.