Squashed 'third_party/allwpilib/' changes from 83f1860047..f1a82828fe

f1a82828fe [wpiutil] Add DataLog and DataLogManager Stop() (#5860)
2a04e12c6f [apriltag] AprilTagFieldLayout: Add accessors for origin and field dimensions (#5869)
33e0089afb Cleanup usages of std::function<void(void)> (#5864)
d06fa633d5 [build] Fix protobuf generation when building with make (#5867)
049732afb8 [cscore] Make camera connection logging clearer (#5866)
87f7c19f90 [wpimath] Make InterpolatingDoubleTreeMap constructor public (#5865)
6b53ef47cf [wpimath] Don't recreate TrapezoidProfile in ProfiledPIDController calculate() (#5863)
8a3a268ae6 [commands] Add finallyDo with zero-arg lambda (#5862)
1c35d42cd0 [wpilib] Pop diagnostic for deprecated function use (#5859)
ddc8db6c26 [wpimath] Add feedforward constant constructor to ElevatorSim (#5823)
c6aff2c431 [upstream_utils] Update to LLVM 17.0.4 (#5855)
a9c5b18a39 [build] Update OpenCV to 2024-4.8.0-2 (#5854)
9540b6922d [hal] Add CAN IDs for AndyMark and Vivid Hosting (#5852)
83a7d33c47 [glass] Improve display of protobuf/struct type strings (#5850)
a4a8ad9c75 [commands] Make Java SelectCommand generic (#5849)
9eecf2a456 [build] Add CMake option to build Java sources jars (#5768)
9536a311cb [wpilib] Add support for the PS5 DualSense controller (#5257)
8d5e6737fc [wpilibc] SolenoidSim: Add virtual destructor (#5848)
07e13d60a2 [ntcore] Fix write_impl (#5847)
1713386869 [wpiutil] ProtobufMessageDatabase: Fix out-of-order Add() rebuild (#5845)
35472f5fc9 [ntcore] Fix a use-after-free in client close (#5844)
ed168b522c [ntcore] Disable buf pool when asan is enabled (#5843)
3e7ba2cc6f [wpinet] WebSocket: Fix write behavior (#5841)
80c47da237 [sim] Disable the robot program when DS disconnects (#5818)
abe1cec90c [wpilib] Update Usage Reporting ResourceType from NI Libraries (#5842)
cdf981abba [glass] Fix position of data type in NT view (#5840)
04dcd80adb [build] Publish unit tests for examples (#5838)
49920234ac [build] Fix checkstyle rules to allow Windows paths (#5839)
366b715942 [wpilib] Fix SendableChooser test (#5835)
3ba501f947 [commands] Java: Fix CommandXboxController.leftTrigger() parameter order (#5831)
ec569a58ef [wpimath] Make KalmanTypeFilter interface public (#5830)
b91317fd36 [wpiutil] DataLog.addSchema(): Don't add into a set view (#5829)
2ab4fcbc24 [wpiutil] ProtobufMessageDatabase: Clear messages first (#5827)
98c14f1692 [wpimath] Add EKF/UKF u-y-R correct overload (#5832)
60bcdeded9 [ci] Disable java in sanitizer builds (#5833)
c87f8fd538 [commands] Add DeferredCommand (#5566)
ad80eb3a0b [ci] Update actions for comment-command (#5824)
c7d6ad5a0b [ntcore] WebSocketConnection: Use weak capture (#5822)
8a8e220792 [simgui] Add 'Invalid' option for AllianceStation (#5820)
cfc6a47f76 [sim] DS plugin: Fix off-by-one error when setting alliance station (#5819)
8efa586ace [ntcore] Don't check type string on publishing an entry (#5816)
23ea188e60 [glass] Add protobuf decode error log message (#5812)
928e87b4f4 [build] Add combined test meta-task (#5813)
63ef585d4b [wpiutil] Fix compilation of MathExtras.h on Windows with /sdl (#5809)
b03a7668f9 [build] Windows CMake/vcpkg fixes (#5807)
3f08bcde54 [hal] Fix HAL AllianceStation on rio (#5811)
196d963dc4 [ntcore] Fix off-by-one error in stream write (#5810)
f4cbcbc984 Fix typos (NFC) (#5804)
ec0f7fefb0 [myrobot] Update the myRobot JRE (#5805)
3d618bdbfd [wpiutil] Fix Java struct array unpacking (#5801)
1fa7445667 [ntcore] Check for valid client in incoming text and binary (#5799)
269b9647da [ci] Update JDK for combine step (#5794)
bee32f080e [docs] Add wpiunits to JavaDocs (#5793)
25dad5a531 [wpinet] TCPConnector_parallel: Don't use thread_local (#5791)
4a93581f1a [build] cmake: use default library type for libglassnt, libglass, wpigui, and imgui (#5797)
abb2857e03 [wpilib] Counter: Fix default distance per pulse, add distance and rate to C++ (#5796)
b14a61e1c0 [readme] Add link to QuickBuffers release page (#5795)
cf54d9ccb7 [wpiutil, ntcore] Add structured data support (#5391)
ecb7cfa9ef [wpimath] Add Exponential motion profile (#5720)
7c6fe56cf2 [ntcore] Fix crash on disconnect (#5788)
85147bf69e [wpinet] WebSocketSerializer: Fix UB (#5787)
244163acad [wpinet] uv::Stream::TryWrite(): Return 0 on EAGAIN (#5784)
820728503d [hal] Remove extra semicolon in RoboRioData (#5786)
45f307d87e [upstream_utils] Upgrade to LLVM 17.0.3 (#5785)
4ce4d63efc [wpilibj] Fix RobotBase.isSimulation() (#5783)
579007ceb3 [commands] Add requirements parameter to Commands.idle() (#5774)
3f3a169149 [wpilib] Make physics sim setState() functions public (#5779)
7501e4ac88 [wpilib] Close sim device in ADIS IMUs (#5776)
99630d2e78 [wpimath] Upgrade to EJML 0.43.1 (#5778)
02cbbc997d [wpimath] Make Vector-Vector binary operators return Vector (#5772)
ed93889e17 [examples] Fix typo in TimesliceRobot example name (#5773)
da70e4c262 [docs] Add jinja2 to CMake prerequisites (#5771)
e814595ea7 [wpimath] Add ChassisSpeeds.fromRobotRelativeSpeeds() (#5744)
f98c943445 [wpimath] LinearSystemId: Add DCMotorSystem overload (#5770)
b3eb64b0f7 [wpiutil] ct_string: Use inline namespace for literals (#5767)
7d9ba256c2 Revert "[build] Add CMake option to build Java source jars (#5756)" (#5766)
1f6492e3d8 [sysid] Update JSON library usage (#5765)
638f04f626 [wpiutil] Add protobuf to thirdparty sources (#5746)
210255bfff [wpiutil] Update json to 3.11.2 (#5680)
896772c750 [wpimath] Add DCMotor functions for Kraken X60 and Neo Vortex (#5759)
fd427f6c82 [wpimath] Fix hardcoded module count in SwerveDriveKinematics.resetHeading() (#5762)
c0b4c6cce6 [wpimath] Add overloads for Transform2d and Transform3d (#5757)
9a0aafd8ab [examples] Make swerve examples multiply desired module speeds by cosine of heading error (#5758)
1c724884ca [build] Add CMake option to build Java source jars (#5756)
5b0db6b93e [ci] Forward CI as well (#5755)
f8cbbbac12 [ci] Take 2 on passing GITHUB_REF (#5754)
b9944be09c [ci] Pass GITHUB_REF to docker container (#5753)
de5e4eda6c [build] Update apriltag, libssh, googletest for 2024 (#5752)
227e660e20 [upstream_utils] Upgrade to LLVM 17.0.2 (#5750)
36f94c9f21 [commands,romi,xrp] Add frcYear to vendordep (#5747)
741d166457 [glass] NT view: enhance array support (#5732)
1d23513945 [ntcore] Fix string array value comparison (#5745)
ff1849052e [commands] Make command scheduling order consistent (#5470)
58e8474368 [build] Disable armsimulation unit test (#5739)
fb07b0da49 [examples] Add XRP C++ Examples and Templates (#5743)
81893ad73d Run wpiformat with clang-format 17 (#5740)
faa1e665ba [wpimath] Add ElevatorFeedforward.calculate(currentV, nextV) overload (#5715)
a789632052 [build] Update to native utils 2024.3.1 (#5738)
8f60ab5182 [build] Update OpenCV to 2024-4.8.0-1 (#5737)
33243f982b [wpimath] Expand Quaternion class with additional operators (#5600)
420f2f7c80 [ntcore] Add RTT-only subprotocol (#5731)
2b63e35ded [ntcore] Fix moving outgoing queue to new period (#5735)
be939cb636 [ntcore] Fix notification of SetDefaultEntryValue (#5733)
69a54de202 [build] Update enterprise plugin (#5730)
fef03a3ff5 [commands] Clean up C++ includes after Requirements was added (#5719)
8b7c6852cf [ntcore] Networking improvements (#5659)
1d19e09ca9 [wpiutil] Set WPI_{UN}IGNORE_DEPRECATED to empty when all else fails (#5728)
58141d6eb5 [wpilib] Make BooleanEvent more consistent (#5436)
6576d9b474 [wpilib] SendableChooser: implement Sendable instead of NTSendable (#5718)
a4030c670f [build] Update to gradle 8.4, enable win arm builds (#5727)
0960f11eba [wpinet] Revert removal of uv_clock_gettime() (#5723)
cb1bd0a3be [wpiutil] Get more precise system time on Windows (#5722)
4831277ffe [wpigui] Fix loading a maximized window on second monitor (#5721)
3eb372c25a [wpiutil] SendableBuilder: Add PublishConst methods (#5158)
1fec8596a4 [ci] Fix -dirty version (#5716)
f7e47d03f3 [build] Remove unnecessary CMake config installs (#5714)
a331ed2374 [sysid] Add SysId (#5672)
8d2cbfce16 [wpiutil] DataLog: Stop logging if insufficient free space (#5699)
48facb9cef [ntcoreffi] Add DataLogManager (#5702)
aecbcb08fc [ntcore] Correctly start DataLog for existing publishers (#5703)
5e295dfbda [wpiutil] DataLog: Limit total buffer allocation (#5700)
c7c7e05d9d [ci] Unbreak combiner (#5698)
c92bad52cb [wpilib] DataLogManager: Use system time valid function (#5697)
d404af5f24 [wpilib] RobotController: Add isSystemTimeValid() (#5696)
e56f1a3632 [ci] Run combine but skip all steps (#5695)
8f5bcad244 [ci] Use sccache for cmake builds (#5692)
703dedc4a6 [ci] Upgrade get-cmake action to fix node12 deprecation warning (#5694)
c69a0d7504 [ci] Don't run example unit test that segfaults (#5693)
66358d103e Add menu items for online docs to GUI tools (#5689)
4be8384a76 [ci] Disable combine on PR builds (#5691)
90288f06a6 [ci] Fix Gradle disk space issues (#5688)
9e9583412e [wpigui] Make wpi::gui::OpenURL() fork the process first (#5687)
d4fcd80b7b [ci] Gradle: Use container only for build step (#5684)
7b70e66772 [outlineviewer] Fix thirdparty library include sorting (#5683)
5f651df5d5 [build] Clean up Gradle configs (#5685)
65b26738d5 Add CMakeSettings.json to gitignore (#5682)
d0305951ad Fix GitHub inline warnings (#5681)
e8d4a20331 [build][cmake] Fix windows tests and re-enable CI tests (#5674)
2b58bbde0b [xrp] Add Reflectance sensor and rangefinder classes (#5673)
dd5612fbee [json] Add forward definition header (#5676)
eab44534c3 [wpimath] Remove unused SmallString include (#5677)
5ab54ff760 Replace wpi::raw_istream with wpi::MemoryBuffer (#5675)
1b6ec5a95d [wpiutil] Upgrade to LLVM 17.0.1 (#5482)
07a0d22fe6 [build] Build examples in CMake CI (#5667)
97021f074a [build] Upgrade imgui and implot (#5668)
87ce1e3761 [build] Fix wpilibNewCommands CMake install (#5671)
6ef94de9b5 [wpimath] Add tests for ArmFeedforward and ElevatorFeedforward (#5663)
c395b29fb4 [wpinet] Add WebSocket::TrySendFrames() (#5607)
c4643ba047 [romi/xrp] Fix version typo in vendordep json (#5664)
51dcb8b55a [examples] Make Romi/XRP Examples use appropriate vendordeps (#5665)
daf7702007 [build] Test each example in a new environment (#5662)
e67df8c180 [wpilib] Const-qualify EncoderSim getters (#5660)
7be290147c [wpiutil] Refactor SpanMatcher and TestPrinters from ntcore (#5658)
9fe258427a [commands] Add proxy factory to Commands (#5603)
633c5a8a22 [commands] Add C++ Requirements struct (#5504)
b265a68eea [commands] Add interruptor parameter to onCommandInterrupt callbacks (#5461)
e93c233d60 [ntcore] Compute Value memory size when creating value (#5657)
5383589f99 [wpinet] uv::Request: Return shared_ptr from Release() (#5656)
40b552be4a [wpinet] uv::Stream: Return error from TryWrite() (#5655)
202a75fe08 [wpinet] RequestImpl: Avoid infinite loop in shared_from_this() (#5654)
8896515eb7 [wpinet] uv::Buffer: Add bytes() accessor (#5653)
ae59a2fba2 [wpinet] uv::Error: Change default error to 0 (#5652)
3b51ecc35b [wpiutil] SpanExtras: Add take_back and take_front (#5651)
17f1062885 Replace std::snprintf() with wpi::format_to_n_c_str() (#5645)
bb39900353 [romi/xrp] Add Romi and XRP Vendordeps (#5644)
cb99517838 [build] cmake: Use default install location on windows for dlls (#5580)
25b0622d4c [build] Add Windows CMake CI (#5516)
34e7849605 Add warning to development builds instructions (NFC) (#5646)
e9e611c9d8 [cameraserver] Remove CameraServer.SetSize() (#5650)
94f58cc536 [wpilib] Remove Compressor.Enabled() (#5649)
4da5aee88a [wpimath] Remove SlewRateLimiter 2 argument constructor (#5648)
2e3ddf5502 Update versions in development builds instructions to 2024 (#5647)
19a8850fb1 [examples] Add TimesliceRobot templates (#3683)
9047682202 [sim] Add XRP-specific plugin (#5631)
575348b81c [wpilib] Use IsSimulation() consistently (#3534)
12e2043b77 [wpilib] Clean up Notifier (#5630)
4bac4dd0f4 [wpimath] Move PIDController from frc2 to frc namespace (#5640)
494cfd78c1 [wpiutil] Fix deprecation warning in LLVM for C++23 (#5642)
43a727e868 [apriltag] Make loadAprilTagFieldLayout throw an unchecked exception instead (#5629)
ad4b017321 [ci] Use Ninja for faster builds (#5626)
4f2114d6f5 Fix warnings from GCC 13 release build (#5637)
e7e927fe26 [build] Also compress debug info for CMake RelWithDebInfo build type (#5638)
205a40c895 [build] Specify zlib for debug info compression (#5636)
707444f000 [apriltag] Suppress -Wtype-limits warning in asserts from GCC 13 (#5635)
3b79cb6ed3 [commands] Revert SubsystemBase deprecation/removal (#5634)
bc7f23a632 [build] Compress Linux debug info (#5633)
57b2d6f254 [build] Update to image 2024 v1.0 (#5625)
339ef1ea39 [wpilib] DataLogManager: Warn user if logging to RoboRIO 1 internal storage (#5617)
7a9a901a73 [build] Fix cmake config files (#5624)
298f8a6e33 [wpilib] Add Mechanism2d tests and make Java impl match C++ (#5527)
d7ef817bae [apriltag] Update apriltag library (#5619)
c3fb31fd0e [docs] Switch to Java 17 api docs (#5613)
bd64f81cf9 [build] Run Google tests in release mode in CI (#5615)
66e6bd81ea [wpimath] Cleanup wpimath/algorithms.md (NFC) (#5621)
4fa56fd884 [build] Add missing find_dependency call (#5623)
f63d958995 [build] Update to native utils 2024.2.0 (#5601)
a9ab08f48b [wpimath] Rename ChassisSpeeds.fromDiscreteSpeeds() to discretize() (#5616)
8e05983a4a [wpimath] Add math docs to plant inversion feedforward internals (NFC) (#5618)
3a33ce918b [ntcore] Add missing StringMap include (#5620)
a6157f184d [wpiutil] timestamp: Add ShutdownNowRio (#5610)
e9f612f581 [build] Guard policy setting for CMake versions below 3.24 (#5612)
1a6df6fec6 [wpimath] Fix DARE Q decomposition (#5611)
9b3f7fb548 [build] Exclude IntelliJ folders from spotless XML (#5602)
814f18c7f5 [wpimath] Fix computation of C for DARE (A, C) detectability check (#5609)
ac23f92451 [hal] Add GetTeamNumber (#5596)
a750bee54d [wpimath] Use std::norm() in IsStabilizable() (#5599)
8e2465f8a0 [wpimath] Add arithmetic functions to wheel speeds classes (#5465)
10d4f5b5df [wpimath] Clean up notation in DARE precondition docs (#5595)
b2dd59450b [hal] Fix unfinished/incorrect GetCPUTemp functions (#5598)
99f66b1e24 [wpimath] Replace frc/EigenCore.h typedefs with Eigen's where possible (#5597)
383289bc4b [build] Make custom CMake macros use lowercase (#5594)
45e7720ec1 [build] Add error message when downloading files in CMake (#5593)
4e0d785356 [wpimath] ChassisSpeeds: document that values aren't relative to the robot (NFC) (#5551)
3c04580a57 [commands] ProxyCommand: Use inner command name in unique_ptr constructor (#5570)
cf19102c4a [commands] SelectCommand: Fix leakage and multiple composition bug (#5571)
171375f440 [ntcoreffi] Link to NI libraries (#5589)
89add5d05b Disable flaky tests (#5591)
a8d4b162ab [ntcore] Remove RPC manual tests (#5590)
39a73b5b58 [commands] C++: Add CommandPtr supplier constructor to ProxyCommand (#5572)
36d514eae7 [commands] Refactor C++ ScheduleCommand to use SmallSet (#5568)
52297ffe29 [commands] Add idle command (#5555)
67043a8eeb [wpimath] Add angular jerk unit (#5582)
51b0fb1492 [wpimath] Fix incorrect header inclusion in angular_acceleration.h (#5587)
b7657a8e28 [wpimath] Split WPIMathJNI into logical chunks (#5552)
ea17f90f87 [build] Fix tool builds with multiple arm platforms installed (#5586)
f1d7b05723 [wpimath] Clean up unit formatter (#5584)
d7264ff597 Replace wpi::errs() usage with fmtlib (#5560)
ab3bf39e0e [wpiutil] Upgrade to fmt 10.1.1 (#5585)
165ebe4c79 Upgrade to fmt 10.1.0 (#5326)
8e2a7fd306 Include thirdparty libraries with angle brackets (#5578)
e322ab8e46 [wpimath] Fix docs for DARE ABQRN stabilizability check (NFC) (#5579)
360fb835f4 [upstream_utils] Handle edge case in filename matches (#5576)
9d86624c00 [build] Fix CMake configure warnings (#5577)
969979d6c7 [wpiutil] Update to foonathan memory 0.7-3 (#5573)
0d2d989e84 [wpimath] Update to gcem 1.17.0 (#5575)
cf86af7166 [wpiutil] Update to mpack 1.1.1 (#5574)
a0c029a35b [commands] Fix dangling SelectCommand documentation (NFC) (#5567)
349141b91b [upstream_utils] Document adding a patch (NFC) (#5432)
7889b35b67 [wpimath] Add RamseteController comparison to LTV controller docs (NFC) (#5559)
b3ef536677 [build] Ignore nt/sim json files in spotless (#5565)
ed895815b5 [build] Compile Java with UTF-8 encoding (#5564)
2e4ad35e36 [wpiutil] jni_util: Add JSpan and CriticalJSpan (#5554)
8f3d6a1d4b [wpimath] Remove discretizeAQTaylor() (#5562)
7c20fa1b18 [wpimath] Refactor DARE tests to reduce RAM usage at compile time (#5557)
89e738262c [ntcore] Limit buffer pool size to 64KB per connection (#5485)
96f7fa662e Upgrade Maven dependencies (#5553)
7a2d336d52 [wpinet] Leak multicast handles during windows shutdown (#5550)
f9e2757d8f [wpimath] Use JDoubleArrayRef in all JNI functions (#5546)
0cf6e37dc1 [wpimath] Make LTV controller constructors use faster DARE solver (#5543)
6953a303b3 [build] Fix the windows build with fmt (#5544)
7a37e3a496 [wpimath] Correct Rotation3d::RotateBy doc comment (NFC) (#5541)
186b409e16 [wpimath] Remove internal Eigen header include (#5539)
03764dfe93 [wpimath] Add static matrix support to DARE solver (#5536)
394cfeadbd [wpimath] Use SDA algorithm instead of SSCA for DARE solver (#5526)
a4b7fde767 [wpilib] Add mechanism specific SetState overloads to physics sims (#5534)
8121566258 [wpimath] Fix CoordinateSystem.convert() Transform3d overload (#5532)
b542e01a0b [glass] Fix array crash when clearing existing workspace (#5535)
e2e1b763b2 [wpigui] Fix PFD file dialogs not closing after window closing (#5530)
86d7bbc4e4 [examples] Add Java Examples and Templates for the XRP (#5529)
e8b5d44752 [wpimath] Make Java Quaternion use doubles instead of Vector (#5525)
38c198fa64 [myRobot] Add apriltags to myRobot build (#5528)
00450c3548 [wpimath] Upgrade to EJML 0.42 (#5531)
faf3cecd83 [wpimath] Don't copy Matrix and underlying storage in VecBuilder (#5524)
6b896a38dc [build] Don't enforce WITH_FLAT_INSTALL with MSVC (part 2) (#5517)
c01814b80e [wpiutil] Add C API for DataLog (#5509)
b5bd0771eb [wpimath] Document extrinsic vs intrinsic rotations (NFC) (#5508)
84ed8aec05 [build] Don't enforce WITH_FLAT_INSTALL with MSVC (#5515)
999f677d8c [ntcoreffi] Add WPI_Impl_SetupNowRio to exported symbols (#5510)
338f37d302 Fix header sorting of libssh (#5507)
75cbd9d6d0 [glass] Add background color selector to glass plots (#5506)
e2c190487b [examples] Add flywheel bang-bang controller example (#4071)
c52dad609e [wpinet] WebSocket: Send pong in response to ping (#5498)
e2d17a24a6 [hal] Expose power rail disable and cpu temp functionality (#5477)
3ad5d2e42d [hal,wpiutil] Use HMB for FPGA Timestamps (#5499)
b46a872494 [ntcore] Remove pImpl from implementation (#5480)
d8c59ccc71 [wpimath] Add tests for MathUtil clamp() and interpolate() (#5501)
0552c8621d [glass,ov] Improve Glass and OutlineViewer title bar message (#5502)
90e37a129f [wpiutil,wpimath] Add generic InterpolatingTreeMap (#5372)
d83a6edc20 [wpilib] Update GetMatchTime docs and units (#5232)
6db2c42966 [wpimath] Trajectory: Throw on empty lists of States (#5497)
21439b606c [wpimath] Disallow LTV controller max velocities above 15 m/s (#5495)
7496e0d208 [ntcore] Value: More efficiently store arrays (#5484)
0c93aded8a [wpimath] Change kinematics.ToTwist2d(end - start) to kinematics.ToTwist2d(start, end) (#5493)
815a8403e5 [wpimath] Give infeasible trajectory constraints a better exception message (#5492)
35a8b129d9 [wpimath] Add RotateBy() function to pose classes (#5491)
26d6e68c8f [upstream_utils] Add GCEM to CI (#5483)
6aa469ae45 [wpilib] Document how to create LinearSystem object for physics sim classes (NFC) (#5488)
a01b6467d3 [wpimath] Link to docs on LQR and KF tolerances (#5486)
d814f1d123 [wpimath] Fix copy-paste error from Pose2d docs (NFC) (#5490)
98f074b072 [wpimath] Add folder prefix to geometry includes (#5489)
e9858c10e9 [glass] Add tooltips for NT settings (#5476)
12dda24f06 [examples] Fix C robot template not correctly looping (#5474)
fc75d31755 [apriltag] Update apriltaglib (#5475)
a95994fff6 [wpiutil] timestamp: Call FPGA functions directly (#5235)
2ba8fbb6f4 [wpimath] Improve documentation for SwerveModulePosition::operator- (#5468)
b8cdf97621 [build] Prepare for Windows arm64 builds (#5390)
552f4b76b5 [wpimath] Add FOC-enabled Falcon constants to the DCMotor class (#5469)
1938251436 [examples] Add Feedforward to ElevatorProfiledPid (#5300)
873c2a6c10 [examples] Update ElevatorTrapezoidProfile example (#5466)
99b88be4f3 [wpilib] Reduce usage of NTSendable (#5434)
d125711023 [hal] Fix Java REVPH faults bitfield (take 2) (#5464)
c3fab7f1f2 [ntcore] Don't update timestamp when value is unchanged (#5356)
5ec7f18bdc [wpilib] EventLoop docs: Remove BooleanEvent references (NFC) (#5463)
c065ae1fcf [wpiunits] Add subproject for a Java typesafe unit system (#5371)
44acca7c00 [wpiutil] Add ClassPreloader (#5365)
88b11832ec [hal] Fix Java REVPH faults bitfield (#5148)
fb57d82e52 [ntcore] Enhance Java raw value support
3a6e40a44b [wpiutil] Enhance DataLog Java raw value support
8dae5af271 [wpiutil] Add compile-time string utilities (ct_string) (#5462)
fc56f8049a [wpilib] DriverStation: Change alliance station to use optional (#5229)
ef155438bd [build] Consume libuv via cmake config instead of via pkg-config (#5438)
86e91e6724 [wpimath] Refactor TrapezoidProfile API (#5457)
72a4543493 [wpilib] DutyCycleEncoderSim: Expand API (#5443)
657338715d [wpimath] Add ChassisSpeeds method to fix drifting during compound swerve drive maneuvers (#5425)
1af224c21b Add missing <functional> includes (#5459)
0b91ca6d5a [wpilib] SendableChooser: Add onChange listener (#5458)
6f7cdd460e [wpimath] Pose3d: Switch to JNI for exp and log (#5444)
c69e34c80c [wpimath] ChassisSpeeds: Add arithmetic functions (#5293)
335e7dd89d [wpilib] Simulation: Add ctor parameter to set starting state of mechanism sims (#5288)
14f30752ab [wpilib] Deprecate Accelerometer and Gyro interfaces (#5445)
70b60e3a74 [commands] Trigger: Fix method names in requireNonNullParam (#5454)
593767c8c7 [wpimath] Improve Euler angle calculations in gimbal lock (#5437)
daf022d3da [build] Make devImplementation inherit from implementation (#5450)
9b8d90b852 [examples] Convert the unitless joystick inputs to actual physical units (#5451)
1f6428ab63 [ntcore] Fix undefined comparison behavior when array is empty (#5448)
17eb9161cd Update code owners for removal of old commands (#5447)
3c4b58ae1e [wpinet] Upgrade to libuv 1.46.0 (#5446)
aaea85ff16 [commands] Merge CommandBase into Command and SubsystemBase into Subsystem (#5392)
7ac932996a [ci] Use PAT for workflow dispatch (#5442)
efe1987e8b [ci] Trigger pages repo workflow (#5441)
828bc5276f [wpiutil] Upgrade to LLVM 16.0.6 (#5435)
701df9eb87 [ci] Change documentation publish to single-commit (#5440)
e5452e3f69 [wpiutil] Add WPICleaner and an example how to use it (#4850)
7a099cb02a [commands] Remove deprecated classes and functions (#5409)
b250a03944 [wpilib] Add function to wait for DS Connection (#5230)
a6463ed761 [wpiutil] Fix unused variable warning in release build (#5430)
f031513470 [ntcore] NetworkTable::GetSubTables(): Remove duplicates (#5076)
f8e74e2f7c [hal] Unify PWM simulation Speed, Position, and Raw (#5277)
fd5699b240 Remove references to Drake (#5427)
e2d385d80a [build] cmake: Respect USE_SYSTEM_FMTLIB (#5429)
d37f990ce3 [hal] Fix HAL Relay/Main doc module (NFC) (#5422)
a7a8b874ac [docs] Expand HAL_ENUM in doxygen docs (#5421)
3a61deedde [wpimath] Rotation2d: Only use gcem::hypot when constexpr evaluated (#5419)
96145de7db [examples] Fix formatting (NFC) (#5420)
fffe6a7b9a [examples] Improve Pneumatics example coverage in Solenoid and RapidReactCmdBot examples (#4998)
6b5817836d [wpimath] Add tolerance for some tests (#5416)
3233883f3e [cscore] Fix warnings on macos arm (#5415)
c4fc21838f [commands] Add ConditionalCommand getInterruptionBehavior (#5161)
89fc51f0d4 Add tests for SendableChooser and Command Sendable functionality (#5179)
663bf25aaf [docs] Generate docs for symbols in __cplusplus (#5412)
fe32127ea8 [command] Clean up Command doc comments (NFC) (#5321)
c1a01569b4 [wpilib][hal] PWM Raw using microseconds (#5283)
1fca519fb4 [wpiutil] Remove remnants of ghc fs and tcb_span libraries (#5411)
90602cc135 [github] Update issue template to collect more project info (#5090)
34412ac57e [build] Exclude files in bin from Spotless (#5410)
61aa60f0e3 [wpilib] Add robot callback that is called when the DS is initially connected (#5231)
ebae341a91 [commands] Add test for subsystem registration and periodic (#5408)
5d3a133f9f Remove spaces in NOLINT comments (#5407)
3a0e484691 [wpimath] Fix clang-tidy warnings (#5403)
eb3810c765 [wpiutil] Fix clang-tidy warnings (#5406)
c4dc697192 [hal] WS Simulation: Add message filtering capability (#5395)
0eccc3f247 [ntcore] Fix clang-tidy warnings (#5405)
f4dda4bac0 [hal] Add javadocs for JNI (NFC) (#5298)
1c20c69793 [cscore] Fix clang-tidy warnings (#5404)
1501607e48 [commands] Fix clang-tidy warnings (#5402)
991f4b0f62 [wpimath] PIDController: Add IZone (#5315)
f5b0d1484b [wpimath] Add isNear method to MathUtil (#5353)
2ce248f66c [hal] Fix clang-tidy warnings (#5401)
5fc4aee2d2 [wpimath] SwerveDriveKinematics: Rename currentChassisSpeed to desiredChassisSpeed (#5393)
50b90ceb54 [wpimath] SwerveDriveKinematics: Add reset method (#5398)
316cd2a453 [commands] Notify DriverStationSim in CommandTestBaseWithParam (#5400)
d4ea5fa902 [cscore] VideoMode: Add equals override (Java) (#5397)
d6bd72d738 [wpimath] ProfiledPIDController: Add getConstraints (#5399)
25ad5017a9 [wpimath] Refactor kinematics, odometry, and pose estimator (#5355)
5c2addda0f [doc] Add missing pneumatics docs (NFC) (#5389)
c3e04a6ea2 Fix loading tests on macos 12 (#5388)
d5ed9fb859 [wpimath] Create separate archive with just units headers (#5383)
901ab693d4 [wpimath] Use UtilityClassTest for more utility classes (#5384)
9d53231b01 [wpilib] DataLogManager: Add warning for low storage space (#5364)
d466933963 [wpiutil] Group doxygen into MPack module (#5380)
652d1c44e3 [wpiutil] Upgrade to macOS 12 to remove concept shims (#5379)
6414be0e5d [wpimath] Group units doxygen modules (#5382)
7ab5800487 [wpiutil] Fix docs typo in SmallVector (#5381)
59905ea721 Replace WPI_DEPRECATED() macro with [[deprecated]] attribute (#5373)
753cb49a5e [ntcore] Fix doxygen module in generated C types (NFC) (#5374)
1c00a52b67 [hal] Expose CAN timestamp base clock (#5357)
91cbcea841 Replace SFINAE with concepts (#5361)
d57d1a4598 [wpimath] Remove unnecessary template argument from unit formatter (#5367)
5acc5e22aa [wpimath] Only compute eigenvalues with EigenSolvers (#5369)
d3c9316a97 extend shuffleboard test timeout (#5377)
1ea868081a [ci] Fix /format command (#5376)
5fac18ff4a Update formatting to clang-format 16 (#5370)
a94a998002 [wpimath] Generalize Eigen formatter (#5360)
125f6ea101 [wpimath] Make SwerveDriveKinematics::ToChassisSpeeds() take const-ref argument (#5363)
51066a5a8a [wpimath] Move unit formatters into units library (#5358)
282c032b60 [wpilibc] Add unit-aware Joystick.GetDirection() (#5319)
073d19cb69 [build] Fix CMake warning (#5359)
01490fc77b [wpiutil] DataLog: Add documentation for append methods (NFC) (#5348)
c9b612c986 [wpilibcExamples] Make C++ state-space elevator KF and LQR match Java (#5346)
eed1e6e3cb [wpimath] Replace DiscretizeAQTaylor() with DiscretizeAQ() (#5344)
c976f40364 [readme] Document how to run examples in simulation (#5340)
4d28bdc19e [ci] Update Github Pages deploy action parameters (#5343)
e0f851871f [ci] Fix github pages deploy version (#5342)
063c8cbedc Run wpiformat (NFC) (#5341)
96e41c0447 [ci] Update deploy and sshagent actions (#5338)
fd294bdd71 [build] Fix compilation with GCC 13 (#5322)
d223e4040b [dlt] Add delete without download functionality (#5329)
abc19bcb43 [upstream_utils] Zero out commit hashes and show 40 digits in index hashes (#5336)
e909f2e687 [build] Update gradle cache repo name (#5334)
52bd5b972d [wpimath] Rewrite DARE solver (#5328)
3876a2523a [wpimath] Remove unused MatrixImpl() function (#5330)
c82fcb1975 [wpiutil] Add reflection based cleanup helper (#4919)
15ba95df7e [wpiutil] Use std::filesystem (#4941)
77c2124fc5 [wpimath] Remove Eigen's custom STL types (#4945)
27fb47ab10 [glass] Field2D: Embed standard field images (#5159)
102e4f2566 [wpilib] Remove deprecated and broken SPI methods (#5249)
463a90f1df [wpilib, hal] Add function to read the RSL state (#5312)
7a90475eec [wpilib] Update RobotBase documentation (NFC) (#5320)
218cfea16b [wpilib] DutyCycleEncoder: Fix reset behavior (#5287)
91392823ff [build] Update to gradle 8.1 (#5303)
258b7cc48b [wpilibj] Filesystem.getDeployDirectory(): Strip JNI path from user.dir (#5317)
26cc43bee1 [wpilib] Add documentation to SPI mode enum (NFC) (#5324)
ac4da9b1cb [hal] Add HAL docs for Addressable LED (NFC) (#5304)
21d4244cf7 [wpimath] Fix DCMotor docs (NFC) (#5309)
1dff81bea7 [hal] Miscellaneous HAL doc fixes (NFC) (#5306)
7ce75574bf [wpimath] Upgrade to Drake v1.15.0 (#5310)
576bd646ae [hal] Add CANManufacturer for Redux Robotics (#5305)
ee3b4621e5 [commands] Add onlyWhile and onlyIf (#5291)
40ca094686 [commands] Fix RepeatCommand calling end() twice (#5261)
9cbeb841f5 [rtns] Match imaging tool capitalization (#5265)
a63d06ff77 [examples] Add constants to java gearsbot example (#5248)
b6c43322a3 [wpilibc] XboxController: Add return tag to docs (NFC) (#5246)
5162d0001c [hal] Fix and document addressable LED timings (#5272)
90fabe9651 [wpilibj] Use method references in drive class initSendable() (#5251)
24828afd11 [wpimath] Fix desaturateWheelSpeeds to account for negative speeds (#5269)
e099948a77 [wpimath] Clean up rank notation in docs (NFC) (#5274)
fd2d8cb9c1 [hal] Use std::log2() for base-2 logarithm (#5278)
ba8c64bcff [wpimath] Fix misspelled Javadoc parameters in pose estimators (NFC) (#5292)
f53c6813d5 [wpimath] Patch Eigen warnings (#5290)
663703d370 [gitattributes] Mark json files as lf text files (#5256)
aa34aacf6e [wpilib] Shuffleboard: Keep duplicates on SelectTab() (#5198)
63512bbbb8 [wpimath] Fix potential divide-by-zero in RKDP (#5242)
9227b2166e [wpilibj] DriverStation: Fix joystick data logs (#5240)
fbf92e9190 [wpinet] ParallelTcpConnector: don't connect to duplicate addresses (#5169)
2108a61362 [ntcore] NT4 client: close timed-out connections (#5175)
0a66479693 [ntcore] Optimize scan of outgoing messages (#5227)
b510c17ef6 [hal] Fix RobotController.getComments() mishandling quotes inside the comments string (#5197)
e7a7eb2e93 [commands] WaitCommand: Remove subclass doc note (NFC) (#5200)
a465f2d8f0 [examples] Shuffleboard: Correct parameter order (#5204)
a3364422fa LICENSE.md: Bump year to 2023 (#5195)
df3242a40a [wpimath] Fix NaN in C++ MakeCostMatrix() that takes an array (#5194)
00abb8c1e0 [commands] RamseteCommand: default-initialize m_prevSpeeds (#5188)
c886273fd7 [wpilibj] DutyCycleEncoder.setDistancePerRotation(): fix simulation (#5147)
53b5fd2ace [ntcore] Use int64 for datalog type string (#5186)
56b758320f [wpilib] DataLogManager: increase time for datetime to be valid (#5185)
08f298e4cd [wpimath] Fix Pose3d log returning Twist3d NaN for theta between 1E-8 and 1E-7 (#5168)
6d0c5b19db [commands] CommandScheduler.isComposed: Remove incorrect throws clause (NFC) (#5183)
0d22cf5ff7 [wpilib] Fix enableLiveWindowInTest crashing in disabled (#5173)
32ec5b3f75 [wpilib] Add isTestEnabled and minor docs cleanup (#5172)
e5c4c6b1a7 [wpimath] Fix invalid iterator access in TimeInterpolatableBuffer (#5138)
099d048d9e [wpimath] Fix Pose3d log returning Twist3d NaN for theta between 1E-9 and 1E-8 (#5143)
4af84a1c12 Fix Typos (NFC) (#5137)
ce3686b80d [wpimath] Check LTV controller max velocity precondition (#5142)
4b0eecaee0 [commands] Subsystem: Add default command removal method (#5064)
edf4ded412 [wpilib] PH: Revert to 5V rail being fixed 5V (#5122)
4c46b6aff9 [wpilibc] Fix DataLogManager crash on exit in sim (#5125)
490ca4a68a [wpilibc] Fix XboxController::GetBackButton doc (NFC) (#5131)
cbb5b0b802 [hal] Simulation: Fix REV PH solenoids 8+ (#5132)
bb7053d9ee [hal] Fix HAL_GetRuntimeType being slow on the roboRIO (#5130)
9efed9a533 Update .clang-format to c++20 (#5121)
dbbfe1aed2 [wpilib] Use PH voltage to calc Analog pressure switch threshold (#5115)
de65a135c3 [wpilib] DutyCycleEncoderSim: Add channel number constructor (#5118)
3e9788cdff [docs] Strip path from generated NT docs (#5119)
ecb072724d [ntcore] Client::Disconnect(): actually close connection (#5113)
0d462a4561 [glass] NT view: Change string/string array to quoted (#5111)
ba37986561 [ntcore] NetworkClient::Disconnect: Add null check (#5112)
25ab9cda92 [glass,ov] Provide menu item to create topic from root (#5110)
2f6251d4a6 [glass] Set default value when publishing new topic (#5109)
e9a7bed988 [wpimath] Add timestamp getter to MathShared (#5091)
9cc14bbb43 [ntcore] Add stress test to dev executable (#5107)
8068369542 [wpinet] uv: Stop creating handles when closing loop (#5102)
805c837a42 [ntcore] Fix use-after-free in server (#5101)
fd18577ba0 [commands] Improve documentation of addRequirements (NFC) (#5103)
74dea9f05e [wpimath] Fix exception for empty pose buffer in pose estimators (#5106)
9eef79d638 [wpilib] PneumaticHub: Document range of enableCompressorAnalog (NFC) (#5099)
843574a810 [ntcore] Use wpi::Now instead of loop time for transmit time
226ef35212 [wpinet] WebSocket: Reduce server send frame overhead
b30664d630 [ntcore] Reduce initial connection overhead
804e5ce236 [examples] MecanumDrive: Fix axis comment in C++ example (NFC) (#5096)
49af88f2bb [examples] ArmSimulation: Fix flaky test (#5093)
d56314f866 [wpiutil] Disable mock time on the Rio (#5092)
43975ac7cc [examples] ArmSimulation, ElevatorSimulation: Extract mechanism to class (#5052)
5483464158 [examples, templates] Improve descriptions (NFC) (#5051)
785e7dd85c [wpilibc] SendableChooser: static_assert copy- and default-constructibility (#5078)
e57ded8c39 [ntcore] Improve disconnect error reporting (#5085)
01f0394419 [wpinet] Revert WebSocket: When Close() is called, call closed immediately (#5084)
59be120982 [wpimath] Fix Pose3d exp()/log() and add rotation vector constructor to Rotation3d (#5072)
37f065032f [wpilib] Refactor TimedRobot tests (#5068)
22a170bee7 [wpilib] Add Notifier test (#5070)
2f310a748c [wpimath] Fix DCMotor.getSpeed() (#5061)
b43ec87f57 [wpilib] ElevatorSim: Fix WouldHitLimit methods (#5057)
19267bef0c [ntcore] Output warning on property set on unpublished topic (#5059)
84cbd48d84 [ntcore] Handle excludeSelf on SetDefault (#5058)
1f35750865 [cameraserver] Add GetInstance() to all functions (#5054)
8230fc631d [wpilib] Revert throw on nonexistent SimDevice name in SimDeviceSim (#5053)
b879a6f8c6 [wpinet] WebSocket: When Close() is called, call closed immediately (#5047)
49459d3e45 [ntcore] Change wire timeout to fixed 1 second (#5048)
4079eabe9b [wpimath] Discard stale pose estimates (#5045)
fe5d226a19 [glass] Fix option for debug-level NT logging (#5049)
b7535252c2 [ntcore] Don't leak buffers in rare WS shutdown case (#5046)
b61ac6db33 [ntcore] Add client disconnect function (#5022)
7b828ce84f [wpimath] Add nearest to Pose2d and Translation2d (#4882)
08a536291b [examples] Improvements to Elevator Simulation Example (#4937)
193a10d020 [wpigui] Limit frame rate to 120 fps by default (#5030)
7867bbde0e [wpilib] Clarify DS functions provided by FMS (NFC) (#5043)
fa7c01b598 [glass] Add option for debug-level NT logging (#5007)
2b81610248 [wpiutil] Add msgpack to datalog Python example (#5032)
a4a369b8da CONTRIBUTING.md: Add unicodeit CLI to math docs guidelines (#5031)
d991f6e435 [wpilib] Throw on nonexistent SimDevice name in SimDeviceSim constructor (#5041)
a27a047ae8 [hal] Check for null in getSimDeviceName JNI (#5038)
2f96cae31a [examples] Hatchbots: Add telemetry (#5011)
83ef8f9658 [simulation] GUI: Fix buffer overflow in joystick axes copy (#5036)
4054893669 [commands] Fix C++ Select() factory (#5024)
f75acd11ce [commands] Use Timer.restart() (#5023)
8bf67b1b33 [wpimath] PIDController::Calculate(double, double): update setpoint flag (#5021)
49bb1358d8 [wpiutil] MemoryBuffer: Fix GetMemoryBufferForStream (#5017)
9c4c07c0f9 [wpiutil] Remove NDEBUG check for debug-level logging (#5018)
1a47cc2e86 [ntcore] Use full handle when subscribing (#5013)
7cd30cffbc Ignore networktables.json (#5006)
92aecab2ef [commands] Command controllers are not subclasses (NFC) (#5000)
8785bba080 [ntcore] Special-case default timestamps (#5003)
9e5b7b8040 [ntcore] Handle topicsonly followed by value subscribe (#4991)
917906530a [wpilib] Add Timer::Restart() (#4963)
00aa66e4fd [wpimath] Remove extraneous assignments from DiscretizeAB() (#4967)
893320544a [examples] C++ RamseteCommand: Fix units (#4954)
b95d0e060d [wpilib] XboxController: Fix docs discrepancy (NFC) (#4993)
008232b43c [ntcore] Write empty persistent file if none found (#4996)
522be348f4 [examples] Rewrite tags (NFC) (#4961)
d48a83dee2 [wpimath] Update Wikipedia links for quaternion to Euler angle conversion (NFC) (#4995)
504fa22143 [wpimath] Workaround intellisense Eigen issue (#4992)
b2b25bf09f [commands] Fix docs inconsistency for toggleOnFalse(Command) (NFC) (#4978)
ce3dc4eb3b [hal] Properly use control word that is in sync with DS data (#4989)
1ea48caa7d [wpilib] Fix C++ ADXRS450 and Java SPI gyro defs (#4988)
fb101925a7 [build] Include wpimathjni in commands binaries (#4981)
657951f6dd [starter] Add a process starter for use by the installer for launching tools (#4931)
a60ca9d71c [examples] Update AprilTag field load API usage (#4975)
f8a45f1558 [wpimath] Remove print statements from tests (#4977)
ecba8b99a8 [examples] Fix swapped arguments in MecanumControllerCommand example (#4976)
e95e88fdf9 [examples] Add comment to drivedistanceoffboard example (#4877)
371d15dec3 [examples] Add Computer Vision Pose Estimation and Latency Compensation Example (#4901)
cb9b8938af [sim] Enable docking in the GUI (#4960)
3b084ecbe0 [apriltag] AprilTagFieldLayout: Improve API shape for loading builtin JSONs (#4949)
27ba096ea1 [wpilib] Fix MOI calculation error in SingleJointedArmSim (#4968)
42c997a3c4 [wpimath] Fix Pose3d exponential and clean up Pose3d logarithm (#4970)
5f1a025f27 [wpilibj] Fix typo in MecanumDrive docs (NFC) (#4969)
0ebf79b54c [wpimath] Fix typo in Pose3d::Exp() docs (NFC) (#4966)
a8c465f3fb [wpimath] HolonomicDriveController: Add getters for the controllers (#4948)
a7b1ab683d [wpilibc] Add unit test for fast deconstruction of GenericHID (#4953)
bd6479dc29 [build] Add Spotless for JSON (#4956)
5cb0340a8c [hal, wpilib] Load joystick values upon code initialization (#4950)
ab0e8c37a7 [readme] Update build requirements (NFC) (#4947)
b74ac1c645 [build] Add apriltag to C++ cmake example builds (#4944)
cf1a411acf [examples] Add example programs for AprilTags detection (#4932)
1e05b21ab5 [wpimath] Fix PID atSetpoint to not return true prematurely (#4906)
e5a6197633 [wpimath] Fix SwerveDriveKinematics not initializing a new array each time (#4942)
039edcc23f [ntcore] Queue current value on subscriber creation (#4938)
f7f19207e0 [wpimath] Allow multiple vision measurements from same timestamp (#4917)
befd12911c [commands] Delete UB-causing rvalue variants of CommandPtr methods (#4923)
34519de60a [commands] Fix spacing in command composition exception (#4924)
dc4355c031 [hal] Add handle constructor and name getters for sim devices (#4925)
53d8d33bca [hal, wpilibj] Add missing distance per pulse functions to EncoderSim (#4928)
530ae40614 [apriltag] Explain what April tag poses represent (NFC) (#4930)
79f565191e [examples] DigitalCommunication, I2CCommunication: Add tests (#4865)
2cd9be413f [wpilib, examples] Cleanup PotentiometerPID, Ultrasonic, UltrasonicPID examples (#4893)
babb0c1fcf [apriltag] Add 2023 field layout JSON (#4912)
330ba45f9c [wpimath] Fix swerve kinematics util classes equals function (#4907)
51272ef6b3 [fieldImages] Add 2023 field (#4915)
0d105ab771 [commands] Deduplicate command test utils (#4897)
cf4235ea36 [wpiutil] Guard MSVC pragma in SymbolExports.h (#4911)
2d4b7b9147 [build] Update opencv version in opencv.gradle (#4909)
aec6f3d506 [ntcore] Fix client flush behavior (#4903)
bfe346c76a [build] Fix cmake java resources (#4898)

Change-Id: Ia1dd90fe42c6cd5df281b8a5b710e136f54355f4
git-subtree-dir: third_party/allwpilib
git-subtree-split: f1a82828fed8950f9a3f1586c44327027627a0c8
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/upstream_utils/README.md b/upstream_utils/README.md
index 587fc9e..979dd0d 100644
--- a/upstream_utils/README.md
+++ b/upstream_utils/README.md
@@ -11,10 +11,9 @@
 
 `upstream_utils.py` contains utilities common to these update scripts.
 
-Patches are generated in the thirdparty repo with
-`git format-patch --no-signature` so they can be applied as individual commits
-and easily rebased onto newer versions. Each library has its own patch directory
-(e.g., `lib_patches`).
+Patches are generated in the thirdparty repo with git's format-patch command so
+they can be applied as individual commits and easily rebased onto newer
+versions. Each library has its own patch directory (e.g., `lib_patches`).
 
 ## Updating thirdparty library version
 
@@ -23,7 +22,7 @@
 
 Start in the `upstream_utils` folder. Restore the original repo.
 ```bash
-./update_lib.py
+./update_<lib>.py
 ```
 
 Navigate to the repo.
@@ -40,14 +39,23 @@
 git fetch --depth 1 origin tag 2.0
 ```
 
-Rebase any patches onto the new version.
+Rebase any patches onto the new version. If the old version and new version are
+on the same branch, run the following.
 ```bash
 git rebase 2.0
 ```
 
+If the old version and new version are on different branches (e.g.,
+llvm-project), use interactive rebase instead and remove commits that are common
+between the two branches from the list of commits to rebase. In other words,
+only commits representing downstream patches should be listed.
+```bash
+git rebase -i 2.0
+```
+
 Generate patch files for the new version.
 ```bash
-git format-patch 2.0..HEAD
+git format-patch 2.0..HEAD --zero-commit --abbrev=40 --no-signature
 ```
 
 Move the patch files to `upstream_utils`.
@@ -55,13 +63,57 @@
 mv *.patch allwpilib/upstream_utils/lib_patches
 ```
 
-Navigate back to `upstream_utils`
+Navigate back to `upstream_utils`.
 ```bash
 cd allwpilib/upstream_utils
 ```
 
 Modify the version number in the call to `setup_upstream_repo()` in
-`update_lib.py`, then  rerun `update_lib.py` to reimport the thirdparty files.
+`update_<lib>.py`, then rerun `update_<lib>.py` to reimport the thirdparty
+files.
 ```bash
-./update_lib.py
+./update_<lib>.py
+```
+
+## Adding patch to thirdparty library
+
+The example below will add a new patch file to a hypothetical library called
+`lib` (Replace `<lib>` with `llvm`, `fmt`, `eigen`, ... in the following steps).
+
+Start in the `upstream_utils` folder. Restore the original repo.
+```bash
+./update_<lib>.py
+```
+
+Navigate to the repo.
+```bash
+cd /tmp/<lib>
+```
+
+Make a commit with the desired changes.
+```bash
+git add ...
+git commit -m "..."
+```
+
+Generate patch files.
+```bash
+git format-patch 2.0..HEAD --zero-commit --abbrev=40 --no-signature
+```
+where `2.0` is replaced with the version specified in `update_<lib>.py`.
+
+Move the patch files to `upstream_utils`.
+```
+mv *.patch allwpilib/upstream_utils/<lib>_patches
+```
+
+Navigate back to `upstream_utils`.
+```bash
+cd allwpilib/upstream_utils
+```
+
+Update the list of patch files in `update_<lib>.py`, then rerun
+`update_<lib>.py` to reimport the thirdparty files.
+```bash
+./update_<lib>.py
 ```
diff --git a/upstream_utils/drake_patches/0001-Replace-Eigen-Dense-with-Eigen-Core.patch b/upstream_utils/drake_patches/0001-Replace-Eigen-Dense-with-Eigen-Core.patch
deleted file mode 100644
index dcd2e8f..0000000
--- a/upstream_utils/drake_patches/0001-Replace-Eigen-Dense-with-Eigen-Core.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From 02d023c7cdfdfb72ccdbccbac0883b4a1f6ec6d5 Mon Sep 17 00:00:00 2001
-From: Tyler Veness <calcmogul@gmail.com>
-Date: Wed, 18 May 2022 11:13:21 -0700
-Subject: [PATCH 1/2] Replace <Eigen/Dense> with <Eigen/Core>
-
----
- common/is_approx_equal_abstol.h                       | 2 +-
- common/test_utilities/eigen_matrix_compare.h          | 2 +-
- math/discrete_algebraic_riccati_equation.cc           | 3 +++
- math/discrete_algebraic_riccati_equation.h            | 2 +-
- math/test/discrete_algebraic_riccati_equation_test.cc | 1 +
- 5 files changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/common/is_approx_equal_abstol.h b/common/is_approx_equal_abstol.h
-index 9af0c45..b3f369c 100644
---- a/common/is_approx_equal_abstol.h
-+++ b/common/is_approx_equal_abstol.h
-@@ -2,7 +2,7 @@
- 
- #include <vector>
- 
--#include <Eigen/Dense>
-+#include <Eigen/Core>
- 
- namespace drake {
- 
-diff --git a/common/test_utilities/eigen_matrix_compare.h b/common/test_utilities/eigen_matrix_compare.h
-index a595da9..c22567d 100644
---- a/common/test_utilities/eigen_matrix_compare.h
-+++ b/common/test_utilities/eigen_matrix_compare.h
-@@ -4,7 +4,7 @@
- #include <cmath>
- #include <limits>
- 
--#include <Eigen/Dense>
-+#include <Eigen/Core>
- #include <gtest/gtest.h>
- 
- #include "drake/common/text_logging.h"
-diff --git a/math/discrete_algebraic_riccati_equation.cc b/math/discrete_algebraic_riccati_equation.cc
-index 901f2ef..20ea2b7 100644
---- a/math/discrete_algebraic_riccati_equation.cc
-+++ b/math/discrete_algebraic_riccati_equation.cc
-@@ -1,5 +1,8 @@
- #include "drake/math/discrete_algebraic_riccati_equation.h"
- 
-+#include <Eigen/Eigenvalues>
-+#include <Eigen/QR>
-+
- #include "drake/common/drake_assert.h"
- #include "drake/common/drake_throw.h"
- #include "drake/common/is_approx_equal_abstol.h"
-diff --git a/math/discrete_algebraic_riccati_equation.h b/math/discrete_algebraic_riccati_equation.h
-index 891373f..df7a58b 100644
---- a/math/discrete_algebraic_riccati_equation.h
-+++ b/math/discrete_algebraic_riccati_equation.h
-@@ -3,7 +3,7 @@
- #include <cmath>
- #include <cstdlib>
- 
--#include <Eigen/Dense>
-+#include <Eigen/Core>
- 
- namespace drake {
- namespace math {
-diff --git a/math/test/discrete_algebraic_riccati_equation_test.cc b/math/test/discrete_algebraic_riccati_equation_test.cc
-index 533ced1..e4ecfd2 100644
---- a/math/test/discrete_algebraic_riccati_equation_test.cc
-+++ b/math/test/discrete_algebraic_riccati_equation_test.cc
-@@ -1,5 +1,6 @@
- #include "drake/math/discrete_algebraic_riccati_equation.h"
- 
-+#include <Eigen/Eigenvalues>
- #include <gtest/gtest.h>
- 
- #include "drake/common/test_utilities/eigen_matrix_compare.h"
diff --git a/upstream_utils/drake_patches/0002-Add-WPILIB_DLLEXPORT-to-DARE-function-declarations.patch b/upstream_utils/drake_patches/0002-Add-WPILIB_DLLEXPORT-to-DARE-function-declarations.patch
deleted file mode 100644
index 1c7b469..0000000
--- a/upstream_utils/drake_patches/0002-Add-WPILIB_DLLEXPORT-to-DARE-function-declarations.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From b208372a18b37f6cbc49dd45d15adf63c9b60755 Mon Sep 17 00:00:00 2001
-From: Tyler Veness <calcmogul@gmail.com>
-Date: Wed, 18 May 2022 11:15:27 -0700
-Subject: [PATCH 2/2] Add WPILIB_DLLEXPORT to DARE function declarations
-
----
- math/discrete_algebraic_riccati_equation.h | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/math/discrete_algebraic_riccati_equation.h b/math/discrete_algebraic_riccati_equation.h
-index df7a58b..55b8442 100644
---- a/math/discrete_algebraic_riccati_equation.h
-+++ b/math/discrete_algebraic_riccati_equation.h
-@@ -4,6 +4,7 @@
- #include <cstdlib>
- 
- #include <Eigen/Core>
-+#include <wpi/SymbolExports.h>
- 
- namespace drake {
- namespace math {
-@@ -21,6 +22,7 @@ Based on the Schur Vector approach outlined in this paper:
- "On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation"
- by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell
- */
-+WPILIB_DLLEXPORT
- Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
-     const Eigen::Ref<const Eigen::MatrixXd>& A,
-     const Eigen::Ref<const Eigen::MatrixXd>& B,
-@@ -71,6 +73,7 @@ J = Σ [uₖ] [0 R][uₖ] ΔT
- @throws std::runtime_error if Q − NR⁻¹Nᵀ is not positive semi-definite.
- @throws std::runtime_error if R is not positive definite.
- */
-+WPILIB_DLLEXPORT
- Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
-     const Eigen::Ref<const Eigen::MatrixXd>& A,
-     const Eigen::Ref<const Eigen::MatrixXd>& B,
diff --git a/upstream_utils/eigen_patches/0001-Disable-warnings.patch b/upstream_utils/eigen_patches/0001-Disable-warnings.patch
index 78a5922..e89fec5 100644
--- a/upstream_utils/eigen_patches/0001-Disable-warnings.patch
+++ b/upstream_utils/eigen_patches/0001-Disable-warnings.patch
@@ -1,14 +1,14 @@
-From 3bfc3d1e3cbc9d7032446cc4aa6246d1c7750901 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Tyler Veness <calcmogul@gmail.com>
 Date: Wed, 18 May 2022 09:14:24 -0700
-Subject: [PATCH] Disable warnings
+Subject: [PATCH 1/3] Disable warnings
 
 ---
  Eigen/src/Core/util/DisableStupidWarnings.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
 
 diff --git a/Eigen/src/Core/util/DisableStupidWarnings.h b/Eigen/src/Core/util/DisableStupidWarnings.h
-index fe0cfec..d973255 100755
+index fe0cfec0bc2461ac44abca8f3d05b468d3c60fd9..9a630e4ae692aee0277d60b3083c968d087920dd 100755
 --- a/Eigen/src/Core/util/DisableStupidWarnings.h
 +++ b/Eigen/src/Core/util/DisableStupidWarnings.h
 @@ -71,6 +71,17 @@
@@ -22,7 +22,7 @@
 +    // This warning is a false positive
 +    #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 +  #endif
-+  #if __GNUC__==12
++  #if __GNUC__>=12
 +    // This warning is a false positive
 +    #pragma GCC diagnostic ignored "-Warray-bounds"
 +  #endif
diff --git a/upstream_utils/eigen_patches/0002-Intellisense-fix.patch b/upstream_utils/eigen_patches/0002-Intellisense-fix.patch
new file mode 100644
index 0000000..ce4cdb6
--- /dev/null
+++ b/upstream_utils/eigen_patches/0002-Intellisense-fix.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Fri, 20 Jan 2023 23:41:56 -0800
+Subject: [PATCH 2/3] Intellisense fix
+
+---
+ Eigen/src/Core/util/Macros.h | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h
+index 986c3d44db94c8ba339792b6738c47cdd2c5acbc..81986b9447824c440e004f38a220393ef5a089c6 100644
+--- a/Eigen/src/Core/util/Macros.h
++++ b/Eigen/src/Core/util/Macros.h
+@@ -58,6 +58,16 @@
+ // Compiler identification, EIGEN_COMP_*
+ //------------------------------------------------------------------------------------------
+ 
++/// \internal Disable NEON features in Intellisense
++#if __INTELLISENSE__
++#ifdef __ARM_NEON
++#undef __ARM_NEON
++#endif
++#ifdef __ARM_NEON__
++#undef __ARM_NEON__
++#endif
++#endif
++
+ /// \internal EIGEN_COMP_GNUC set to 1 for all compilers compatible with GCC
+ #ifdef __GNUC__
+   #define EIGEN_COMP_GNUC (__GNUC__*10+__GNUC_MINOR__)
diff --git a/upstream_utils/eigen_patches/0003-Eigen-Sparse-fix-warnings-Wunused-but-set-variable.patch b/upstream_utils/eigen_patches/0003-Eigen-Sparse-fix-warnings-Wunused-but-set-variable.patch
new file mode 100644
index 0000000..d68f094
--- /dev/null
+++ b/upstream_utils/eigen_patches/0003-Eigen-Sparse-fix-warnings-Wunused-but-set-variable.patch
@@ -0,0 +1,65 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Laurent Rineau <laurent.rineau@cgal.org>
+Date: Tue, 11 Oct 2022 17:37:04 +0000
+Subject: [PATCH 3/3] Eigen/Sparse: fix warnings -Wunused-but-set-variable
+
+---
+ Eigen/src/SparseCore/TriangularSolver.h        | 4 ++--
+ Eigen/src/SparseLU/SparseLU_heap_relax_snode.h | 5 -----
+ 2 files changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/Eigen/src/SparseCore/TriangularSolver.h b/Eigen/src/SparseCore/TriangularSolver.h
+index f9c56ba79800e209dcf3f18ba37dbb8023488bca..7cb2c2665f0e24924da88f11c0fe3ca0c0af52e3 100644
+--- a/Eigen/src/SparseCore/TriangularSolver.h
++++ b/Eigen/src/SparseCore/TriangularSolver.h
+@@ -270,11 +270,11 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
+       }
+ 
+ 
+-      Index count = 0;
++//       Index count = 0;
+       // FIXME compute a reference value to filter zeros
+       for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector/*,1e-12*/); it; ++it)
+       {
+-        ++ count;
++//         ++ count;
+ //         std::cerr << "fill " << it.index() << ", " << col << "\n";
+ //         std::cout << it.value() << "  ";
+         // FIXME use insertBack
+diff --git a/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h b/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h
+index 6f75d500e5f831f414175ce46dbceffa0acd5539..7aecbcad8ed2703000d62cfd5d88d983c69a7423 100644
+--- a/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h
++++ b/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h
+@@ -75,8 +75,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
+   // Identify the relaxed supernodes by postorder traversal of the etree
+   Index snode_start; // beginning of a snode 
+   StorageIndex k;
+-  Index nsuper_et_post = 0; // Number of relaxed snodes in postordered etree 
+-  Index nsuper_et = 0; // Number of relaxed snodes in the original etree 
+   StorageIndex l; 
+   for (j = 0; j < n; )
+   {
+@@ -88,7 +86,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
+       parent = et(j);
+     }
+     // Found a supernode in postordered etree, j is the last column 
+-    ++nsuper_et_post;
+     k = StorageIndex(n);
+     for (Index i = snode_start; i <= j; ++i)
+       k = (std::min)(k, inv_post(i));
+@@ -97,7 +94,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
+     {
+       // This is also a supernode in the original etree
+       relax_end(k) = l; // Record last column 
+-      ++nsuper_et; 
+     }
+     else 
+     {
+@@ -107,7 +103,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
+         if (descendants(i) == 0) 
+         {
+           relax_end(l) = l;
+-          ++nsuper_et;
+         }
+       }
+     }
diff --git a/upstream_utils/fmt_patches/0001-Don-t-throw-on-write-failure.patch b/upstream_utils/fmt_patches/0001-Don-t-throw-on-write-failure.patch
index edaf575..5b05dbf 100644
--- a/upstream_utils/fmt_patches/0001-Don-t-throw-on-write-failure.patch
+++ b/upstream_utils/fmt_patches/0001-Don-t-throw-on-write-failure.patch
@@ -1,4 +1,4 @@
-From e685209746aabbbed0a9db54694b8ea1ca504163 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Tyler Veness <calcmogul@gmail.com>
 Date: Wed, 18 May 2022 10:21:49 -0700
 Subject: [PATCH 1/2] Don't throw on write failure
@@ -6,14 +6,14 @@
 ---
  include/fmt/format-inl.h | 4 +---
  include/fmt/xchar.h      | 3 +--
- src/os.cc                | 3 +--
- 3 files changed, 3 insertions(+), 7 deletions(-)
+ src/os.cc                | 4 +---
+ 3 files changed, 3 insertions(+), 8 deletions(-)
 
 diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h
-index 22b1ec8..abe4ff1 100644
+index dac2d437a41ab7b0b4e72895212b5a972ada73a9..af6ba74d618f29c77339e8a82906cccd26a2efa4 100644
 --- a/include/fmt/format-inl.h
 +++ b/include/fmt/format-inl.h
-@@ -79,9 +79,7 @@ FMT_FUNC void report_error(format_func func, int error_code,
+@@ -75,9 +75,7 @@ FMT_FUNC void report_error(format_func func, int error_code,
  // A wrapper around fwrite that throws on error.
  inline void fwrite_fully(const void* ptr, size_t size, size_t count,
                           FILE* stream) {
@@ -25,30 +25,31 @@
  
  #ifndef FMT_STATIC_THOUSANDS_SEPARATOR
 diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h
-index 3b5bc15..fc3c67f 100644
+index 625ec36922e9bcc44a76b3c40792cb08ede63813..0f79c1720a4c855bb7088381e93af08eae56d66c 100644
 --- a/include/fmt/xchar.h
 +++ b/include/fmt/xchar.h
-@@ -200,8 +200,7 @@ inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
-   wmemory_buffer buffer;
-   detail::vformat_to(buffer, fmt, args);
-   buffer.push_back(L'\0');
--  if (std::fputws(buffer.data(), f) == -1)
+@@ -220,8 +220,7 @@ inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
+   auto buf = wmemory_buffer();
+   detail::vformat_to(buf, fmt, args);
+   buf.push_back(L'\0');
+-  if (std::fputws(buf.data(), f) == -1)
 -    FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
-+  std::fputws(buffer.data(), f);
++  std::fputws(buf.data(), f);
  }
  
  inline void vprint(wstring_view fmt, wformat_args args) {
 diff --git a/src/os.cc b/src/os.cc
-index f388ead..2c49951 100644
+index bca410e945e0347d349e06179906a43b38b56a5c..d7ded50f9870a885d1ce1835fecc4f740858127a 100644
 --- a/src/os.cc
 +++ b/src/os.cc
-@@ -277,8 +277,7 @@ std::size_t file::read(void* buffer, std::size_t count) {
- std::size_t file::write(const void* buffer, std::size_t count) {
+@@ -258,9 +258,7 @@ long long file::size() const {
+ std::size_t file::read(void* buffer, std::size_t count) {
    rwresult result = 0;
-   FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));
--  if (result < 0) FMT_THROW(system_error(errno, "cannot write to file"));
+   FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count))));
+-  if (result < 0)
+-    FMT_THROW(system_error(errno, FMT_STRING("cannot read from file")));
 -  return detail::to_unsigned(result);
 +  return count;
  }
  
- file file::dup(int fd) {
+ std::size_t file::write(const void* buffer, std::size_t count) {
diff --git a/upstream_utils/fmt_patches/0002-Suppress-C-20-clang-tidy-warning-false-positive.patch b/upstream_utils/fmt_patches/0002-Suppress-C-20-clang-tidy-warning-false-positive.patch
deleted file mode 100644
index 7e25fc0..0000000
--- a/upstream_utils/fmt_patches/0002-Suppress-C-20-clang-tidy-warning-false-positive.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 1d8e07241d380d13383a6ff479f3895ef49ce514 Mon Sep 17 00:00:00 2001
-From: Tyler Veness <calcmogul@gmail.com>
-Date: Fri, 2 Sep 2022 15:12:54 -0700
-Subject: [PATCH 2/2] Suppress C++20 clang-tidy warning false positive
-
----
- include/fmt/core.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/include/fmt/core.h b/include/fmt/core.h
-index f6a37af..5c210bc 100644
---- a/include/fmt/core.h
-+++ b/include/fmt/core.h
-@@ -2952,7 +2952,7 @@ class format_string_checker {
-       basic_string_view<Char> format_str, ErrorHandler eh)
-       : context_(format_str, num_args, types_, eh),
-         parse_funcs_{&parse_format_specs<Args, parse_context_type>...},
--        types_{
-+        types_{  // NOLINT(clang-analyzer-optin.cplusplus.UninitializedObject)
-             mapped_type_constant<Args,
-                                  basic_format_context<Char*, Char>>::value...} {
-   }
diff --git a/upstream_utils/fmt_patches/0002-Suppress-warnings-we-can-t-fix.patch b/upstream_utils/fmt_patches/0002-Suppress-warnings-we-can-t-fix.patch
new file mode 100644
index 0000000..a3866e2
--- /dev/null
+++ b/upstream_utils/fmt_patches/0002-Suppress-warnings-we-can-t-fix.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Tue, 16 May 2023 13:49:18 -0700
+Subject: [PATCH 2/2] Suppress warnings we can't fix
+
+---
+ include/fmt/format.h | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/include/fmt/format.h b/include/fmt/format.h
+index e5bd8b110efe49e12a12b004ea246a4dba671a6f..f11be0d6d58f3d992d7d06adb3d9576f81ecfe11 100644
+--- a/include/fmt/format.h
++++ b/include/fmt/format.h
+@@ -1324,7 +1324,14 @@ inline auto equal2(const char* lhs, const char* rhs) -> bool {
+ template <typename Char>
+ FMT_CONSTEXPR20 FMT_INLINE void copy2(Char* dst, const char* src) {
+   if (!is_constant_evaluated() && sizeof(Char) == sizeof(char)) {
++#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1000
++#  pragma GCC diagnostic push
++#  pragma GCC diagnostic ignored "-Wstringop-overflow"
++#endif
+     memcpy(dst, src, 2);
++#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1000
++#  pragma GCC diagnostic pop
++#endif
+     return;
+   }
+   *dst++ = static_cast<Char>(*src++);
diff --git a/upstream_utils/json_patches/0001-Remove-version-from-namespace.patch b/upstream_utils/json_patches/0001-Remove-version-from-namespace.patch
new file mode 100644
index 0000000..64e3efc
--- /dev/null
+++ b/upstream_utils/json_patches/0001-Remove-version-from-namespace.patch
@@ -0,0 +1,75 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Fri, 8 Sep 2023 19:21:41 -0700
+Subject: [PATCH 1/4] Remove version from namespace
+
+---
+ include/nlohmann/detail/abi_macros.hpp | 45 ++------------------------
+ 1 file changed, 3 insertions(+), 42 deletions(-)
+
+diff --git a/include/nlohmann/detail/abi_macros.hpp b/include/nlohmann/detail/abi_macros.hpp
+index 0d3108d166602886d41b5f0fec1e56dd3dbe7e3c..ce9291306cdd9a9baeb8fbb77ca1dc33959e0d36 100644
+--- a/include/nlohmann/detail/abi_macros.hpp
++++ b/include/nlohmann/detail/abi_macros.hpp
+@@ -42,40 +42,6 @@
+     #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
+ #endif
+ 
+-#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
+-    #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
+-#endif
+-
+-// Construct the namespace ABI tags component
+-#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
+-#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
+-    NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
+-
+-#define NLOHMANN_JSON_ABI_TAGS                                       \
+-    NLOHMANN_JSON_ABI_TAGS_CONCAT(                                   \
+-            NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS,                       \
+-            NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
+-
+-// Construct the namespace version component
+-#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
+-    _v ## major ## _ ## minor ## _ ## patch
+-#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
+-    NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
+-
+-#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
+-#define NLOHMANN_JSON_NAMESPACE_VERSION
+-#else
+-#define NLOHMANN_JSON_NAMESPACE_VERSION                                 \
+-    NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
+-                                           NLOHMANN_JSON_VERSION_MINOR, \
+-                                           NLOHMANN_JSON_VERSION_PATCH)
+-#endif
+-
+-// Combine namespace components
+-#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
+-#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
+-    NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
+-
+ #ifndef NLOHMANN_JSON_NAMESPACE
+ #define NLOHMANN_JSON_NAMESPACE               \
+     nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
+@@ -84,17 +50,12 @@
+ #endif
+ 
+ #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
+-#define NLOHMANN_JSON_NAMESPACE_BEGIN                \
+-    namespace nlohmann                               \
+-    {                                                \
+-    inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
+-                NLOHMANN_JSON_ABI_TAGS,              \
+-                NLOHMANN_JSON_NAMESPACE_VERSION)     \
++#define NLOHMANN_JSON_NAMESPACE_BEGIN \
++    namespace nlohmann                \
+     {
+ #endif
+ 
+ #ifndef NLOHMANN_JSON_NAMESPACE_END
+-#define NLOHMANN_JSON_NAMESPACE_END                                     \
+-    }  /* namespace (inline namespace) NOLINT(readability/namespace) */ \
++#define NLOHMANN_JSON_NAMESPACE_END \
+     }  // namespace nlohmann
+ #endif
diff --git a/upstream_utils/json_patches/0002-Make-serializer-public.patch b/upstream_utils/json_patches/0002-Make-serializer-public.patch
new file mode 100644
index 0000000..cb6ad1c
--- /dev/null
+++ b/upstream_utils/json_patches/0002-Make-serializer-public.patch
@@ -0,0 +1,55 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Thu, 7 Sep 2023 22:02:27 -0700
+Subject: [PATCH 2/4] Make serializer public
+
+---
+ include/nlohmann/detail/output/serializer.hpp | 4 +++-
+ include/nlohmann/json.hpp                     | 3 +--
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp
+index 500fc55ec5e5895ead2b372a6fe79ae941d88d83..7674d134a4d9f230aa4e432294c19dac8dd366b1 100644
+--- a/include/nlohmann/detail/output/serializer.hpp
++++ b/include/nlohmann/detail/output/serializer.hpp
+@@ -373,7 +373,7 @@ class serializer
+         }
+     }
+ 
+-  JSON_PRIVATE_UNLESS_TESTED:
++  public:
+     /*!
+     @brief dump escaped string
+ 
+@@ -696,6 +696,7 @@ class serializer
+         return false;
+     }
+ 
++  public:
+     /*!
+     @brief dump an integer
+ 
+@@ -876,6 +877,7 @@ class serializer
+         }
+     }
+ 
++  private:
+     /*!
+     @brief check whether a string is UTF-8 encoded
+ 
+diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp
+index 18a7c875774527a2e08c5ab72e5564aa50381608..c462cade8a7167a00697f6f940be35c5609a283c 100644
+--- a/include/nlohmann/json.hpp
++++ b/include/nlohmann/json.hpp
+@@ -153,10 +153,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
+     using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
+     template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
+ 
+-  JSON_PRIVATE_UNLESS_TESTED:
++  public:
+     using serializer = ::nlohmann::detail::serializer<basic_json>;
+ 
+-  public:
+     using value_t = detail::value_t;
+     /// JSON Pointer, see @ref nlohmann::json_pointer
+     using json_pointer = ::nlohmann::json_pointer<StringType>;
diff --git a/upstream_utils/json_patches/0003-Make-dump_escaped-take-std-string_view.patch b/upstream_utils/json_patches/0003-Make-dump_escaped-take-std-string_view.patch
new file mode 100644
index 0000000..84ba3ea
--- /dev/null
+++ b/upstream_utils/json_patches/0003-Make-dump_escaped-take-std-string_view.patch
@@ -0,0 +1,22 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Fri, 8 Sep 2023 21:42:01 -0700
+Subject: [PATCH 3/4] Make dump_escaped() take std::string_view
+
+---
+ include/nlohmann/detail/output/serializer.hpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp
+index 7674d134a4d9f230aa4e432294c19dac8dd366b1..ecc4f7d500b9e0bc15917503061a4db100391366 100644
+--- a/include/nlohmann/detail/output/serializer.hpp
++++ b/include/nlohmann/detail/output/serializer.hpp
+@@ -388,7 +388,7 @@ class serializer
+ 
+     @complexity Linear in the length of string @a s.
+     */
+-    void dump_escaped(const string_t& s, const bool ensure_ascii)
++    void dump_escaped(std::string_view s, const bool ensure_ascii)
+     {
+         std::uint32_t codepoint{};
+         std::uint8_t state = UTF8_ACCEPT;
diff --git a/upstream_utils/json_patches/0004-Add-llvm-stream-support.patch b/upstream_utils/json_patches/0004-Add-llvm-stream-support.patch
new file mode 100644
index 0000000..c47586f
--- /dev/null
+++ b/upstream_utils/json_patches/0004-Add-llvm-stream-support.patch
@@ -0,0 +1,133 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: PJ Reiniger <pj.reiniger@gmail.com>
+Date: Wed, 20 Sep 2023 02:23:10 -0400
+Subject: [PATCH 4/4] Add llvm stream support
+
+---
+ .../detail/output/output_adapters.hpp         | 26 +++++++++++++++++++
+ include/nlohmann/detail/output/serializer.hpp | 11 ++++++--
+ include/nlohmann/json.hpp                     | 24 +++++++++++++++++
+ 3 files changed, 59 insertions(+), 2 deletions(-)
+
+diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp
+index 630bd8f73f38b7bf18be571217873f6215e6e31a..78addc557eec3b2a31cde78fb4c6f7f6efc7e777 100644
+--- a/include/nlohmann/detail/output/output_adapters.hpp
++++ b/include/nlohmann/detail/output/output_adapters.hpp
+@@ -22,6 +22,8 @@
+ 
+ #include <nlohmann/detail/macro_scope.hpp>
+ 
++#include <wpi/raw_ostream.h>
++
+ NLOHMANN_JSON_NAMESPACE_BEGIN
+ namespace detail
+ {
+@@ -118,6 +120,27 @@ class output_string_adapter : public output_adapter_protocol<CharType>
+     StringType& str;
+ };
+ 
++template<typename CharType>
++class raw_ostream_adapter : public output_adapter_protocol<CharType>
++{
++  public:
++    explicit raw_ostream_adapter(raw_ostream& s) noexcept
++        : os(s) {}
++
++
++    void write_character(CharType c) override {
++        os << c;
++    }
++
++    JSON_HEDLEY_NON_NULL(2)
++    void write_characters(const CharType* s, std::size_t length) override {
++        os.write(s, length);
++    }
++
++  private:
++    raw_ostream& os;
++};
++
+ template<typename CharType, typename StringType = std::basic_string<CharType>>
+ class output_adapter
+ {
+@@ -134,6 +157,9 @@ class output_adapter
+     output_adapter(StringType& s)
+         : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
+ 
++    output_adapter(raw_ostream& os)
++        : oa(std::make_shared<raw_ostream_adapter<CharType>>(os)) {}
++
+     operator output_adapter_t<CharType>()
+     {
+         return oa;
+diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp
+index ecc4f7d500b9e0bc15917503061a4db100391366..bb392a985b57b79020c949593c155052a4271d6b 100644
+--- a/include/nlohmann/detail/output/serializer.hpp
++++ b/include/nlohmann/detail/output/serializer.hpp
+@@ -65,15 +65,22 @@ class serializer
+     @param[in] error_handler_  how to react on decoding errors
+     */
+     serializer(output_adapter_t<char> s, const char ichar,
+-               error_handler_t error_handler_ = error_handler_t::strict)
++               error_handler_t error_handler_ = error_handler_t::strict,
++               size_t indent_init_len = 512)
+         : o(std::move(s))
+         , loc(std::localeconv())
+         , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
+         , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->decimal_point)))
+         , indent_char(ichar)
+-        , indent_string(512, indent_char)
++        , indent_string(indent_init_len, indent_char)
+         , error_handler(error_handler_)
+     {}
++    
++    serializer(raw_ostream& os, const char ichar,
++               size_t indent_init_len = 512,
++               error_handler_t error_handler_ = error_handler_t::strict)
++        : serializer(output_adapter<char>(os), ichar, error_handler_, indent_init_len)
++    {}
+ 
+     // delete because of pointer members
+     serializer(const serializer&) = delete;
+diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp
+index c462cade8a7167a00697f6f940be35c5609a283c..ad98956ba880f844ed1a17765266880f6ea08b2f 100644
+--- a/include/nlohmann/json.hpp
++++ b/include/nlohmann/json.hpp
+@@ -1275,6 +1275,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
+         return result;
+     }
+ 
++    void dump(raw_ostream& os, const int indent = -1,
++                  const char indent_char = ' ',
++                  const bool ensure_ascii = false,
++                  const error_handler_t error_handler = error_handler_t::strict) const {
++      serializer s(os, indent_char);
++
++      if (indent >= 0)
++      {
++          s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent));
++      }
++      else
++      {
++          s.dump(*this, false, ensure_ascii, 0);
++      }
++
++      os.flush();
++    }
++
+     /// @brief return the type of the JSON value (explicit)
+     /// @sa https://json.nlohmann.me/api/basic_json/type/
+     constexpr value_t type() const noexcept
+@@ -3990,6 +4008,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
+         return o << j;
+     }
+ #endif  // JSON_NO_IO
++    
++    friend raw_ostream& operator<<(raw_ostream& o, const basic_json& j)
++    {
++        j.dump(o, 0);
++        return o;
++    }
+     /// @}
+ 
+ 
diff --git a/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch b/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch
new file mode 100644
index 0000000..890b8c3
--- /dev/null
+++ b/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch
@@ -0,0 +1,190 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Fri, 14 Jul 2023 17:33:08 -0700
+Subject: [PATCH 01/10] Revert "win,process: write minidumps when sending
+ SIGQUIT (#3840)"
+
+This reverts commit 748d894e82abcdfff7429cf745003e182c47f163.
+---
+ CMakeLists.txt    |   5 +-
+ configure.ac      |   2 +-
+ include/uv/win.h  |   1 -
+ src/win/process.c | 116 ----------------------------------------------
+ 4 files changed, 2 insertions(+), 122 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 93733dd04783436cc1f1a801133e67e315f4af8d..0958dfb1bd93311cd0e20506311e1e41774c5fa4 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -183,10 +183,7 @@ if(WIN32)
+        advapi32
+        iphlpapi
+        userenv
+-       ws2_32
+-       dbghelp
+-       ole32
+-       uuid)
++       ws2_32)
+   list(APPEND uv_sources
+        src/win/async.c
+        src/win/core.c
+diff --git a/configure.ac b/configure.ac
+index deb083605de639e896df83882715ddca25340fa3..76177a4bc8e5f17bc1e062af3a9028d2dfc76dc9 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -74,7 +74,7 @@ AM_CONDITIONAL([OS400],    [AS_CASE([$host_os],[os400],         [true], [false])
+ AM_CONDITIONAL([SUNOS],    [AS_CASE([$host_os],[solaris*],      [true], [false])])
+ AM_CONDITIONAL([WINNT],    [AS_CASE([$host_os],[mingw*],        [true], [false])])
+ AS_CASE([$host_os],[mingw*], [
+-    LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32 -ldbghelp -lole32 -luuid"
++    LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32"
+ ])
+ AS_CASE([$host_os], [solaris2.10], [
+     CFLAGS="$CFLAGS -DSUNOS_NO_IFADDRS"
+diff --git a/include/uv/win.h b/include/uv/win.h
+index 6f8c47298e407bcb0151cf383a8370b71074f03e..eb74776978340a4910194bae35a9da6493e8c0a6 100644
+--- a/include/uv/win.h
++++ b/include/uv/win.h
+@@ -91,7 +91,6 @@ typedef struct pollfd {
+  * variants (Linux and Darwin)
+  */
+ #define SIGHUP                1
+-#define SIGQUIT               3
+ #define SIGKILL               9
+ #define SIGWINCH             28
+ 
+diff --git a/src/win/process.c b/src/win/process.c
+index 3e451e2291d6ed200ec258e874becbbea22bbc27..ed44adc67c6d52785a199206d9ba0357e2d0b045 100644
+--- a/src/win/process.c
++++ b/src/win/process.c
+@@ -32,9 +32,6 @@
+ #include "internal.h"
+ #include "handle-inl.h"
+ #include "req-inl.h"
+-#include <dbghelp.h>
+-#include <shlobj.h>
+-#include <psapi.h>     /* GetModuleBaseNameW */
+ 
+ 
+ #define SIGKILL         9
+@@ -1197,120 +1194,7 @@ static int uv__kill(HANDLE process_handle, int signum) {
+     return UV_EINVAL;
+   }
+ 
+-  /* Create a dump file for the targeted process, if the registry key
+-   * `HKLM:Software\Microsoft\Windows\Windows Error Reporting\LocalDumps`
+-   * exists.  The location of the dumps can be influenced by the `DumpFolder`
+-   * sub-key, which has a default value of `%LOCALAPPDATA%\CrashDumps`, see [0]
+-   * for more detail.  Note that if the dump folder does not exist, we attempt
+-   * to create it, to match behavior with WER itself.
+-   * [0]: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps */
+-  if (signum == SIGQUIT) {
+-    HKEY registry_key;
+-    DWORD pid, ret;
+-    WCHAR basename[MAX_PATH];
+-
+-    /* Get target process name. */
+-    GetModuleBaseNameW(process_handle, NULL, &basename[0], sizeof(basename));
+-
+-    /* Get PID of target process. */
+-    pid = GetProcessId(process_handle);
+-
+-    /* Get LocalDumps directory path. */
+-    ret = RegOpenKeyExW(
+-        HKEY_LOCAL_MACHINE,
+-        L"SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\LocalDumps",
+-        0,
+-        KEY_QUERY_VALUE,
+-        &registry_key);
+-    if (ret == ERROR_SUCCESS) {
+-      HANDLE hDumpFile = NULL;
+-      WCHAR dump_folder[MAX_PATH], dump_name[MAX_PATH];
+-      DWORD dump_folder_len = sizeof(dump_folder), key_type = 0;
+-      ret = RegGetValueW(registry_key,
+-                         NULL,
+-                         L"DumpFolder",
+-                         RRF_RT_ANY,
+-                         &key_type,
+-                         (PVOID) dump_folder,
+-                         &dump_folder_len);
+-      if (ret != ERROR_SUCCESS) {
+-        /* Default value for `dump_folder` is `%LOCALAPPDATA%\CrashDumps`. */
+-        WCHAR* localappdata;
+-        SHGetKnownFolderPath(&FOLDERID_LocalAppData, 0, NULL, &localappdata);
+-        _snwprintf_s(dump_folder,
+-                     sizeof(dump_folder),
+-                     _TRUNCATE,
+-                     L"%ls\\CrashDumps",
+-                     localappdata);
+-        CoTaskMemFree(localappdata);
+-      }
+-      RegCloseKey(registry_key);
+-
+-      /* Create dump folder if it doesn't already exist. */
+-      CreateDirectoryW(dump_folder, NULL);
+-
+-      /* Construct dump filename from process name and PID. */
+-      _snwprintf_s(dump_name,
+-                   sizeof(dump_name),
+-                   _TRUNCATE,
+-                   L"%ls\\%ls.%d.dmp",
+-                   dump_folder,
+-                   basename,
+-                   pid);
+-
+-      hDumpFile = CreateFileW(dump_name,
+-                              GENERIC_WRITE,
+-                              0,
+-                              NULL,
+-                              CREATE_NEW,
+-                              FILE_ATTRIBUTE_NORMAL,
+-                              NULL);
+-      if (hDumpFile != INVALID_HANDLE_VALUE) {
+-        DWORD dump_options, sym_options;
+-        FILE_DISPOSITION_INFO DeleteOnClose = { TRUE };
+-
+-        /* If something goes wrong while writing it out, delete the file. */
+-        SetFileInformationByHandle(hDumpFile,
+-                                   FileDispositionInfo,
+-                                   &DeleteOnClose,
+-                                   sizeof(DeleteOnClose));
+-
+-        /* Tell wine to dump ELF modules as well. */
+-        sym_options = SymGetOptions();
+-        SymSetOptions(sym_options | 0x40000000);
+-
+-/* MiniDumpWithAvxXStateContext might be undef in server2012r2 or mingw < 12 */
+-#ifndef MiniDumpWithAvxXStateContext
+-#define MiniDumpWithAvxXStateContext 0x00200000
+-#endif
+-        /* We default to a fairly complete dump.  In the future, we may want to
+-         * allow clients to customize what kind of dump to create. */
+-        dump_options = MiniDumpWithFullMemory |
+-                       MiniDumpIgnoreInaccessibleMemory |
+-                       MiniDumpWithAvxXStateContext;
+-
+-        if (MiniDumpWriteDump(process_handle,
+-                              pid,
+-                              hDumpFile,
+-                              dump_options,
+-                              NULL,
+-                              NULL,
+-                              NULL)) {
+-          /* Don't delete the file on close if we successfully wrote it out. */
+-          FILE_DISPOSITION_INFO DontDeleteOnClose = { FALSE };
+-          SetFileInformationByHandle(hDumpFile,
+-                                     FileDispositionInfo,
+-                                     &DontDeleteOnClose,
+-                                     sizeof(DontDeleteOnClose));
+-        }
+-        SymSetOptions(sym_options);
+-        CloseHandle(hDumpFile);
+-      }
+-    }
+-  }
+-
+   switch (signum) {
+-    case SIGQUIT:
+     case SIGTERM:
+     case SIGKILL:
+     case SIGINT: {
diff --git a/upstream_utils/libuv_patches/0001-Fix-missing-casts.patch b/upstream_utils/libuv_patches/0002-Fix-missing-casts.patch
similarity index 68%
rename from upstream_utils/libuv_patches/0001-Fix-missing-casts.patch
rename to upstream_utils/libuv_patches/0002-Fix-missing-casts.patch
index 6965d0d..4d9603f 100644
--- a/upstream_utils/libuv_patches/0001-Fix-missing-casts.patch
+++ b/upstream_utils/libuv_patches/0002-Fix-missing-casts.patch
@@ -1,66 +1,51 @@
-From d5613423f057b088f6b3753f49162947d5559ad9 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 26 Apr 2022 15:01:25 -0400
-Subject: [PATCH 1/9] Fix missing casts
+Subject: [PATCH 02/10] Fix missing casts
 
 ---
- include/uv/unix.h              |  2 +-
- src/fs-poll.c                  | 10 ++++-----
- src/inet.c                     | 11 +++++-----
+ src/fs-poll.c                  | 10 ++++----
+ src/inet.c                     | 11 ++++----
  src/strscpy.c                  |  2 +-
+ src/thread-common.c            |  2 +-
  src/threadpool.c               |  2 +-
  src/unix/bsd-ifaddrs.c         |  2 +-
- src/unix/core.c                | 12 +++++-----
- src/unix/darwin-proctitle.c    |  5 +++--
+ src/unix/core.c                | 18 ++++++-------
+ src/unix/darwin-proctitle.c    |  5 ++--
  src/unix/darwin.c              |  2 +-
- src/unix/epoll.c               |  2 +-
- src/unix/freebsd.c             |  4 ++--
- src/unix/fs.c                  | 20 ++++++++---------
- src/unix/fsevents.c            | 40 +++++++++++++++++-----------------
- src/unix/getaddrinfo.c         |  8 +++----
+ src/unix/freebsd.c             |  4 +--
+ src/unix/fs.c                  | 20 +++++++--------
+ src/unix/fsevents.c            | 34 ++++++++++++-------------
+ src/unix/getaddrinfo.c         |  8 +++---
  src/unix/ibmi.c                |  2 +-
  src/unix/kqueue.c              |  6 ++---
- src/unix/linux-core.c          |  5 ++---
- src/unix/linux-inotify.c       |  4 ++--
+ src/unix/linux.c               | 46 +++++++++++++++++-----------------
  src/unix/loop.c                |  2 +-
- src/unix/netbsd.c              |  4 ++--
- src/unix/openbsd.c             |  4 ++--
- src/unix/pipe.c                |  4 ++--
- src/unix/poll.c                |  2 +-
+ src/unix/netbsd.c              |  4 +--
+ src/unix/openbsd.c             |  4 +--
+ src/unix/pipe.c                |  4 +--
+ src/unix/poll.c                |  4 +--
  src/unix/posix-poll.c          |  2 +-
- src/unix/process.c             |  4 ++--
+ src/unix/process.c             |  4 +--
  src/unix/proctitle.c           |  2 +-
  src/unix/random-sysctl-linux.c |  2 +-
- src/unix/stream.c              | 35 ++++++++++++++---------------
- src/unix/thread.c              |  7 +++---
- src/unix/udp.c                 |  8 +++----
- src/uv-common.c                | 16 +++++++-------
- src/win/core.c                 |  8 ++++---
- src/win/fs-event.c             |  4 ++--
+ src/unix/stream.c              | 31 ++++++++++++-----------
+ src/unix/thread.c              |  5 ++--
+ src/unix/udp.c                 |  8 +++---
+ src/uv-common.c                | 16 ++++++------
+ src/win/core.c                 |  8 +++---
+ src/win/fs-event.c             |  4 +--
  src/win/fs-fd-hash-inl.h       |  2 +-
- src/win/fs.c                   | 26 +++++++++++-----------
- src/win/pipe.c                 | 10 ++++-----
- src/win/process.c              | 12 +++++-----
+ src/win/fs.c                   | 28 ++++++++++-----------
+ src/win/pipe.c                 | 12 ++++-----
+ src/win/process.c              | 12 ++++-----
  src/win/tcp.c                  |  2 +-
- src/win/thread.c               |  4 ++--
- src/win/util.c                 | 29 ++++++++++++------------
- 40 files changed, 166 insertions(+), 162 deletions(-)
+ src/win/thread.c               |  4 +--
+ src/win/util.c                 | 27 ++++++++++----------
+ 38 files changed, 183 insertions(+), 178 deletions(-)
 
-diff --git a/include/uv/unix.h b/include/uv/unix.h
-index ea37d787..420be86c 100644
---- a/include/uv/unix.h
-+++ b/include/uv/unix.h
-@@ -223,7 +223,7 @@ typedef struct {
-   int backend_fd;                                                             \
-   void* pending_queue[2];                                                     \
-   void* watcher_queue[2];                                                     \
--  uv__io_t** watchers;                                                        \
-+  void** watchers;                                                            \
-   unsigned int nwatchers;                                                     \
-   unsigned int nfds;                                                          \
-   void* wq[2];                                                                \
 diff --git a/src/fs-poll.c b/src/fs-poll.c
-index 1bac1c56..5a39daed 100644
+index 1bac1c568e36cadd0b68451926c6f045f88342d2..5a39daed095502b2db34f23fcaf0ab04f31f96ff 100644
 --- a/src/fs-poll.c
 +++ b/src/fs-poll.c
 @@ -77,7 +77,7 @@ int uv_fs_poll_start(uv_fs_poll_t* handle,
@@ -109,10 +94,10 @@
           last = it, it = it->previous) {
        assert(last->previous != NULL);
 diff --git a/src/inet.c b/src/inet.c
-index ddabf22f..ca8b6ac8 100644
+index cd77496846e90e8b8e61c63c10f498f153344fe5..dd94bea3886ca37945fcad7909d765e3700e3c21 100644
 --- a/src/inet.c
 +++ b/src/inet.c
-@@ -40,9 +40,9 @@ static int inet_pton6(const char *src, unsigned char *dst);
+@@ -35,9 +35,9 @@ static int inet_pton6(const char *src, unsigned char *dst);
  int uv_inet_ntop(int af, const void* src, char* dst, size_t size) {
    switch (af) {
    case AF_INET:
@@ -124,7 +109,7 @@
    default:
      return UV_EAFNOSUPPORT;
    }
-@@ -154,10 +154,11 @@ int uv_inet_pton(int af, const char* src, void* dst) {
+@@ -149,10 +149,11 @@ int uv_inet_pton(int af, const char* src, void* dst) {
  
    switch (af) {
    case AF_INET:
@@ -138,7 +123,7 @@
      s = (char*) src;
      p = strchr(src, '%');
      if (p != NULL) {
-@@ -168,7 +169,7 @@ int uv_inet_pton(int af, const char* src, void* dst) {
+@@ -163,7 +164,7 @@ int uv_inet_pton(int af, const char* src, void* dst) {
        memcpy(s, src, len);
        s[len] = '\0';
      }
@@ -148,7 +133,7 @@
    default:
      return UV_EAFNOSUPPORT;
 diff --git a/src/strscpy.c b/src/strscpy.c
-index 20df6fcb..6b4cc3bc 100644
+index 20df6fcbed29e9d944c866ddbcd5c09345a426b3..6b4cc3bc741b40b9c2b13d4c06e7090f8083a7ba 100644
 --- a/src/strscpy.c
 +++ b/src/strscpy.c
 @@ -27,7 +27,7 @@ ssize_t uv__strscpy(char* d, const char* s, size_t n) {
@@ -160,11 +145,24 @@
  
    if (i == 0)
      return 0;
+diff --git a/src/thread-common.c b/src/thread-common.c
+index c67c0a7dd7279af6c67b7d5d4a623c47bdf3fff2..c0e39b543df229dd8cb8492bb695e61e40911453 100644
+--- a/src/thread-common.c
++++ b/src/thread-common.c
+@@ -49,7 +49,7 @@ int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) {
+   if (barrier == NULL || count == 0)
+     return UV_EINVAL;
+ 
+-  b = uv__malloc(sizeof(*b));
++  b = (struct _uv_barrier *)uv__malloc(sizeof(*b));
+   if (b == NULL)
+     return UV_ENOMEM;
+ #endif
 diff --git a/src/threadpool.c b/src/threadpool.c
-index e804c7c4..1241ace1 100644
+index dbef67f2f10f1df498f228c21eba2a71ceceee29..f572de5aaf1a1b150e58c7b989949441cac279c4 100644
 --- a/src/threadpool.c
 +++ b/src/threadpool.c
-@@ -206,7 +206,7 @@ static void init_threads(void) {
+@@ -207,7 +207,7 @@ static void init_threads(void) {
  
    threads = default_threads;
    if (nthreads > ARRAY_SIZE(default_threads)) {
@@ -174,7 +172,7 @@
        nthreads = ARRAY_SIZE(default_threads);
        threads = default_threads;
 diff --git a/src/unix/bsd-ifaddrs.c b/src/unix/bsd-ifaddrs.c
-index 11ca9559..c3dd71a1 100644
+index 11ca95591fc38244e931fecd9dd4038d3968af7a..c3dd71a1889bfae08cfdf95acda61e6c3472bd2c 100644
 --- a/src/unix/bsd-ifaddrs.c
 +++ b/src/unix/bsd-ifaddrs.c
 @@ -92,7 +92,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
@@ -187,10 +185,10 @@
    if (*addresses == NULL) {
      freeifaddrs(addrs);
 diff --git a/src/unix/core.c b/src/unix/core.c
-index 54c769f3..6353b0e3 100644
+index 25c5181f370e94983e8a5f797f02f7a8dc207e00..28c036f94f3e76717afa651451969f128c5a573c 100644
 --- a/src/unix/core.c
 +++ b/src/unix/core.c
-@@ -824,7 +824,7 @@ static unsigned int next_power_of_two(unsigned int val) {
+@@ -855,7 +855,7 @@ static unsigned int next_power_of_two(unsigned int val) {
  }
  
  static void maybe_resize(uv_loop_t* loop, unsigned int len) {
@@ -199,7 +197,7 @@
    void* fake_watcher_list;
    void* fake_watcher_count;
    unsigned int nwatchers;
-@@ -843,8 +843,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) {
+@@ -874,8 +874,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) {
    }
  
    nwatchers = next_power_of_two(len + 2) - 2;
@@ -210,7 +208,16 @@
  
    if (watchers == NULL)
      abort();
-@@ -1184,7 +1184,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
+@@ -884,7 +884,7 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) {
+   watchers[nwatchers] = fake_watcher_list;
+   watchers[nwatchers + 1] = fake_watcher_count;
+ 
+-  loop->watchers = watchers;
++  loop->watchers = (uv__io_t**)watchers;
+   loop->nwatchers = nwatchers;
+ }
+ 
+@@ -1216,7 +1216,7 @@ static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) {
     * is frequently 1024 or 4096, so we can just use that directly. The pwent
     * will not usually be large. */
    for (bufsize = 2000;; bufsize *= 2) {
@@ -219,7 +226,7 @@
  
      if (buf == NULL)
        return UV_ENOMEM;
-@@ -1210,7 +1210,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
+@@ -1242,7 +1242,7 @@ static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) {
    name_size = strlen(pw.pw_name) + 1;
    homedir_size = strlen(pw.pw_dir) + 1;
    shell_size = strlen(pw.pw_shell) + 1;
@@ -228,7 +235,25 @@
  
    if (pwd->username == NULL) {
      uv__free(buf);
-@@ -1274,7 +1274,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
+@@ -1292,7 +1292,7 @@ int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) {
+    * is frequently 1024 or 4096, so we can just use that directly. The pwent
+    * will not usually be large. */
+   for (bufsize = 2000;; bufsize *= 2) {
+-    buf = uv__malloc(bufsize);
++    buf = (char*)uv__malloc(bufsize);
+ 
+     if (buf == NULL)
+       return UV_ENOMEM;
+@@ -1323,7 +1323,7 @@ int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) {
+     members++;
+   }
+ 
+-  gr_mem = uv__malloc(name_size + mem_size);
++  gr_mem = (char*)uv__malloc(name_size + mem_size);
+   if (gr_mem == NULL) {
+     uv__free(buf);
+     return UV_ENOMEM;
+@@ -1380,7 +1380,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
  
    for (i = 0; environ[i] != NULL; i++);
  
@@ -238,7 +263,7 @@
    if (*envitems == NULL)
      return UV_ENOMEM;
 diff --git a/src/unix/darwin-proctitle.c b/src/unix/darwin-proctitle.c
-index 5288083e..9bd55dd7 100644
+index 5288083ef04fd78d90c34071cc76281adbc310d8..9bd55dd764b845cf8ea441d525b4e136699eb52e 100644
 --- a/src/unix/darwin-proctitle.c
 +++ b/src/unix/darwin-proctitle.c
 @@ -128,8 +128,9 @@ int uv__set_process_title(const char* title) {
@@ -254,10 +279,10 @@
    if (display_name_key == NULL || *display_name_key == NULL)
      goto out;
 diff --git a/src/unix/darwin.c b/src/unix/darwin.c
-index 62f04d31..5fbf7342 100644
+index 90790d701c4327518d17230c5aa69b9a74112e73..9ee5cd8eb9d02fb8b71986c47fe8a686f0983847 100644
 --- a/src/unix/darwin.c
 +++ b/src/unix/darwin.c
-@@ -353,7 +353,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+@@ -217,7 +217,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
      return UV_EINVAL;  /* FIXME(bnoordhuis) Translate error. */
    }
  
@@ -266,24 +291,11 @@
    if (!(*cpu_infos)) {
      vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type);
      return UV_ENOMEM;
-diff --git a/src/unix/epoll.c b/src/unix/epoll.c
-index 97348e25..4c057fb3 100644
---- a/src/unix/epoll.c
-+++ b/src/unix/epoll.c
-@@ -325,7 +325,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
-       assert(fd >= 0);
-       assert((unsigned) fd < loop->nwatchers);
- 
--      w = loop->watchers[fd];
-+      w = (uv__io_t*)loop->watchers[fd];
- 
-       if (w == NULL) {
-         /* File descriptor that we've stopped watching, disarm it.
 diff --git a/src/unix/freebsd.c b/src/unix/freebsd.c
-index 658ff262..6700ff61 100644
+index 191bc8bc213ffddb15c5e04baa66e2a0a8d69a3d..1bd63886b823be6451ac013d94e29885795375b7 100644
 --- a/src/unix/freebsd.c
 +++ b/src/unix/freebsd.c
-@@ -215,7 +215,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+@@ -220,7 +220,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
    if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0))
      return UV__ERR(errno);
  
@@ -292,7 +304,7 @@
    if (!(*cpu_infos))
      return UV_ENOMEM;
  
-@@ -232,7 +232,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+@@ -237,7 +237,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
  
    size = maxcpus * CPUSTATES * sizeof(long);
  
@@ -302,10 +314,10 @@
      uv__free(*cpu_infos);
      return UV_ENOMEM;
 diff --git a/src/unix/fs.c b/src/unix/fs.c
-index 933c9c0d..1a615244 100644
+index 6b051c124f2fd9b0f72b41d7d7ba9c715e9686e1..e25d02e54dbe93e4b9c22b0140108c99ae2cb4f7 100644
 --- a/src/unix/fs.c
 +++ b/src/unix/fs.c
-@@ -137,7 +137,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
+@@ -140,7 +140,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
        size_t new_path_len;                                                    \
        path_len = strlen(path) + 1;                                            \
        new_path_len = strlen(new_path) + 1;                                    \
@@ -314,7 +326,7 @@
        if (req->path == NULL)                                                  \
          return UV_ENOMEM;                                                     \
        req->new_path = req->path + path_len;                                   \
-@@ -572,7 +572,7 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
+@@ -568,7 +568,7 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
  static int uv__fs_opendir(uv_fs_t* req) {
    uv_dir_t* dir;
  
@@ -323,7 +335,7 @@
    if (dir == NULL)
      goto error;
  
-@@ -596,7 +596,7 @@ static int uv__fs_readdir(uv_fs_t* req) {
+@@ -592,7 +592,7 @@ static int uv__fs_readdir(uv_fs_t* req) {
    unsigned int dirent_idx;
    unsigned int i;
  
@@ -332,7 +344,7 @@
    dirent_idx = 0;
  
    while (dirent_idx < dir->nentries) {
-@@ -638,7 +638,7 @@ error:
+@@ -634,7 +634,7 @@ error:
  static int uv__fs_closedir(uv_fs_t* req) {
    uv_dir_t* dir;
  
@@ -341,7 +353,7 @@
  
    if (dir->dir != NULL) {
      closedir(dir->dir);
-@@ -667,7 +667,7 @@ static int uv__fs_statfs(uv_fs_t* req) {
+@@ -663,7 +663,7 @@ static int uv__fs_statfs(uv_fs_t* req) {
  #endif /* defined(__sun) */
      return -1;
  
@@ -350,7 +362,7 @@
    if (stat_fs == NULL) {
      errno = ENOMEM;
      return -1;
-@@ -731,7 +731,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
+@@ -727,7 +727,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
      maxlen = uv__fs_pathmax_size(req->path);
  #endif
  
@@ -359,7 +371,7 @@
  
    if (buf == NULL) {
      errno = ENOMEM;
-@@ -751,7 +751,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
+@@ -747,7 +747,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
  
    /* Uncommon case: resize to make room for the trailing nul byte. */
    if (len == maxlen) {
@@ -368,7 +380,7 @@
  
      if (buf == NULL)
        return -1;
-@@ -774,7 +774,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) {
+@@ -770,7 +770,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) {
    ssize_t len;
  
    len = uv__fs_pathmax_size(req->path);
@@ -377,7 +389,7 @@
  
    if (buf == NULL) {
      errno = ENOMEM;
-@@ -2010,7 +2010,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
+@@ -1984,7 +1984,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
    req->nbufs = nbufs;
    req->bufs = req->bufsml;
    if (nbufs > ARRAY_SIZE(req->bufsml))
@@ -386,7 +398,7 @@
  
    if (req->bufs == NULL)
      return UV_ENOMEM;
-@@ -2180,7 +2180,7 @@ int uv_fs_write(uv_loop_t* loop,
+@@ -2171,7 +2171,7 @@ int uv_fs_write(uv_loop_t* loop,
    req->nbufs = nbufs;
    req->bufs = req->bufsml;
    if (nbufs > ARRAY_SIZE(req->bufsml))
@@ -396,10 +408,10 @@
    if (req->bufs == NULL)
      return UV_ENOMEM;
 diff --git a/src/unix/fsevents.c b/src/unix/fsevents.c
-index bf4f1f6a..648c8a98 100644
+index df703f3635fc95bab21debc9697dba06a2a44827..c31d08ba37cfd10672ab6a7a8fd38a1c79b952fe 100644
 --- a/src/unix/fsevents.c
 +++ b/src/unix/fsevents.c
-@@ -185,7 +185,7 @@ static void (*pFSEventStreamStop)(FSEventStreamRef);
+@@ -183,7 +183,7 @@ static void (*pFSEventStreamStop)(FSEventStreamRef);
  static void uv__fsevents_cb(uv_async_t* cb) {
    uv_fs_event_t* handle;
  
@@ -408,9 +420,9 @@
  
    UV__FSEVENTS_PROCESS(handle, {
      handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0);
-@@ -233,10 +233,10 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef,
+@@ -231,10 +231,10 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef,
    FSEventStreamEventFlags flags;
-   QUEUE head;
+   struct uv__queue head;
  
 -  loop = info;
 -  state = loop->cf_state;
@@ -422,7 +434,7 @@
  
    /* For each handle */
    uv_mutex_lock(&state->fsevent_mutex);
-@@ -306,7 +306,7 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef,
+@@ -304,7 +304,7 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef,
            continue;
        }
  
@@ -431,34 +443,7 @@
        if (event == NULL)
          break;
  
-@@ -373,7 +373,7 @@ static int uv__fsevents_create_stream(uv_loop_t* loop, CFArrayRef paths) {
-                              flags);
-   assert(ref != NULL);
- 
--  state = loop->cf_state;
-+  state = (uv__cf_loop_state_t*)loop->cf_state;
-   pFSEventStreamScheduleWithRunLoop(ref,
-                                     state->loop,
-                                     *pkCFRunLoopDefaultMode);
-@@ -392,7 +392,7 @@ static int uv__fsevents_create_stream(uv_loop_t* loop, CFArrayRef paths) {
- static void uv__fsevents_destroy_stream(uv_loop_t* loop) {
-   uv__cf_loop_state_t* state;
- 
--  state = loop->cf_state;
-+  state = (uv__cf_loop_state_t*)loop->cf_state;
- 
-   if (state->fsevent_stream == NULL)
-     return;
-@@ -419,7 +419,7 @@ static void uv__fsevents_reschedule(uv_fs_event_t* handle,
-   int err;
-   unsigned int path_count;
- 
--  state = handle->loop->cf_state;
-+  state = (uv__cf_loop_state_t*)handle->loop->cf_state;
-   paths = NULL;
-   cf_paths = NULL;
-   err = 0;
-@@ -447,7 +447,7 @@ static void uv__fsevents_reschedule(uv_fs_event_t* handle,
+@@ -438,7 +438,7 @@ static void uv__fsevents_reschedule(uv__cf_loop_state_t* state,
    uv_mutex_lock(&state->fsevent_mutex);
    path_count = state->fsevent_handle_count;
    if (path_count != 0) {
@@ -467,7 +452,7 @@
      if (paths == NULL) {
        uv_mutex_unlock(&state->fsevent_mutex);
        goto final;
-@@ -605,7 +605,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
+@@ -594,7 +594,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
    if (err)
      return err;
  
@@ -476,7 +461,7 @@
    if (state == NULL)
      return UV_ENOMEM;
  
-@@ -707,7 +707,7 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) {
+@@ -696,7 +696,7 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) {
    }
  
    /* Destroy state */
@@ -485,7 +470,7 @@
    uv_sem_destroy(&state->fsevent_sem);
    uv_mutex_destroy(&state->fsevent_mutex);
    pCFRelease(state->signal_source);
-@@ -721,8 +721,8 @@ static void* uv__cf_loop_runner(void* arg) {
+@@ -710,8 +710,8 @@ static void* uv__cf_loop_runner(void* arg) {
    uv_loop_t* loop;
    uv__cf_loop_state_t* state;
  
@@ -496,8 +481,8 @@
    state->loop = pCFRunLoopGetCurrent();
  
    pCFRunLoopAddSource(state->loop,
-@@ -750,8 +750,8 @@ static void uv__cf_loop_cb(void* arg) {
-   QUEUE split_head;
+@@ -739,8 +739,8 @@ static void uv__cf_loop_cb(void* arg) {
+   struct uv__queue split_head;
    uv__cf_loop_signal_t* s;
  
 -  loop = arg;
@@ -506,8 +491,8 @@
 +  state = (uv__cf_loop_state_t*)loop->cf_state;
  
    uv_mutex_lock(&loop->cf_mutex);
-   QUEUE_MOVE(&loop->cf_signals, &split_head);
-@@ -781,7 +781,7 @@ int uv__cf_loop_signal(uv_loop_t* loop,
+   uv__queue_move(&loop->cf_signals, &split_head);
+@@ -770,7 +770,7 @@ int uv__cf_loop_signal(uv_loop_t* loop,
    uv__cf_loop_signal_t* item;
    uv__cf_loop_state_t* state;
  
@@ -516,16 +501,16 @@
    if (item == NULL)
      return UV_ENOMEM;
  
-@@ -791,7 +791,7 @@ int uv__cf_loop_signal(uv_loop_t* loop,
+@@ -780,7 +780,7 @@ int uv__cf_loop_signal(uv_loop_t* loop,
    uv_mutex_lock(&loop->cf_mutex);
-   QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member);
+   uv__queue_insert_tail(&loop->cf_signals, &item->member);
  
 -  state = loop->cf_state;
 +  state = (uv__cf_loop_state_t*)loop->cf_state;
    assert(state != NULL);
    pCFRunLoopSourceSignal(state->signal_source);
    pCFRunLoopWakeUp(state->loop);
-@@ -825,7 +825,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
+@@ -814,7 +814,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
     * Events will occur in other thread.
     * Initialize callback for getting them back into event loop's thread
     */
@@ -534,26 +519,26 @@
    if (handle->cf_cb == NULL) {
      err = UV_ENOMEM;
      goto fail_cf_cb_malloc;
-@@ -841,7 +841,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
+@@ -830,7 +830,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
      goto fail_cf_mutex_init;
  
    /* Insert handle into the list */
 -  state = handle->loop->cf_state;
 +  state = (uv__cf_loop_state_t*)handle->loop->cf_state;
    uv_mutex_lock(&state->fsevent_mutex);
-   QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member);
+   uv__queue_insert_tail(&state->fsevent_handles, &handle->cf_member);
    state->fsevent_handle_count++;
-@@ -881,7 +881,7 @@ int uv__fsevents_close(uv_fs_event_t* handle) {
+@@ -870,7 +870,7 @@ int uv__fsevents_close(uv_fs_event_t* handle) {
      return UV_EINVAL;
  
    /* Remove handle from  the list */
 -  state = handle->loop->cf_state;
 +  state = (uv__cf_loop_state_t*)handle->loop->cf_state;
    uv_mutex_lock(&state->fsevent_mutex);
-   QUEUE_REMOVE(&handle->cf_member);
+   uv__queue_remove(&handle->cf_member);
    state->fsevent_handle_count--;
 diff --git a/src/unix/getaddrinfo.c b/src/unix/getaddrinfo.c
-index 77337ace..41dc3909 100644
+index 77337ace9454e032a392c97cb9aa311f15518956..41dc3909969a643e129847ae3a3252d51feadb27 100644
 --- a/src/unix/getaddrinfo.c
 +++ b/src/unix/getaddrinfo.c
 @@ -172,7 +172,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
@@ -587,10 +572,10 @@
    if (cb) {
      uv__work_submit(loop,
 diff --git a/src/unix/ibmi.c b/src/unix/ibmi.c
-index 8c6ae636..56af31e9 100644
+index 837bba6e2fef7b834a8d104d263bef47eaed0950..5e0fa98d104428534e5264a1c6358e3f68c58b82 100644
 --- a/src/unix/ibmi.c
 +++ b/src/unix/ibmi.c
-@@ -288,7 +288,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+@@ -293,7 +293,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
  
    numcpus = sysconf(_SC_NPROCESSORS_ONLN);
  
@@ -600,10 +585,10 @@
      return UV_ENOMEM;
    }
 diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c
-index 5dac76ae..86eb529b 100644
+index b78242d3be4e3cf6b7b998f56dc65213982d4bc7..28e55aae6c613576ede7024a5c73d746e134d865 100644
 --- a/src/unix/kqueue.c
 +++ b/src/unix/kqueue.c
-@@ -281,8 +281,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
+@@ -299,8 +299,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
      nevents = 0;
  
      assert(loop->watchers != NULL);
@@ -614,7 +599,7 @@
      for (i = 0; i < nfds; i++) {
        ev = events + i;
        fd = ev->ident;
-@@ -304,7 +304,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
+@@ -322,7 +322,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
        /* Skip invalidated events, see uv__platform_invalidate_fd */
        if (fd == -1)
          continue;
@@ -622,29 +607,166 @@
 +      w = (uv__io_t*)loop->watchers[fd];
  
        if (w == NULL) {
-         /* File descriptor that we've stopped watching, disarm it.
-diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
-index 23a7dafe..85f3fc01 100644
---- a/src/unix/linux-core.c
-+++ b/src/unix/linux-core.c
-@@ -117,7 +117,6 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
- }
+         /* File descriptor that we've stopped watching, disarm it. */
+diff --git a/src/unix/linux.c b/src/unix/linux.c
+index 48b9c2c43e104079d3ccb5d830d1d79f891fb1a3..9173850bd158eaf9c41deca38f9ba84762a027a1 100644
+--- a/src/unix/linux.c
++++ b/src/unix/linux.c
+@@ -456,8 +456,8 @@ static void uv__iou_init(int epollfd,
+   char* sqe;
+   int ringfd;
  
+-  sq = MAP_FAILED;
+-  sqe = MAP_FAILED;
++  sq = (char*)MAP_FAILED;
++  sqe = (char*)MAP_FAILED;
  
--
- uint64_t uv__hrtime(uv_clocktype_t type) {
-   static clock_t fast_clock_id = -1;
-   struct timespec t;
-@@ -283,7 +282,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
-     goto out;
+   if (!uv__use_io_uring())
+     return;
+@@ -496,14 +496,14 @@ static void uv__iou_init(int epollfd,
+   maxlen = sqlen < cqlen ? cqlen : sqlen;
+   sqelen = params.sq_entries * sizeof(struct uv__io_uring_sqe);
  
-   err = UV_ENOMEM;
--  ci = uv__calloc(numcpus, sizeof(*ci));
-+  ci = (uv_cpu_info_t*)uv__calloc(numcpus, sizeof(*ci));
-   if (ci == NULL)
-     goto out;
+-  sq = mmap(0,
++  sq = (char*)mmap(0,
+             maxlen,
+             PROT_READ | PROT_WRITE,
+             MAP_SHARED | MAP_POPULATE,
+             ringfd,
+             0);  /* IORING_OFF_SQ_RING */
  
-@@ -663,7 +662,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
+-  sqe = mmap(0,
++  sqe = (char*)mmap(0,
+              sqelen,
+              PROT_READ | PROT_WRITE,
+              MAP_SHARED | MAP_POPULATE,
+@@ -643,7 +643,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
+   int i;
+ 
+   lfields = uv__get_internal_fields(loop);
+-  inv = lfields->inv;
++  inv = (uv__invalidate*)lfields->inv;
+ 
+   /* Invalidate events with same file descriptor */
+   if (inv != NULL)
+@@ -718,7 +718,7 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou,
+     return NULL;  /* No room in ring buffer. TODO(bnoordhuis) maybe flush it? */
+ 
+   slot = tail & mask;
+-  sqe = iou->sqe;
++  sqe = (uv__io_uring_sqe*)iou->sqe;
+   sqe = &sqe[slot];
+   memset(sqe, 0, sizeof(*sqe));
+   sqe->user_data = (uintptr_t) req;
+@@ -986,7 +986,7 @@ int uv__iou_fs_statx(uv_loop_t* loop,
+   struct uv__statx* statxbuf;
+   struct uv__iou* iou;
+ 
+-  statxbuf = uv__malloc(sizeof(*statxbuf));
++  statxbuf = (struct uv__statx*)uv__malloc(sizeof(*statxbuf));
+   if (statxbuf == NULL)
+     return 0;
+ 
+@@ -1050,7 +1050,7 @@ static void uv__iou_fs_statx_post(uv_fs_t* req) {
+   uv_stat_t* buf;
+ 
+   buf = &req->statbuf;
+-  statxbuf = req->ptr;
++  statxbuf = (struct uv__statx*)req->ptr;
+   req->ptr = NULL;
+ 
+   if (req->result == 0) {
+@@ -1079,7 +1079,7 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) {
+   tail = atomic_load_explicit((_Atomic uint32_t*) iou->cqtail,
+                               memory_order_acquire);
+   mask = iou->cqmask;
+-  cqe = iou->cqe;
++  cqe = (uv__io_uring_cqe*)iou->cqe;
+   nevents = 0;
+ 
+   for (i = head; i != tail; i++) {
+@@ -1170,7 +1170,7 @@ static void uv__epoll_ctl_prep(int epollfd,
+     pe = &(*events)[slot];
+     *pe = *e;
+ 
+-    sqe = ctl->sqe;
++    sqe = (uv__io_uring_sqe*)ctl->sqe;
+     sqe = &sqe[slot];
+ 
+     memset(sqe, 0, sizeof(*sqe));
+@@ -1226,7 +1226,7 @@ static void uv__epoll_ctl_flush(int epollfd,
+   while (*ctl->cqhead != *ctl->cqtail) {
+     slot = (*ctl->cqhead)++ & ctl->cqmask;
+ 
+-    cqe = ctl->cqe;
++    cqe = (uv__io_uring_cqe*)ctl->cqe;
+     cqe = &cqe[slot];
+ 
+     if (cqe->res == 0)
+@@ -1708,7 +1708,7 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
+   snprintf(*models, sizeof(*models), "unknown");
+   maxcpu = 0;
+ 
+-  cpus = uv__calloc(ARRAY_SIZE(*cpus), sizeof(**cpus));
++  cpus = (decltype(cpus))uv__calloc(ARRAY_SIZE(*cpus), sizeof(**cpus));
+   if (cpus == NULL)
+     return UV_ENOMEM;
+ 
+@@ -1764,9 +1764,9 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
+ 
+     /* arm64: translate CPU part code to model name. */
+     if (*parts) {
+-      p = memmem(parts, sizeof(parts) - 1, p, n + 1);
++      p = (char*)memmem(parts, sizeof(parts) - 1, p, n + 1);
+       if (p == NULL)
+-        p = "unknown";
++        p = const_cast<char*>("unknown");
+       else
+         p += n + 1;
+       n = (int) strcspn(p, "\n");
+@@ -1815,7 +1815,7 @@ nocpuinfo:
+   }
+ 
+   size = n * sizeof(**ci) + sizeof(models);
+-  *ci = uv__malloc(size);
++  *ci = (uv_cpu_info_t*)uv__malloc(size);
+   *count = 0;
+ 
+   if (*ci == NULL) {
+@@ -1824,7 +1824,7 @@ nocpuinfo:
+   }
+ 
+   *count = n;
+-  p = memcpy(*ci + n, models, sizeof(models));
++  p = (char*)memcpy(*ci + n, models, sizeof(models));
+ 
+   i = 0;
+   for (cpu = 0; cpu < maxcpu; cpu++) {
+@@ -1833,19 +1833,19 @@ nocpuinfo:
+ 
+     c = *cpus + cpu;
+ 
+-    (*ci)[i++] = (uv_cpu_info_t) {
++    (*ci)[i++] = uv_cpu_info_t{
+       .model     = p + c->model * sizeof(*model),
+-      .speed     = c->freq / 1000,
++      .speed     = (int)(c->freq / 1000),
+       /* Note: sysconf(_SC_CLK_TCK) is fixed at 100 Hz,
+        * therefore the multiplier is always 1000/100 = 10.
+        */
+-      .cpu_times = (struct uv_cpu_times_s) {
++      .cpu_times = {
+         .user = 10 * c->user,
+         .nice = 10 * c->nice,
+         .sys  = 10 * c->sys,
+         .idle = 10 * c->idle,
+         .irq  = 10 * c->irq,
+-      },
++      }
+     };
+   }
+ 
+@@ -1902,7 +1902,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
    }
  
    /* Make sure the memory is initiallized to zero using calloc() */
@@ -653,11 +775,7 @@
    if (!(*addresses)) {
      freeifaddrs(addrs);
      return UV_ENOMEM;
-diff --git a/src/unix/linux-inotify.c b/src/unix/linux-inotify.c
-index c1bd260e..f5366e96 100644
---- a/src/unix/linux-inotify.c
-+++ b/src/unix/linux-inotify.c
-@@ -281,12 +281,12 @@ int uv_fs_event_start(uv_fs_event_t* handle,
+@@ -2470,12 +2470,12 @@ int uv_fs_event_start(uv_fs_event_t* handle,
      goto no_insert;
  
    len = strlen(path) + 1;
@@ -669,11 +787,11 @@
    w->wd = wd;
 -  w->path = memcpy(w + 1, path, len);
 +  w->path = (char*)memcpy(w + 1, path, len);
-   QUEUE_INIT(&w->watchers);
+   uv__queue_init(&w->watchers);
    w->iterating = 0;
-   RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w);
+   RB_INSERT(watcher_root, uv__inotify_watchers(loop), w);
 diff --git a/src/unix/loop.c b/src/unix/loop.c
-index a88e71c3..2e819cdd 100644
+index a9468e8e19cbede795032980c47eb83aee1e0c68..3babe4d701949ebc69d74f7dedee33c777d89892 100644
 --- a/src/unix/loop.c
 +++ b/src/unix/loop.c
 @@ -148,7 +148,7 @@ int uv_loop_fork(uv_loop_t* loop) {
@@ -686,10 +804,10 @@
        continue;
  
 diff --git a/src/unix/netbsd.c b/src/unix/netbsd.c
-index c66333f5..b6886a1c 100644
+index fa21e98e41aec8b7d8bc46c299c4c20a7a0c3f0c..4c6d5a24fe896d89e3b2f1db1dc2b1dd7d010aec 100644
 --- a/src/unix/netbsd.c
 +++ b/src/unix/netbsd.c
-@@ -206,14 +206,14 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+@@ -211,14 +211,14 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
      cpuspeed = 0;
  
    size = numcpus * CPUSTATES * sizeof(*cp_times);
@@ -707,7 +825,7 @@
      uv__free(cp_times);
      uv__free(*cpu_infos);
 diff --git a/src/unix/openbsd.c b/src/unix/openbsd.c
-index f32a94df..62740f73 100644
+index 9c863b6c90dad9864cb8341c2b6203c1390a9487..2aa61e2ee3321d91ba84887c7ed6dcfa23d00ccf 100644
 --- a/src/unix/openbsd.c
 +++ b/src/unix/openbsd.c
 @@ -72,7 +72,7 @@ int uv_exepath(char* buffer, size_t* size) {
@@ -719,7 +837,7 @@
      if (argsbuf == NULL)
        goto out;
      mib[0] = CTL_KERN;
-@@ -197,7 +197,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+@@ -202,7 +202,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
    if (sysctl(which, ARRAY_SIZE(which), &numcpus, &size, NULL, 0))
      return UV__ERR(errno);
  
@@ -729,10 +847,10 @@
      return UV_ENOMEM;
  
 diff --git a/src/unix/pipe.c b/src/unix/pipe.c
-index e8cfa148..c8ba31da 100644
+index d332f3518303d6ef1dee1d835c392bb60b935bad..a60b1a0e442bb3c482575da117f30e9f119f55d3 100644
 --- a/src/unix/pipe.c
 +++ b/src/unix/pipe.c
-@@ -309,7 +309,7 @@ int uv_pipe_pending_count(uv_pipe_t* handle) {
+@@ -377,7 +377,7 @@ int uv_pipe_pending_count(uv_pipe_t* handle) {
    if (handle->queued_fds == NULL)
      return 1;
  
@@ -741,7 +859,7 @@
    return queued_fds->offset + 1;
  }
  
-@@ -346,7 +346,7 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
+@@ -414,7 +414,7 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
    if (r != UV_ENOBUFS)
      return r;
  
@@ -751,7 +869,7 @@
      return UV_ENOMEM;
  
 diff --git a/src/unix/poll.c b/src/unix/poll.c
-index 7a12e2d1..73647317 100644
+index 7a12e2d1488a9d48712439e62c6637b9e1161f69..c21722b2e8eef4d16c523f7319fb57c3167d8dd9 100644
 --- a/src/unix/poll.c
 +++ b/src/unix/poll.c
 @@ -117,7 +117,7 @@ int uv_poll_stop(uv_poll_t* handle) {
@@ -763,8 +881,17 @@
    uv__io_t* w;
    int events;
  
+@@ -125,7 +125,7 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {
+                       UV_PRIORITIZED)) == 0);
+   assert(!uv__is_closing(handle));
+ 
+-  watchers = handle->loop->watchers;
++  watchers = (void**)handle->loop->watchers;
+   w = &handle->io_watcher;
+ 
+   if (uv__fd_exists(handle->loop, w->fd))
 diff --git a/src/unix/posix-poll.c b/src/unix/posix-poll.c
-index 0f4bf938..8da038d1 100644
+index 2e016c2fbaed2eeccd78080969a86aff821a4251..b71eee3f01a3f30b3b5efef539194139f258009a 100644
 --- a/src/unix/posix-poll.c
 +++ b/src/unix/posix-poll.c
 @@ -61,7 +61,7 @@ static void uv__pollfds_maybe_resize(uv_loop_t* loop) {
@@ -777,10 +904,10 @@
      abort();
  
 diff --git a/src/unix/process.c b/src/unix/process.c
-index f8415368..0916aa45 100644
+index dd58c18d9b9359fca1a924698c39bd6390dafbe0..2d622c956de6d7b6f8a04be3ecd311f39602b241 100644
 --- a/src/unix/process.c
 +++ b/src/unix/process.c
-@@ -403,7 +403,7 @@ static int posix_spawn_can_use_setsid;
+@@ -423,7 +423,7 @@ static int posix_spawn_can_use_setsid;
  static void uv__spawn_init_posix_spawn_fncs(void) {
    /* Try to locate all non-portable functions at runtime */
    posix_spawn_fncs.file_actions.addchdir_np =
@@ -789,7 +916,7 @@
  }
  
  
-@@ -967,7 +967,7 @@ int uv_spawn(uv_loop_t* loop,
+@@ -988,7 +988,7 @@ int uv_spawn(uv_loop_t* loop,
    err = UV_ENOMEM;
    pipes = pipes_storage;
    if (stdio_count > (int) ARRAY_SIZE(pipes_storage))
@@ -799,7 +926,7 @@
    if (pipes == NULL)
      goto error;
 diff --git a/src/unix/proctitle.c b/src/unix/proctitle.c
-index 9d1f00dd..8cdec753 100644
+index 9d1f00ddf66e291abd40d0c0052a7f9bd5c03017..8cdec753d003ebe16485db2b47ffb3863a9473ff 100644
 --- a/src/unix/proctitle.c
 +++ b/src/unix/proctitle.c
 @@ -65,7 +65,7 @@ char** uv_setup_args(int argc, char** argv) {
@@ -812,7 +939,7 @@
      return argv;
  
 diff --git a/src/unix/random-sysctl-linux.c b/src/unix/random-sysctl-linux.c
-index 66ba8d74..9ef18df0 100644
+index 66ba8d74ec22b72d318b91d82365f5b9693feb3c..9ef18df01a51aa6a26ae6d1d9660a819d18604d0 100644
 --- a/src/unix/random-sysctl-linux.c
 +++ b/src/unix/random-sysctl-linux.c
 @@ -48,7 +48,7 @@ int uv__random_sysctl(void* buf, size_t buflen) {
@@ -825,10 +952,10 @@
  
    while (p < pe) {
 diff --git a/src/unix/stream.c b/src/unix/stream.c
-index b1f6359e..c6cc50e7 100644
+index 28c4d5463c4622725a433b8807e5e7bde580dadd..265ddade7aec129eb9dbf07cde2a16a0e341d1a7 100644
 --- a/src/unix/stream.c
 +++ b/src/unix/stream.c
-@@ -113,7 +113,7 @@ static void uv__stream_osx_interrupt_select(uv_stream_t* stream) {
+@@ -123,7 +123,7 @@ static void uv__stream_osx_interrupt_select(uv_stream_t* stream) {
    uv__stream_select_t* s;
    int r;
  
@@ -837,7 +964,7 @@
    if (s == NULL)
      return;
  
-@@ -142,8 +142,8 @@ static void uv__stream_osx_select(void* arg) {
+@@ -152,8 +152,8 @@ static void uv__stream_osx_select(void* arg) {
    int r;
    int max_fd;
  
@@ -848,7 +975,7 @@
    fd = s->fd;
  
    if (fd > s->int_fd)
-@@ -320,7 +320,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
+@@ -330,7 +330,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
    sread_sz = ROUND_UP(max_fd + 1, sizeof(uint32_t) * NBBY) / NBBY;
    swrite_sz = sread_sz;
  
@@ -857,7 +984,7 @@
    if (s == NULL) {
      err = UV_ENOMEM;
      goto failed_malloc;
-@@ -605,7 +605,7 @@ done:
+@@ -573,7 +573,7 @@ done:
    if (server->queued_fds != NULL) {
      uv__stream_queued_fds_t* queued_fds;
  
@@ -866,16 +993,7 @@
  
      /* Read first */
      server->accepted_fd = queued_fds->fds[0];
-@@ -844,7 +844,7 @@ static int uv__try_write(uv_stream_t* stream,
-     /* silence aliasing warning */
-     {
-       void* pv = CMSG_DATA(cmsg);
--      int* pi = pv;
-+      int* pi = (int*)pv;
-       *pi = fd_to_send;
-     }
- 
-@@ -975,11 +975,12 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
+@@ -942,11 +942,12 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
    uv__stream_queued_fds_t* queued_fds;
    unsigned int queue_size;
  
@@ -891,7 +1009,7 @@
      if (queued_fds == NULL)
        return UV_ENOMEM;
      queued_fds->size = queue_size;
-@@ -989,9 +990,9 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
+@@ -956,9 +957,9 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
      /* Grow */
    } else if (queued_fds->size == queued_fds->offset) {
      queue_size = queued_fds->size + 8;
@@ -904,16 +1022,7 @@
  
      /*
       * Allocation failure, report back.
-@@ -1039,7 +1040,7 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) {
- 
-     /* silence aliasing warning */
-     pv = CMSG_DATA(cmsg);
--    pi = pv;
-+    pi = (int*)pv;
- 
-     /* Count available fds */
-     start = (char*) cmsg;
-@@ -1423,7 +1424,7 @@ int uv_write2(uv_write_t* req,
+@@ -1356,7 +1357,7 @@ int uv_write2(uv_write_t* req,
  
    req->bufs = req->bufsml;
    if (nbufs > ARRAY_SIZE(req->bufsml))
@@ -922,7 +1031,7 @@
  
    if (req->bufs == NULL)
      return UV_ENOMEM;
-@@ -1557,7 +1558,7 @@ int uv___stream_fd(const uv_stream_t* handle) {
+@@ -1490,7 +1491,7 @@ int uv___stream_fd(const uv_stream_t* handle) {
           handle->type == UV_TTY ||
           handle->type == UV_NAMED_PIPE);
  
@@ -931,7 +1040,7 @@
    if (s != NULL)
      return s->fd;
  
-@@ -1575,7 +1576,7 @@ void uv__stream_close(uv_stream_t* handle) {
+@@ -1508,7 +1509,7 @@ void uv__stream_close(uv_stream_t* handle) {
    if (handle->select != NULL) {
      uv__stream_select_t* s;
  
@@ -940,7 +1049,7 @@
  
      uv_sem_post(&s->close_sem);
      uv_sem_post(&s->async_sem);
-@@ -1610,7 +1611,7 @@ void uv__stream_close(uv_stream_t* handle) {
+@@ -1543,7 +1544,7 @@ void uv__stream_close(uv_stream_t* handle) {
  
    /* Close all queued fds */
    if (handle->queued_fds != NULL) {
@@ -950,19 +1059,10 @@
        uv__close(queued_fds->fds[i]);
      uv__free(handle->queued_fds);
 diff --git a/src/unix/thread.c b/src/unix/thread.c
-index d89e5cd1..759cd0c2 100644
+index 4d6f4b8232ec6dc0bd27258a1315340e3e272ae9..531c6211bb4321e5f11031a0644b4e3ab9174396 100644
 --- a/src/unix/thread.c
 +++ b/src/unix/thread.c
-@@ -59,7 +59,7 @@ int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) {
-   if (barrier == NULL || count == 0)
-     return UV_EINVAL;
- 
--  b = uv__malloc(sizeof(*b));
-+  b = (_uv_barrier*)uv__malloc(sizeof(*b));
-   if (b == NULL)
-     return UV_ENOMEM;
- 
-@@ -275,8 +275,7 @@ int uv_thread_create_ex(uv_thread_t* tid,
+@@ -168,8 +168,7 @@ int uv_thread_create_ex(uv_thread_t* tid,
        abort();
    }
  
@@ -972,7 +1072,7 @@
  
    if (attr != NULL)
      pthread_attr_destroy(attr);
-@@ -547,7 +546,7 @@ static int uv__custom_sem_init(uv_sem_t* sem_, unsigned int value) {
+@@ -540,7 +539,7 @@ static int uv__custom_sem_init(uv_sem_t* sem_, unsigned int value) {
    int err;
    uv_semaphore_t* sem;
  
@@ -982,10 +1082,10 @@
      return UV_ENOMEM;
  
 diff --git a/src/unix/udp.c b/src/unix/udp.c
-index 4d985b88..a130aeaa 100644
+index c2814512a5f507ceb9e764cdb7c6ff3d36e77974..cbee16b22a36b1c82e74f6a81c3811052e9b8482 100644
 --- a/src/unix/udp.c
 +++ b/src/unix/udp.c
-@@ -227,11 +227,11 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
+@@ -191,11 +191,11 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
        if (msgs[k].msg_hdr.msg_flags & MSG_TRUNC)
          flags |= UV_UDP_PARTIAL;
  
@@ -999,7 +1099,7 @@
                        flags);
      }
  
-@@ -281,7 +281,7 @@ static void uv__udp_recvmsg(uv_udp_t* handle) {
+@@ -245,7 +245,7 @@ static void uv__udp_recvmsg(uv_udp_t* handle) {
      memset(&peer, 0, sizeof(peer));
      h.msg_name = &peer;
      h.msg_namelen = sizeof(peer);
@@ -1008,7 +1108,7 @@
      h.msg_iovlen = 1;
  
      do {
-@@ -765,7 +765,7 @@ int uv__udp_send(uv_udp_send_t* req,
+@@ -719,7 +719,7 @@ int uv__udp_send(uv_udp_send_t* req,
  
    req->bufs = req->bufsml;
    if (nbufs > ARRAY_SIZE(req->bufsml))
@@ -1018,7 +1118,7 @@
    if (req->bufs == NULL) {
      uv__req_unregister(handle->loop, req);
 diff --git a/src/uv-common.c b/src/uv-common.c
-index efc9eb50..dfb606e3 100644
+index 916f3f4e00664ab47f94d2a6ee7c6a9ef0461389..c04f93596ab1f730576256d86e216ccb7f258b72 100644
 --- a/src/uv-common.c
 +++ b/src/uv-common.c
 @@ -54,10 +54,10 @@ static uv__allocator_t uv__allocator = {
@@ -1048,16 +1148,16 @@
  }
  
  void* uv__malloc(size_t size) {
-@@ -653,7 +653,7 @@ void uv__fs_scandir_cleanup(uv_fs_t* req) {
+@@ -688,7 +688,7 @@ void uv__fs_scandir_cleanup(uv_fs_t* req) {
+   unsigned int n;
  
-   unsigned int* nbufs = uv__get_nbufs(req);
+   if (req->result >= 0) {
+-    dents = req->ptr;
++    dents = (uv__dirent_t**)(req->ptr);
+     nbufs = uv__get_nbufs(req);
  
--  dents = req->ptr;
-+  dents = (uv__dirent_t**)(req->ptr);
-   if (*nbufs > 0 && *nbufs != (unsigned int) req->result)
-     (*nbufs)--;
-   for (; *nbufs < (unsigned int) req->result; (*nbufs)++)
-@@ -680,7 +680,7 @@ int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) {
+     i = 0;
+@@ -721,7 +721,7 @@ int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) {
    nbufs = uv__get_nbufs(req);
    assert(nbufs);
  
@@ -1066,7 +1166,7 @@
  
    /* Free previous entity */
    if (*nbufs > 0)
-@@ -745,7 +745,7 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
+@@ -786,7 +786,7 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
    if (req->ptr == NULL)
      return;
  
@@ -1075,7 +1175,7 @@
    dirents = dir->dirents;
    req->ptr = NULL;
  
-@@ -791,7 +791,7 @@ uv_loop_t* uv_default_loop(void) {
+@@ -832,7 +832,7 @@ uv_loop_t* uv_default_loop(void) {
  uv_loop_t* uv_loop_new(void) {
    uv_loop_t* loop;
  
@@ -1085,7 +1185,7 @@
      return NULL;
  
 diff --git a/src/win/core.c b/src/win/core.c
-index 67af93e6..0752edff 100644
+index e9885a0f1ff3890a8d957c8793e22b01cedc0e97..87ade7ad65243ee3ff940320f84e1960390300e1 100644
 --- a/src/win/core.c
 +++ b/src/win/core.c
 @@ -98,7 +98,8 @@ static int uv__loops_add(uv_loop_t* loop) {
@@ -1108,7 +1208,7 @@
    if (!new_loops)
      goto loop_removed;
    uv__loops = new_loops;
-@@ -261,7 +263,7 @@ int uv_loop_init(uv_loop_t* loop) {
+@@ -264,7 +266,7 @@ int uv_loop_init(uv_loop_t* loop) {
  
    loop->endgame_handles = NULL;
  
@@ -1118,7 +1218,7 @@
      err = UV_ENOMEM;
      goto fail_timers_alloc;
 diff --git a/src/win/fs-event.c b/src/win/fs-event.c
-index 6758c7c7..15046731 100644
+index 6758c7c78bc1d6a5316a8ae7dc2d1e23cd0f32bc..150467313d576bfe2966b55f3d8cffa23cbb8ea3 100644
 --- a/src/win/fs-event.c
 +++ b/src/win/fs-event.c
 @@ -73,7 +73,7 @@ static void uv__relative_path(const WCHAR* filename,
@@ -1140,7 +1240,7 @@
        goto short_path_done;
      }
 diff --git a/src/win/fs-fd-hash-inl.h b/src/win/fs-fd-hash-inl.h
-index 0b532af1..703a8d8f 100644
+index 0b532af12d4371c2311bd50a66913287a0716f43..703a8d8f87de1089ac8b18bd817d416d48dc442e 100644
 --- a/src/win/fs-fd-hash-inl.h
 +++ b/src/win/fs-fd-hash-inl.h
 @@ -146,7 +146,7 @@ INLINE static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) {
@@ -1153,19 +1253,28 @@
          uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
        }
 diff --git a/src/win/fs.c b/src/win/fs.c
-index 79230799..8374012f 100644
+index fc209c54f470edaa031009979061cff071cbf66d..328c8f2e0513562b53c948ffea59d0841e14b264 100644
 --- a/src/win/fs.c
 +++ b/src/win/fs.c
-@@ -285,7 +285,7 @@ static int fs__wide_to_utf8(WCHAR* w_source_ptr,
+@@ -258,7 +258,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path,
      return 0;
    }
  
--  target = uv__malloc(target_len + 1);
-+  target = (char*)uv__malloc(target_len + 1);
-   if (target == NULL) {
-     SetLastError(ERROR_OUTOFMEMORY);
-     return -1;
-@@ -1464,7 +1464,7 @@ void fs__scandir(uv_fs_t* req) {
+-  buf = uv__malloc(buf_sz);
++  buf = (WCHAR *)uv__malloc(buf_sz);
+   if (buf == NULL) {
+     return ERROR_OUTOFMEMORY;
+   }
+@@ -376,7 +376,7 @@ static int fs__wide_to_wtf8(WCHAR* w_source_ptr,
+     return 0;
+ 
+   if (*target_ptr == NULL) {
+-    target = uv__malloc(target_len + 1);
++    target = (char *)uv__malloc(target_len + 1);
+     if (target == NULL) {
+       SetLastError(ERROR_OUTOFMEMORY);
+       return -1;
+@@ -1575,7 +1575,7 @@ void fs__scandir(uv_fs_t* req) {
        if (dirents_used >= dirents_size) {
          size_t new_dirents_size =
              dirents_size == 0 ? dirents_initial_size : dirents_size << 1;
@@ -1174,16 +1283,16 @@
              uv__realloc(dirents, new_dirents_size * sizeof *dirents);
  
          if (new_dirents == NULL)
-@@ -1478,7 +1478,7 @@ void fs__scandir(uv_fs_t* req) {
+@@ -1589,7 +1589,7 @@ void fs__scandir(uv_fs_t* req) {
         * includes room for the first character of the filename, but `utf8_len`
         * doesn't count the NULL terminator at this point.
         */
--      dirent = uv__malloc(sizeof *dirent + utf8_len);
-+      dirent = (uv__dirent_t*)uv__malloc(sizeof *dirent + utf8_len);
+-      dirent = uv__malloc(sizeof *dirent + wtf8_len);
++      dirent = (uv__dirent_t*)uv__malloc(sizeof *dirent + wtf8_len);
        if (dirent == NULL)
          goto out_of_memory_error;
  
-@@ -1589,7 +1589,7 @@ void fs__opendir(uv_fs_t* req) {
+@@ -1691,7 +1691,7 @@ void fs__opendir(uv_fs_t* req) {
      goto error;
    }
  
@@ -1192,7 +1301,7 @@
    if (dir == NULL) {
      SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
      goto error;
-@@ -1604,7 +1604,7 @@ void fs__opendir(uv_fs_t* req) {
+@@ -1706,7 +1706,7 @@ void fs__opendir(uv_fs_t* req) {
    else
      fmt = L"%s\\*";
  
@@ -1201,7 +1310,7 @@
    if (find_path == NULL) {
      SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
      goto error;
-@@ -1641,7 +1641,7 @@ void fs__readdir(uv_fs_t* req) {
+@@ -1743,7 +1743,7 @@ void fs__readdir(uv_fs_t* req) {
    int r;
  
    req->flags |= UV_FS_FREE_PTR;
@@ -1210,7 +1319,7 @@
    dirents = dir->dirents;
    memset(dirents, 0, dir->nentries * sizeof(*dir->dirents));
    find_data = &dir->find_data;
-@@ -1698,7 +1698,7 @@ error:
+@@ -1800,7 +1800,7 @@ error:
  void fs__closedir(uv_fs_t* req) {
    uv_dir_t* dir;
  
@@ -1219,7 +1328,7 @@
    FindClose(dir->dir_handle);
    uv__free(req->ptr);
    SET_REQ_RESULT(req, 0);
-@@ -2627,7 +2627,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
+@@ -2791,7 +2791,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
      return -1;
    }
  
@@ -1228,7 +1337,7 @@
    if (w_realpath_buf == NULL) {
      SetLastError(ERROR_OUTOFMEMORY);
      return -1;
-@@ -2738,7 +2738,7 @@ retry_get_disk_free_space:
+@@ -2904,7 +2904,7 @@ retry_get_disk_free_space:
      }
  
      len = MAX_PATH + 1;
@@ -1237,7 +1346,7 @@
      if (pathw == NULL) {
        SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
        return;
-@@ -2754,7 +2754,7 @@ retry_get_full_path_name:
+@@ -2920,7 +2920,7 @@ retry_get_full_path_name:
        return;
      } else if (ret > len) {
        len = ret;
@@ -1246,7 +1355,7 @@
        if (pathw == NULL) {
          SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
          return;
-@@ -2770,7 +2770,7 @@ retry_get_full_path_name:
+@@ -2936,7 +2936,7 @@ retry_get_full_path_name:
      uv__free(pathw);
    }
  
@@ -1255,7 +1364,7 @@
    if (stat_fs == NULL) {
      SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
      return;
-@@ -2929,7 +2929,7 @@ int uv_fs_read(uv_loop_t* loop,
+@@ -3095,7 +3095,7 @@ int uv_fs_read(uv_loop_t* loop,
    req->fs.info.nbufs = nbufs;
    req->fs.info.bufs = req->fs.info.bufsml;
    if (nbufs > ARRAY_SIZE(req->fs.info.bufsml))
@@ -1264,7 +1373,7 @@
  
    if (req->fs.info.bufs == NULL) {
      SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
-@@ -2962,7 +2962,7 @@ int uv_fs_write(uv_loop_t* loop,
+@@ -3128,7 +3128,7 @@ int uv_fs_write(uv_loop_t* loop,
    req->fs.info.nbufs = nbufs;
    req->fs.info.bufs = req->fs.info.bufsml;
    if (nbufs > ARRAY_SIZE(req->fs.info.bufsml))
@@ -1274,10 +1383,10 @@
    if (req->fs.info.bufs == NULL) {
      SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
 diff --git a/src/win/pipe.c b/src/win/pipe.c
-index 99846181..cd77061a 100644
+index f0cac3822564e14052feb5e1934f54c57c78160d..c1739efe82b8755999145860b4da6b50c73518a2 100644
 --- a/src/win/pipe.c
 +++ b/src/win/pipe.c
-@@ -728,7 +728,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
+@@ -756,7 +756,7 @@ int uv_pipe_bind2(uv_pipe_t* handle,
  
    /* Convert name to UTF16. */
    nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR);
@@ -1286,7 +1395,7 @@
    if (!handle->name) {
      uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
    }
-@@ -841,7 +841,7 @@ void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
+@@ -906,7 +906,7 @@ int uv_pipe_connect2(uv_connect_t* req,
  
    /* Convert name to UTF16. */
    nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR);
@@ -1295,7 +1404,16 @@
    if (!handle->name) {
      uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
    }
-@@ -1453,7 +1453,7 @@ static int uv__build_coalesced_write_req(uv_write_t* user_req,
+@@ -924,7 +924,7 @@ int uv_pipe_connect2(uv_connect_t* req,
+   pipeHandle = open_named_pipe(handle->name, &duplex_flags);
+   if (pipeHandle == INVALID_HANDLE_VALUE) {
+     if (GetLastError() == ERROR_PIPE_BUSY) {
+-      req->u.connect.name = uv__malloc(nameSize);
++      req->u.connect.name = (WCHAR *)uv__malloc(nameSize);
+       if (!req->u.connect.name) {
+         uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
+       }
+@@ -1528,7 +1528,7 @@ static int uv__build_coalesced_write_req(uv_write_t* user_req,
                         data_length;                  /* (c) */
  
    /* Allocate buffer. */
@@ -1304,7 +1422,7 @@
    if (heap_buffer == NULL)
      return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */
  
-@@ -1698,7 +1698,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop,
+@@ -1777,7 +1777,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop,
      bufs = stack_bufs;
    } else {
      /* Use heap-allocated buffer array. */
@@ -1313,7 +1431,7 @@
      if (bufs == NULL)
        return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */
    }
-@@ -2430,7 +2430,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size)
+@@ -2514,7 +2514,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size)
                                        FileNameInformation);
    if (nt_status == STATUS_BUFFER_OVERFLOW) {
      name_size = sizeof(*name_info) + tmp_name_info.FileNameLength;
@@ -1323,10 +1441,10 @@
        *size = 0;
        err = UV_ENOMEM;
 diff --git a/src/win/process.c b/src/win/process.c
-index 24c63339..e857db3e 100644
+index ed44adc67c6d52785a199206d9ba0357e2d0b045..b383e8b405db56d413985b38df216d09c58ec4a0 100644
 --- a/src/win/process.c
 +++ b/src/win/process.c
-@@ -616,8 +616,8 @@ error:
+@@ -615,8 +615,8 @@ error:
  
  
  int env_strncmp(const wchar_t* a, int na, const wchar_t* b) {
@@ -1337,7 +1455,7 @@
    wchar_t* A;
    wchar_t* B;
    int nb;
-@@ -634,8 +634,8 @@ int env_strncmp(const wchar_t* a, int na, const wchar_t* b) {
+@@ -633,8 +633,8 @@ int env_strncmp(const wchar_t* a, int na, const wchar_t* b) {
    assert(b_eq);
    nb = b_eq - b;
  
@@ -1348,7 +1466,7 @@
  
    r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, a, na, A, na);
    assert(r==na);
-@@ -718,7 +718,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
+@@ -717,7 +717,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
    if (dst_copy == NULL && env_len > 0) {
      return ERROR_OUTOFMEMORY;
    }
@@ -1357,7 +1475,7 @@
  
    ptr = dst_copy;
    ptr_copy = env_copy;
-@@ -772,7 +772,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
+@@ -771,7 +771,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
    }
  
    /* final pass: copy, in sort order, and inserting required variables */
@@ -1367,10 +1485,10 @@
      uv__free(dst_copy);
      return ERROR_OUTOFMEMORY;
 diff --git a/src/win/tcp.c b/src/win/tcp.c
-index b6aa4c51..4cccee42 100644
+index 187f36e2a61c870b0d16e17e9d4a9e1161ba8851..d8da4d941a51b0625fc0c072342ec4edf74c0ea3 100644
 --- a/src/win/tcp.c
 +++ b/src/win/tcp.c
-@@ -612,7 +612,7 @@ int uv__tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
+@@ -585,7 +585,7 @@ int uv__tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
  
    if (handle->tcp.serv.accept_reqs == NULL) {
      handle->tcp.serv.accept_reqs =
@@ -1380,7 +1498,7 @@
        uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
      }
 diff --git a/src/win/thread.c b/src/win/thread.c
-index d3b1c96b..9ad60c91 100644
+index 57c25e8f5a861c9d8a4c402c260d3ac235200423..57f1698f595e2410a51044f7f228b5a235206819 100644
 --- a/src/win/thread.c
 +++ b/src/win/thread.c
 @@ -98,7 +98,7 @@ static UINT __stdcall uv__thread_start(void* arg) {
@@ -1402,10 +1520,19 @@
      return UV_ENOMEM;
  
 diff --git a/src/win/util.c b/src/win/util.c
-index 99432053..c655f532 100644
+index f6ec79cd57b5010ed5fd6829d952bcdacc8b7671..1cfd7b2caf0d4ad1a6a66df9406c21f4e2b69b04 100644
 --- a/src/win/util.c
 +++ b/src/win/util.c
-@@ -164,7 +164,7 @@ int uv_cwd(char* buffer, size_t* size) {
+@@ -160,7 +160,7 @@ static int uv__cwd(WCHAR** buf, DWORD *len) {
+       return uv_translate_sys_error(GetLastError());
+ 
+     /* |t| is the size of the buffer _including_ nul. */
+-    p = uv__malloc(t * sizeof(*p));
++    p = (WCHAR *)uv__malloc(t * sizeof(*p));
+     if (p == NULL)
+       return UV_ENOMEM;
+ 
+@@ -265,7 +265,7 @@ int uv_chdir(const char* dir) {
    if (utf16_len == 0) {
      return uv_translate_sys_error(GetLastError());
    }
@@ -1414,25 +1541,7 @@
    if (utf16_buffer == NULL) {
      return UV_ENOMEM;
    }
-@@ -242,7 +242,7 @@ int uv_chdir(const char* dir) {
-   if (utf16_len == 0) {
-     return uv_translate_sys_error(GetLastError());
-   }
--  utf16_buffer = uv__malloc(utf16_len * sizeof(WCHAR));
-+  utf16_buffer = (WCHAR*)uv__malloc(utf16_len * sizeof(WCHAR));
-   if (utf16_buffer == NULL) {
-     return UV_ENOMEM;
-   }
-@@ -268,7 +268,7 @@ int uv_chdir(const char* dir) {
-   new_utf16_len = GetCurrentDirectoryW(utf16_len, utf16_buffer);
-   if (new_utf16_len > utf16_len ) {
-     uv__free(utf16_buffer);
--    utf16_buffer = uv__malloc(new_utf16_len * sizeof(WCHAR));
-+    utf16_buffer = (WCHAR*)uv__malloc(new_utf16_len * sizeof(WCHAR));
-     if (utf16_buffer == NULL) {
-       /* When updating the environment variable fails, return UV_OK anyway.
-        * We did successfully change current working directory, only updating
-@@ -573,14 +573,14 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
+@@ -623,14 +623,14 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
    GetSystemInfo(&system_info);
    cpu_count = system_info.dwNumberOfProcessors;
  
@@ -1449,7 +1558,7 @@
    if (sppi == NULL) {
      err = ERROR_OUTOFMEMORY;
      goto error;
-@@ -802,7 +802,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
+@@ -774,7 +774,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
        case ERROR_BUFFER_OVERFLOW:
          /* This happens when win_address_buf is NULL or too small to hold all
           * adapters. */
@@ -1459,7 +1568,7 @@
          if (win_address_buf == NULL)
            return UV_ENOMEM;
  
-@@ -810,7 +811,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
+@@ -782,7 +783,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
  
        case ERROR_NO_DATA: {
          /* No adapters were found. */
@@ -1468,7 +1577,7 @@
          if (uv_address_buf == NULL)
            return UV_ENOMEM;
  
-@@ -887,7 +888,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
+@@ -859,7 +860,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
    }
  
    /* Allocate space to store interface data plus adapter names. */
@@ -1477,7 +1586,7 @@
    if (uv_address_buf == NULL) {
      uv__free(win_address_buf);
      return UV_ENOMEM;
-@@ -1131,7 +1132,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
+@@ -1074,7 +1075,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
    }
    /* Include space for terminating null char. */
    len += 1;
@@ -1486,7 +1595,7 @@
    if (path == NULL) {
      return UV_ENOMEM;
    }
-@@ -1221,7 +1222,7 @@ int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8) {
+@@ -1153,7 +1154,7 @@ int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8) {
    /* Allocate the destination buffer adding an extra byte for the terminating
     * NULL. If utf16len is not -1 WideCharToMultiByte will not add it, so
     * we do it ourselves always, just in case. */
@@ -1495,7 +1604,7 @@
  
    if (*utf8 == NULL)
      return UV_ENOMEM;
-@@ -1269,7 +1270,7 @@ int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) {
+@@ -1201,7 +1202,7 @@ int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) {
    /* Allocate the destination buffer adding an extra byte for the terminating
     * NULL. If utf8len is not -1 MultiByteToWideChar will not add it, so
     * we do it ourselves always, just in case. */
@@ -1504,7 +1613,7 @@
  
    if (*utf16 == NULL)
      return UV_ENOMEM;
-@@ -1310,7 +1311,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
+@@ -1242,7 +1243,7 @@ static int uv__getpwuid_r(uv_passwd_t* pwd) {
      return uv_translate_sys_error(r);
    }
  
@@ -1513,7 +1622,7 @@
    if (path == NULL) {
      CloseHandle(token);
      return UV_ENOMEM;
-@@ -1381,7 +1382,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
+@@ -1323,7 +1324,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
  
    for (penv = env, i = 0; *penv != L'\0'; penv += wcslen(penv) + 1, i++);
  
@@ -1522,7 +1631,7 @@
    if (*envitems == NULL) {
      FreeEnvironmentStringsW(env);
      return UV_ENOMEM;
-@@ -1471,7 +1472,7 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) {
+@@ -1413,7 +1414,7 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) {
        uv__free(var);
  
      varlen = 1 + len;
diff --git a/upstream_utils/libuv_patches/0002-Fix-warnings.patch b/upstream_utils/libuv_patches/0002-Fix-warnings.patch
deleted file mode 100644
index fedaea0..0000000
--- a/upstream_utils/libuv_patches/0002-Fix-warnings.patch
+++ /dev/null
@@ -1,365 +0,0 @@
-From f7b4492d37b35a64a3a6c5bbbdb375494095b6ff Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Tue, 26 Apr 2022 15:09:43 -0400
-Subject: [PATCH 2/9] Fix warnings
-
----
- include/uv/win.h    |   5 +++
- src/idna.c          |   2 +-
- src/inet.c          |   4 ++
- src/threadpool.c    |   4 ++
- src/unix/core.c     |  12 ++++-
- src/unix/darwin.c   | 106 +++++++++++++++++++++++---------------------
- src/unix/internal.h |   4 +-
- src/unix/thread.c   |   6 ---
- src/uv-common.c     |   8 ++++
- src/win/fs-event.c  |   2 +
- src/win/fs.c        |   2 +
- src/win/pipe.c      |   2 +
- src/win/process.c   |   2 +
- src/win/tty.c       |   2 +
- 14 files changed, 99 insertions(+), 62 deletions(-)
-
-diff --git a/include/uv/win.h b/include/uv/win.h
-index 56a4cf11..10d5e8f1 100644
---- a/include/uv/win.h
-+++ b/include/uv/win.h
-@@ -201,11 +201,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
-              LPWSAOVERLAPPED overlapped,
-              LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
- 
-+#pragma warning(push)
-+#pragma warning(disable : 28251)
-+
- #ifndef _NTDEF_
-   typedef LONG NTSTATUS;
-   typedef NTSTATUS *PNTSTATUS;
- #endif
- 
-+#pragma warning(pop)
-+
- #ifndef RTL_CONDITION_VARIABLE_INIT
-   typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
- #endif
-diff --git a/src/idna.c b/src/idna.c
-index 93d982ca..36a39a08 100644
---- a/src/idna.c
-+++ b/src/idna.c
-@@ -106,7 +106,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
-                                   char** d, char* de) {
-   static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789";
-   const char* ss;
--  unsigned c;
-+  unsigned c = 0;
-   unsigned h;
-   unsigned k;
-   unsigned n;
-diff --git a/src/inet.c b/src/inet.c
-index ca8b6ac8..1b190255 100644
---- a/src/inet.c
-+++ b/src/inet.c
-@@ -27,6 +27,10 @@
- #include "uv.h"
- #include "uv-common.h"
- 
-+#ifdef _WIN32
-+#pragma warning(disable : 6001)
-+#endif
-+
- #define UV__INET_ADDRSTRLEN         16
- #define UV__INET6_ADDRSTRLEN        46
- 
-diff --git a/src/threadpool.c b/src/threadpool.c
-index 1241ace1..718972c3 100644
---- a/src/threadpool.c
-+++ b/src/threadpool.c
-@@ -27,6 +27,10 @@
- 
- #include <stdlib.h>
- 
-+#ifdef _WIN32
-+#pragma warning(disable: 6001 6011)
-+#endif
-+
- #define MAX_THREADPOOL_SIZE 1024
- 
- static uv_once_t once = UV_ONCE_INIT;
-diff --git a/src/unix/core.c b/src/unix/core.c
-index 6353b0e3..223c5513 100644
---- a/src/unix/core.c
-+++ b/src/unix/core.c
-@@ -544,6 +544,16 @@ int uv__accept(int sockfd) {
-   return peerfd;
- }
- 
-+#if defined(__APPLE__)
-+#pragma GCC diagnostic push
-+#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
-+#if defined(__LP64__)
-+  extern "C" int close$NOCANCEL(int);
-+#else
-+  extern "C" int close$NOCANCEL$UNIX2003(int);
-+#endif
-+#pragma GCC diagnostic pop
-+#endif
- 
- /* close() on macos has the "interesting" quirk that it fails with EINTR
-  * without closing the file descriptor when a thread is in the cancel state.
-@@ -558,10 +568,8 @@ int uv__close_nocancel(int fd) {
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
- #if defined(__LP64__) || TARGET_OS_IPHONE
--  extern int close$NOCANCEL(int);
-   return close$NOCANCEL(fd);
- #else
--  extern int close$NOCANCEL$UNIX2003(int);
-   return close$NOCANCEL$UNIX2003(fd);
- #endif
- #pragma GCC diagnostic pop
-diff --git a/src/unix/darwin.c b/src/unix/darwin.c
-index 5fbf7342..eeb35720 100644
---- a/src/unix/darwin.c
-+++ b/src/unix/darwin.c
-@@ -253,64 +253,68 @@ static int uv__get_cpu_speed(uint64_t* speed) {
- 
- #define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
- 
--  kr = pIOMasterPort(MACH_PORT_NULL, &mach_port);
--  assert(kr == KERN_SUCCESS);
--  CFMutableDictionaryRef classes_to_match
--      = pIOServiceMatching("IOPlatformDevice");
--  kr = pIOServiceGetMatchingServices(mach_port, classes_to_match, &it);
--  assert(kr == KERN_SUCCESS);
--  service = pIOIteratorNext(it);
--
--  CFStringRef device_type_str = S("device_type");
--  CFStringRef clock_frequency_str = S("clock-frequency");
--
--  while (service != 0) {
--    CFDataRef data;
--    data = pIORegistryEntryCreateCFProperty(service,
--                                            device_type_str,
--                                            NULL,
--                                            0);
--    if (data) {
--      const UInt8* raw = pCFDataGetBytePtr(data);
--      if (strncmp((char*)raw, "cpu", 3) == 0 ||
--          strncmp((char*)raw, "processor", 9) == 0) {
--        CFDataRef freq_ref;
--        freq_ref = pIORegistryEntryCreateCFProperty(service,
--                                                    clock_frequency_str,
--                                                    NULL,
--                                                    0);
--        if (freq_ref) {
--          const UInt8* freq_ref_ptr = pCFDataGetBytePtr(freq_ref);
--          CFIndex len = pCFDataGetLength(freq_ref);
--          if (len == 8)
--            memcpy(speed, freq_ref_ptr, 8);
--          else if (len == 4) {
--            uint32_t v;
--            memcpy(&v, freq_ref_ptr, 4);
--            *speed = v;
--          } else {
--            *speed = 0;
--          }
-+  // Braces ensure goto doesn't jump into device_type_str's and
-+  // clock_frequency_str's lifetimes after their initialization
-+  {
-+    kr = pIOMasterPort(MACH_PORT_NULL, &mach_port);
-+    assert(kr == KERN_SUCCESS);
-+    CFMutableDictionaryRef classes_to_match
-+        = pIOServiceMatching("IOPlatformDevice");
-+    kr = pIOServiceGetMatchingServices(mach_port, classes_to_match, &it);
-+    assert(kr == KERN_SUCCESS);
-+    service = pIOIteratorNext(it);
- 
--          pCFRelease(freq_ref);
--          pCFRelease(data);
--          break;
-+    CFStringRef device_type_str = S("device_type");
-+    CFStringRef clock_frequency_str = S("clock-frequency");
-+
-+    while (service != 0) {
-+      CFDataRef data;
-+      data = pIORegistryEntryCreateCFProperty(service,
-+                                              device_type_str,
-+                                              NULL,
-+                                              0);
-+      if (data) {
-+        const UInt8* raw = pCFDataGetBytePtr(data);
-+        if (strncmp((char*)raw, "cpu", 3) == 0 ||
-+            strncmp((char*)raw, "processor", 9) == 0) {
-+          CFDataRef freq_ref;
-+          freq_ref = pIORegistryEntryCreateCFProperty(service,
-+                                                      clock_frequency_str,
-+                                                      NULL,
-+                                                      0);
-+          if (freq_ref) {
-+            const UInt8* freq_ref_ptr = pCFDataGetBytePtr(freq_ref);
-+            CFIndex len = pCFDataGetLength(freq_ref);
-+            if (len == 8)
-+              memcpy(speed, freq_ref_ptr, 8);
-+            else if (len == 4) {
-+              uint32_t v;
-+              memcpy(&v, freq_ref_ptr, 4);
-+              *speed = v;
-+            } else {
-+              *speed = 0;
-+            }
-+
-+            pCFRelease(freq_ref);
-+            pCFRelease(data);
-+            break;
-+          }
-         }
-+        pCFRelease(data);
-       }
--      pCFRelease(data);
--    }
- 
--    service = pIOIteratorNext(it);
--  }
-+      service = pIOIteratorNext(it);
-+    }
- 
--  pIOObjectRelease(it);
-+    pIOObjectRelease(it);
- 
--  err = 0;
-+    err = 0;
- 
--  if (device_type_str != NULL)
--    pCFRelease(device_type_str);
--  if (clock_frequency_str != NULL)
--    pCFRelease(clock_frequency_str);
-+    if (device_type_str != NULL)
-+      pCFRelease(device_type_str);
-+    if (clock_frequency_str != NULL)
-+      pCFRelease(clock_frequency_str);
-+  }
- 
- out:
-   if (core_foundation_handle != NULL)
-diff --git a/src/unix/internal.h b/src/unix/internal.h
-index cee35c21..f9d1666d 100644
---- a/src/unix/internal.h
-+++ b/src/unix/internal.h
-@@ -312,8 +312,8 @@ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) {
-   loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000;
- }
- 
--UV_UNUSED(static char* uv__basename_r(const char* path)) {
--  char* s;
-+UV_UNUSED(static const char* uv__basename_r(const char* path)) {
-+  const char* s;
- 
-   s = strrchr(path, '/');
-   if (s == NULL)
-diff --git a/src/unix/thread.c b/src/unix/thread.c
-index 759cd0c2..64726bd6 100644
---- a/src/unix/thread.c
-+++ b/src/unix/thread.c
-@@ -244,12 +244,6 @@ int uv_thread_create_ex(uv_thread_t* tid,
-   size_t stack_size;
-   size_t min_stack_size;
- 
--  /* Used to squelch a -Wcast-function-type warning. */
--  union {
--    void (*in)(void*);
--    void* (*out)(void*);
--  } f;
--
-   stack_size =
-       params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
- 
-diff --git a/src/uv-common.c b/src/uv-common.c
-index dfb606e3..49026c03 100644
---- a/src/uv-common.c
-+++ b/src/uv-common.c
-@@ -758,6 +758,10 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
-   }
- }
- 
-+#ifdef __clang__
-+# pragma clang diagnostic push
-+# pragma clang diagnostic ignored "-Wvarargs"
-+#endif
- 
- int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
-   va_list ap;
-@@ -771,6 +775,10 @@ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
-   return err;
- }
- 
-+#ifdef __clang__
-+# pragma clang diagnostic pop
-+#endif
-+
- 
- static uv_loop_t default_loop_struct;
- static uv_loop_t* default_loop_ptr;
-diff --git a/src/win/fs-event.c b/src/win/fs-event.c
-index 15046731..3244a4e4 100644
---- a/src/win/fs-event.c
-+++ b/src/win/fs-event.c
-@@ -19,6 +19,8 @@
-  * IN THE SOFTWARE.
-  */
- 
-+#define _CRT_NONSTDC_NO_WARNINGS
-+
- #include <assert.h>
- #include <errno.h>
- #include <stdio.h>
-diff --git a/src/win/fs.c b/src/win/fs.c
-index 8374012f..f71b3c04 100644
---- a/src/win/fs.c
-+++ b/src/win/fs.c
-@@ -19,6 +19,8 @@
-  * IN THE SOFTWARE.
-  */
- 
-+#define _CRT_NONSTDC_NO_WARNINGS
-+
- #include <assert.h>
- #include <stdlib.h>
- #include <direct.h>
-diff --git a/src/win/pipe.c b/src/win/pipe.c
-index cd77061a..f413a72d 100644
---- a/src/win/pipe.c
-+++ b/src/win/pipe.c
-@@ -19,6 +19,8 @@
-  * IN THE SOFTWARE.
-  */
- 
-+#define _CRT_NONSTDC_NO_WARNINGS
-+
- #include <assert.h>
- #include <io.h>
- #include <stdio.h>
-diff --git a/src/win/process.c b/src/win/process.c
-index e857db3e..a49016f6 100644
---- a/src/win/process.c
-+++ b/src/win/process.c
-@@ -19,6 +19,8 @@
-  * IN THE SOFTWARE.
-  */
- 
-+#define _CRT_NONSTDC_NO_WARNINGS
-+
- #include <assert.h>
- #include <io.h>
- #include <stdio.h>
-diff --git a/src/win/tty.c b/src/win/tty.c
-index 267ca645..d7522668 100644
---- a/src/win/tty.c
-+++ b/src/win/tty.c
-@@ -19,6 +19,8 @@
-  * IN THE SOFTWARE.
-  */
- 
-+#define _CRT_NONSTDC_NO_WARNINGS
-+
- #include <assert.h>
- #include <io.h>
- #include <string.h>
diff --git a/upstream_utils/libuv_patches/0003-Fix-warnings.patch b/upstream_utils/libuv_patches/0003-Fix-warnings.patch
new file mode 100644
index 0000000..cbf5c70
--- /dev/null
+++ b/upstream_utils/libuv_patches/0003-Fix-warnings.patch
@@ -0,0 +1,297 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: PJ Reiniger <pj.reiniger@gmail.com>
+Date: Tue, 26 Apr 2022 15:09:43 -0400
+Subject: [PATCH 03/10] Fix warnings
+
+---
+ include/uv/win.h    |  5 +++++
+ src/idna.c          |  2 +-
+ src/inet.c          |  4 ++++
+ src/threadpool.c    |  4 ++++
+ src/unix/core.c     | 12 ++++++++++--
+ src/unix/internal.h |  4 ++--
+ src/unix/linux.c    | 15 ++++++++++++---
+ src/unix/thread.c   |  6 ------
+ src/uv-common.c     |  8 ++++++++
+ src/win/fs-event.c  |  2 ++
+ src/win/fs.c        |  2 ++
+ src/win/pipe.c      |  2 ++
+ src/win/process.c   |  2 ++
+ src/win/thread.c    |  4 ++--
+ src/win/tty.c       |  2 ++
+ 15 files changed, 58 insertions(+), 16 deletions(-)
+
+diff --git a/include/uv/win.h b/include/uv/win.h
+index eb74776978340a4910194bae35a9da6493e8c0a6..6d0afe69e7dd4caf4c9459e548fe75cf0c51b501 100644
+--- a/include/uv/win.h
++++ b/include/uv/win.h
+@@ -201,11 +201,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
+              LPWSAOVERLAPPED overlapped,
+              LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
+ 
++#pragma warning(push)
++#pragma warning(disable : 28251)
++
+ #ifndef _NTDEF_
+   typedef LONG NTSTATUS;
+   typedef NTSTATUS *PNTSTATUS;
+ #endif
+ 
++#pragma warning(pop)
++
+ #ifndef RTL_CONDITION_VARIABLE_INIT
+   typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
+ #endif
+diff --git a/src/idna.c b/src/idna.c
+index 93d982ca018f2d39d9c0ffab07998c2c637029eb..36a39a089019fb4c2a35ec84516658c392eec0a3 100644
+--- a/src/idna.c
++++ b/src/idna.c
+@@ -106,7 +106,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
+                                   char** d, char* de) {
+   static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789";
+   const char* ss;
+-  unsigned c;
++  unsigned c = 0;
+   unsigned h;
+   unsigned k;
+   unsigned n;
+diff --git a/src/inet.c b/src/inet.c
+index dd94bea3886ca37945fcad7909d765e3700e3c21..71c9e5b774d64d505e6c6d6ed2637178b8532d4d 100644
+--- a/src/inet.c
++++ b/src/inet.c
+@@ -22,6 +22,10 @@
+ #include "uv.h"
+ #include "uv-common.h"
+ 
++#ifdef _WIN32
++#pragma warning(disable : 6001)
++#endif
++
+ #define UV__INET_ADDRSTRLEN         16
+ #define UV__INET6_ADDRSTRLEN        46
+ 
+diff --git a/src/threadpool.c b/src/threadpool.c
+index f572de5aaf1a1b150e58c7b989949441cac279c4..aa282af468935b680140295a175e503ca82d8fa4 100644
+--- a/src/threadpool.c
++++ b/src/threadpool.c
+@@ -27,6 +27,10 @@
+ 
+ #include <stdlib.h>
+ 
++#ifdef _WIN32
++#pragma warning(disable: 6001 6011)
++#endif
++
+ #define MAX_THREADPOOL_SIZE 1024
+ 
+ static uv_once_t once = UV_ONCE_INIT;
+diff --git a/src/unix/core.c b/src/unix/core.c
+index 28c036f94f3e76717afa651451969f128c5a573c..268fc9652f437eb0d0cda2a9e0b06b9e91eb9742 100644
+--- a/src/unix/core.c
++++ b/src/unix/core.c
+@@ -575,6 +575,16 @@ int uv__accept(int sockfd) {
+   return peerfd;
+ }
+ 
++#if defined(__APPLE__)
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
++#if defined(__LP64__)
++  extern "C" int close$NOCANCEL(int);
++#else
++  extern "C" int close$NOCANCEL$UNIX2003(int);
++#endif
++#pragma GCC diagnostic pop
++#endif
+ 
+ /* close() on macos has the "interesting" quirk that it fails with EINTR
+  * without closing the file descriptor when a thread is in the cancel state.
+@@ -589,10 +599,8 @@ int uv__close_nocancel(int fd) {
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
+ #if defined(__LP64__) || TARGET_OS_IPHONE
+-  extern int close$NOCANCEL(int);
+   return close$NOCANCEL(fd);
+ #else
+-  extern int close$NOCANCEL$UNIX2003(int);
+   return close$NOCANCEL$UNIX2003(fd);
+ #endif
+ #pragma GCC diagnostic pop
+diff --git a/src/unix/internal.h b/src/unix/internal.h
+index fe5885136039d5332623467b86bf52cd4b32ca0f..98c437dcadec5b5106d697e82d5394d459f55e47 100644
+--- a/src/unix/internal.h
++++ b/src/unix/internal.h
+@@ -384,8 +384,8 @@ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) {
+   loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000;
+ }
+ 
+-UV_UNUSED(static char* uv__basename_r(const char* path)) {
+-  char* s;
++UV_UNUSED(static const char* uv__basename_r(const char* path)) {
++  const char* s;
+ 
+   s = strrchr(path, '/');
+   if (s == NULL)
+diff --git a/src/unix/linux.c b/src/unix/linux.c
+index 9173850bd158eaf9c41deca38f9ba84762a027a1..157443792f1216c83b4221c3810d17c81c5913c4 100644
+--- a/src/unix/linux.c
++++ b/src/unix/linux.c
+@@ -1718,7 +1718,11 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
+     return UV__ERR(errno);
+   }
+ 
+-  fgets(buf, sizeof(buf), fp);  /* Skip first line. */
++  /* Skip first line. */
++  if (!fgets(buf, sizeof(buf), fp)) {
++    uv__free(cpus);
++    return UV__ERR(errno);
++  }
+ 
+   for (;;) {
+     memset(&t, 0, sizeof(t));
+@@ -1729,7 +1733,10 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
+     if (n != 7)
+       break;
+ 
+-    fgets(buf, sizeof(buf), fp);  /* Skip rest of line. */
++    /* Skip rest of line. */
++    if (!fgets(buf, sizeof(buf), fp)) {
++      break;
++    }
+ 
+     if (cpu >= ARRAY_SIZE(*cpus))
+       continue;
+@@ -1809,7 +1816,9 @@ nocpuinfo:
+     if (fp == NULL)
+       continue;
+ 
+-    fscanf(fp, "%llu", &(*cpus)[cpu].freq);
++    if (0 > fscanf(fp, "%llu", &(*cpus)[cpu].freq)) {
++      (*cpus)[cpu].freq = 0llu;
++    }
+     fclose(fp);
+     fp = NULL;
+   }
+diff --git a/src/unix/thread.c b/src/unix/thread.c
+index 531c6211bb4321e5f11031a0644b4e3ab9174396..f8600947e3e7df015c4302af4feee740707b2c46 100644
+--- a/src/unix/thread.c
++++ b/src/unix/thread.c
+@@ -137,12 +137,6 @@ int uv_thread_create_ex(uv_thread_t* tid,
+   size_t stack_size;
+   size_t min_stack_size;
+ 
+-  /* Used to squelch a -Wcast-function-type warning. */
+-  union {
+-    void (*in)(void*);
+-    void* (*out)(void*);
+-  } f;
+-
+   stack_size =
+       params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
+ 
+diff --git a/src/uv-common.c b/src/uv-common.c
+index c04f93596ab1f730576256d86e216ccb7f258b72..cd10b36b4a393e325ea03b93eb9897193ca9800b 100644
+--- a/src/uv-common.c
++++ b/src/uv-common.c
+@@ -799,6 +799,10 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
+   }
+ }
+ 
++#ifdef __clang__
++# pragma clang diagnostic push
++# pragma clang diagnostic ignored "-Wvarargs"
++#endif
+ 
+ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
+   va_list ap;
+@@ -812,6 +816,10 @@ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
+   return err;
+ }
+ 
++#ifdef __clang__
++# pragma clang diagnostic pop
++#endif
++
+ 
+ static uv_loop_t default_loop_struct;
+ static uv_loop_t* default_loop_ptr;
+diff --git a/src/win/fs-event.c b/src/win/fs-event.c
+index 150467313d576bfe2966b55f3d8cffa23cbb8ea3..3244a4e4320d7ce98f226b49b2634c65de89c213 100644
+--- a/src/win/fs-event.c
++++ b/src/win/fs-event.c
+@@ -19,6 +19,8 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#define _CRT_NONSTDC_NO_WARNINGS
++
+ #include <assert.h>
+ #include <errno.h>
+ #include <stdio.h>
+diff --git a/src/win/fs.c b/src/win/fs.c
+index 328c8f2e0513562b53c948ffea59d0841e14b264..565c05fff13c2e6e74091c1da7b31636d7fd370d 100644
+--- a/src/win/fs.c
++++ b/src/win/fs.c
+@@ -19,6 +19,8 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#define _CRT_NONSTDC_NO_WARNINGS
++
+ #include <assert.h>
+ #include <stdlib.h>
+ #include <direct.h>
+diff --git a/src/win/pipe.c b/src/win/pipe.c
+index c1739efe82b8755999145860b4da6b50c73518a2..258d6a684c67f154096a25e7226f1a7d08b93d5b 100644
+--- a/src/win/pipe.c
++++ b/src/win/pipe.c
+@@ -19,6 +19,8 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#define _CRT_NONSTDC_NO_WARNINGS
++
+ #include <assert.h>
+ #include <io.h>
+ #include <stdio.h>
+diff --git a/src/win/process.c b/src/win/process.c
+index b383e8b405db56d413985b38df216d09c58ec4a0..2b1b46259959867482079962d0ea44246a42e7cb 100644
+--- a/src/win/process.c
++++ b/src/win/process.c
+@@ -19,6 +19,8 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#define _CRT_NONSTDC_NO_WARNINGS
++
+ #include <assert.h>
+ #include <io.h>
+ #include <stdio.h>
+diff --git a/src/win/thread.c b/src/win/thread.c
+index 57f1698f595e2410a51044f7f228b5a235206819..03b33e9b4de6fe2532095d717a8639e8df454cce 100644
+--- a/src/win/thread.c
++++ b/src/win/thread.c
+@@ -204,8 +204,8 @@ int uv_thread_setaffinity(uv_thread_t* tid,
+   threadmask = 0;
+   for (i = 0; i < cpumasksize; i++) {
+     if (cpumask[i]) {
+-      if (procmask & (1 << i))
+-        threadmask |= 1 << i;
++      if (procmask & (1LL << i))
++        threadmask |= 1LL << i;
+       else
+         return UV_EINVAL;
+     }
+diff --git a/src/win/tty.c b/src/win/tty.c
+index 7e1f15544b177382a774300f832bc982d85bd62b..abbe1315883257d6825b794344dcd4cba9514097 100644
+--- a/src/win/tty.c
++++ b/src/win/tty.c
+@@ -19,6 +19,8 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#define _CRT_NONSTDC_NO_WARNINGS
++
+ #include <assert.h>
+ #include <io.h>
+ #include <string.h>
diff --git a/upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch b/upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch
similarity index 70%
rename from upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch
rename to upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch
index f55f5cc..c95b28a 100644
--- a/upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch
+++ b/upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch
@@ -1,21 +1,20 @@
-From dec4f95751a103f132e9674adf184188ec69176f Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 26 Apr 2022 15:19:14 -0400
-Subject: [PATCH 3/9] Preprocessor cleanup
+Subject: [PATCH 04/10] Preprocessor cleanup
 
 ---
- include/uv.h        | 18 +-----------------
+ include/uv.h        | 12 ------------
  include/uv/unix.h   |  8 --------
- include/uv/win.h    |  6 +-----
  src/unix/internal.h |  2 ++
  src/win/fs.c        |  1 +
  src/win/tty.c       |  2 ++
  src/win/util.c      |  8 ++++++++
  src/win/winsock.c   |  1 +
- 8 files changed, 16 insertions(+), 30 deletions(-)
+ 7 files changed, 14 insertions(+), 20 deletions(-)
 
 diff --git a/include/uv.h b/include/uv.h
-index ee1c94cc..dbaeb1e9 100644
+index 02397dd0fdd43d51f86c0dde9a62046702f12bdb..d5342b0d52232bbf83825948cc6bc09e5d74a4c7 100644
 --- a/include/uv.h
 +++ b/include/uv.h
 @@ -23,9 +23,6 @@
@@ -28,20 +27,7 @@
  
  #if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED)
  #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both."
-@@ -56,11 +53,7 @@ extern "C" {
- #include <stddef.h>
- #include <stdio.h>
- 
--#if defined(_MSC_VER) && _MSC_VER < 1600
--# include "uv/stdint-msvc2008.h"
--#else
--# include <stdint.h>
--#endif
-+#include <stdint.h>
- 
- #if defined(_WIN32)
- # include "uv/win.h"
-@@ -767,16 +760,10 @@ UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
+@@ -796,16 +793,10 @@ UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
  UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state);
  UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state);
  
@@ -57,8 +43,8 @@
 -
  UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
  
- /*
-@@ -1844,7 +1831,4 @@ UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
+ enum {
+@@ -1906,7 +1897,4 @@ UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
  #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
  #undef UV__ERR
  
@@ -67,7 +53,7 @@
 -#endif
  #endif /* UV_H */
 diff --git a/include/uv/unix.h b/include/uv/unix.h
-index 420be86c..256fef37 100644
+index 09f88a5674280d762c094d956e5dec6971c6a33e..e334cabe0280ef94bacbb1171049c71f17bf56ff 100644
 --- a/include/uv/unix.h
 +++ b/include/uv/unix.h
 @@ -47,14 +47,6 @@
@@ -85,28 +71,11 @@
  #elif defined(__APPLE__)
  # include "uv/darwin.h"
  #elif defined(__DragonFly__)       || \
-diff --git a/include/uv/win.h b/include/uv/win.h
-index 10d5e8f1..0a33366f 100644
---- a/include/uv/win.h
-+++ b/include/uv/win.h
-@@ -60,11 +60,7 @@ typedef struct pollfd {
- #include <fcntl.h>
- #include <sys/stat.h>
- 
--#if defined(_MSC_VER) && _MSC_VER < 1600
--# include "uv/stdint-msvc2008.h"
--#else
--# include <stdint.h>
--#endif
-+#include <stdint.h>
- 
- #include "uv/tree.h"
- #include "uv/threadpool.h"
 diff --git a/src/unix/internal.h b/src/unix/internal.h
-index f9d1666d..2b654157 100644
+index 98c437dcadec5b5106d697e82d5394d459f55e47..854d98a16a74c45e0b6cb92b17782de6803f6e28 100644
 --- a/src/unix/internal.h
 +++ b/src/unix/internal.h
-@@ -192,6 +192,8 @@ struct uv__stream_queued_fds_s {
+@@ -233,6 +233,8 @@ struct uv__statx {
  #if defined(__linux__) && O_NDELAY != O_NONBLOCK
  #undef uv__nonblock
  #define uv__nonblock uv__nonblock_fcntl
@@ -116,22 +85,22 @@
  
  /* core */
 diff --git a/src/win/fs.c b/src/win/fs.c
-index f71b3c04..71c9b169 100644
+index 565c05fff13c2e6e74091c1da7b31636d7fd370d..f415ddc2c39d09eea317fc857777acce1ce7d13e 100644
 --- a/src/win/fs.c
 +++ b/src/win/fs.c
-@@ -38,6 +38,7 @@
- #include "handle-inl.h"
- #include "fs-fd-hash-inl.h"
+@@ -40,6 +40,7 @@
+ 
+ #include <winioctl.h>
  
 +#pragma comment(lib, "Advapi32.lib")
  
  #define UV_FS_FREE_PATHS         0x0002
  #define UV_FS_FREE_PTR           0x0008
 diff --git a/src/win/tty.c b/src/win/tty.c
-index d7522668..9753784d 100644
+index abbe1315883257d6825b794344dcd4cba9514097..9bb3d9e830c901122da5e521e0c6b032dfd5044c 100644
 --- a/src/win/tty.c
 +++ b/src/win/tty.c
-@@ -42,6 +42,8 @@
+@@ -37,6 +37,8 @@
  #include "stream-inl.h"
  #include "req-inl.h"
  
@@ -141,10 +110,10 @@
  # define InterlockedOr _InterlockedOr
  #endif
 diff --git a/src/win/util.c b/src/win/util.c
-index c655f532..7a5dd2ef 100644
+index 1cfd7b2caf0d4ad1a6a66df9406c21f4e2b69b04..af18cfa6c106c5de0996e4fff9b4127aaa3b576b 100644
 --- a/src/win/util.c
 +++ b/src/win/util.c
-@@ -63,12 +63,20 @@
+@@ -64,12 +64,20 @@
  
  
  /* A RtlGenRandom() by any other name... */
@@ -166,7 +135,7 @@
  static uint64_t hrtime_frequency_ = 0;
  
 diff --git a/src/win/winsock.c b/src/win/winsock.c
-index a68b0953..7843e9f1 100644
+index a68b095366a78e78675b49a078749f45dbad6015..7843e9f13321c32419cebaacde82d30f471e11d7 100644
 --- a/src/win/winsock.c
 +++ b/src/win/winsock.c
 @@ -25,6 +25,7 @@
diff --git a/upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch b/upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch
similarity index 89%
rename from upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch
rename to upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch
index a29043b..e016c2e 100644
--- a/upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch
+++ b/upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch
@@ -1,14 +1,14 @@
-From 2d06f216dec3abbeaaabb465b945e09856d1b687 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 26 Apr 2022 15:24:47 -0400
-Subject: [PATCH 4/9] Cleanup problematic language
+Subject: [PATCH 05/10] Cleanup problematic language
 
 ---
  src/unix/tty.c | 21 +++++++++++----------
  1 file changed, 11 insertions(+), 10 deletions(-)
 
 diff --git a/src/unix/tty.c b/src/unix/tty.c
-index b4150525..ed81e26a 100644
+index d099bdb3b677212d21e06ac7bb1031c8e5386499..1bd217b5a15eed13a8349c479b53471dd36ca216 100644
 --- a/src/unix/tty.c
 +++ b/src/unix/tty.c
 @@ -79,7 +79,7 @@ int uv__tcsetattr(int fd, int how, const struct termios *term) {
@@ -18,7 +18,7 @@
 -static int uv__tty_is_slave(const int fd) {
 +static int uv__tty_is_peripheral(const int fd) {
    int result;
- #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ #if defined(__linux__) || defined(__FreeBSD__)
    int dummy;
 @@ -91,15 +91,16 @@ static int uv__tty_is_slave(const int fd) {
    result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0;
diff --git a/upstream_utils/libuv_patches/0005-Use-roborio-time.patch b/upstream_utils/libuv_patches/0005-Use-roborio-time.patch
deleted file mode 100644
index 46cc46f..0000000
--- a/upstream_utils/libuv_patches/0005-Use-roborio-time.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 690d487df2e60a01ab811aba34587466a38caead Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Tue, 26 Apr 2022 15:26:03 -0400
-Subject: [PATCH 5/9] Use roborio time
-
----
- src/unix/linux-core.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
-index 85f3fc01..12ed7ff1 100644
---- a/src/unix/linux-core.c
-+++ b/src/unix/linux-core.c
-@@ -67,6 +67,10 @@
- # define CLOCK_MONOTONIC_COARSE 6
- #endif
- 
-+#ifdef __FRC_ROBORIO__
-+#include "wpi/timestamp.h"
-+#endif
-+
- /* This is rather annoying: CLOCK_BOOTTIME lives in <linux/time.h> but we can't
-  * include that file because it conflicts with <time.h>. We'll just have to
-  * define it ourselves.
-@@ -118,6 +122,9 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
- 
- 
- uint64_t uv__hrtime(uv_clocktype_t type) {
-+#ifdef __FRC_ROBORIO__
-+  return wpi::Now() * 1000u;
-+#else
-   static clock_t fast_clock_id = -1;
-   struct timespec t;
-   clock_t clock_id;
-@@ -151,6 +158,7 @@ done:
-     return 0;  /* Not really possible. */
- 
-   return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec;
-+#endif
- }
- 
- 
diff --git a/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch b/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch
index 964d944..d4aa9a2 100644
--- a/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch
+++ b/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch
@@ -1,19 +1,18 @@
-From ad60aa8e1c03cc5f0c88159d37f63b0c063927c7 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 26 Apr 2022 15:28:52 -0400
-Subject: [PATCH 6/9] Style / comments cleanup
+Subject: [PATCH 06/10] Style / comments cleanup
 
 ---
  src/fs-poll.c     | 1 +
  src/unix/core.c   | 1 +
- src/unix/thread.c | 3 +--
  src/uv-common.c   | 1 +
  src/win/process.c | 1 -
  src/win/winsock.c | 1 +
- 6 files changed, 5 insertions(+), 3 deletions(-)
+ 5 files changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/src/fs-poll.c b/src/fs-poll.c
-index 5a39daed..1a7ca70d 100644
+index 5a39daed095502b2db34f23fcaf0ab04f31f96ff..1a7ca70d62c71f6eaef2b9985796cc46a6438869 100644
 --- a/src/fs-poll.c
 +++ b/src/fs-poll.c
 @@ -34,6 +34,7 @@
@@ -25,10 +24,10 @@
    uv_fs_poll_t* parent_handle;
    int busy_polling;
 diff --git a/src/unix/core.c b/src/unix/core.c
-index 223c5513..4c23f608 100644
+index 268fc9652f437eb0d0cda2a9e0b06b9e91eb9742..f53adc156a7c454c492abaeac29d90be436785fc 100644
 --- a/src/unix/core.c
 +++ b/src/unix/core.c
-@@ -544,6 +544,7 @@ int uv__accept(int sockfd) {
+@@ -575,6 +575,7 @@ int uv__accept(int sockfd) {
    return peerfd;
  }
  
@@ -36,39 +35,11 @@
  #if defined(__APPLE__)
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
-diff --git a/src/unix/thread.c b/src/unix/thread.c
-index 64726bd6..392a0715 100644
---- a/src/unix/thread.c
-+++ b/src/unix/thread.c
-@@ -85,7 +85,6 @@ error2:
-   return rc;
- }
- 
--
- int uv_barrier_wait(uv_barrier_t* barrier) {
-   struct _uv_barrier* b;
-   int last;
-@@ -94,6 +93,7 @@ int uv_barrier_wait(uv_barrier_t* barrier) {
-     return UV_EINVAL;
- 
-   b = barrier->b;
-+  /* Lock the mutex*/
-   uv_mutex_lock(&b->mutex);
- 
-   if (++b->in == b->threshold) {
-@@ -113,7 +113,6 @@ int uv_barrier_wait(uv_barrier_t* barrier) {
-   return last;
- }
- 
--
- void uv_barrier_destroy(uv_barrier_t* barrier) {
-   struct _uv_barrier* b;
- 
 diff --git a/src/uv-common.c b/src/uv-common.c
-index 49026c03..c9a32c03 100644
+index cd10b36b4a393e325ea03b93eb9897193ca9800b..bfcc3ef10f4fd7763221638947da6e02e7a17c33 100644
 --- a/src/uv-common.c
 +++ b/src/uv-common.c
-@@ -758,6 +758,7 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
+@@ -799,6 +799,7 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
    }
  }
  
@@ -77,7 +48,7 @@
  # pragma clang diagnostic push
  # pragma clang diagnostic ignored "-Wvarargs"
 diff --git a/src/win/process.c b/src/win/process.c
-index a49016f6..8e7835a5 100644
+index 2b1b46259959867482079962d0ea44246a42e7cb..18816d3b1e8c863f8ca74fe0104de1aecd0ae3fa 100644
 --- a/src/win/process.c
 +++ b/src/win/process.c
 @@ -35,7 +35,6 @@
@@ -89,7 +60,7 @@
  
  
 diff --git a/src/win/winsock.c b/src/win/winsock.c
-index 7843e9f1..cda82bc3 100644
+index 7843e9f13321c32419cebaacde82d30f471e11d7..cda82bc33c2c6e3dbfa9d978b5b40476228452bd 100644
 --- a/src/win/winsock.c
 +++ b/src/win/winsock.c
 @@ -25,6 +25,7 @@
diff --git a/upstream_utils/libuv_patches/0008-Fix-Win32-warning-suppression-pragma.patch b/upstream_utils/libuv_patches/0007-Fix-Win32-warning-suppression-pragma.patch
similarity index 64%
rename from upstream_utils/libuv_patches/0008-Fix-Win32-warning-suppression-pragma.patch
rename to upstream_utils/libuv_patches/0007-Fix-Win32-warning-suppression-pragma.patch
index bdc5f61..5ef597c 100644
--- a/upstream_utils/libuv_patches/0008-Fix-Win32-warning-suppression-pragma.patch
+++ b/upstream_utils/libuv_patches/0007-Fix-Win32-warning-suppression-pragma.patch
@@ -1,17 +1,17 @@
-From 49d5945dde1d182fd2d75cdf550120951796cb1f Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Tyler Veness <calcmogul@gmail.com>
 Date: Sat, 21 May 2022 22:58:06 -0700
-Subject: [PATCH 8/9] Fix Win32 warning suppression pragma
+Subject: [PATCH 07/10] Fix Win32 warning suppression pragma
 
 ---
  src/win/util.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/win/util.c b/src/win/util.c
-index 7a5dd2ef..d9888aec 100644
+index af18cfa6c106c5de0996e4fff9b4127aaa3b576b..9324992ec521cc3496e3e9304e600963a3f20897 100644
 --- a/src/win/util.c
 +++ b/src/win/util.c
-@@ -1750,7 +1750,7 @@ int uv_os_uname(uv_utsname_t* buffer) {
+@@ -1692,7 +1692,7 @@ int uv_os_uname(uv_utsname_t* buffer) {
    } else {
      /* Silence GetVersionEx() deprecation warning. */
      #ifdef _MSC_VER
diff --git a/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch b/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch
deleted file mode 100644
index 92032da..0000000
--- a/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From ee8a72764f602928cc08d16d661602c0aefde050 Mon Sep 17 00:00:00 2001
-From: Tyler Veness <calcmogul@gmail.com>
-Date: Tue, 17 May 2022 21:36:57 -0700
-Subject: [PATCH 7/9] Squelch GCC 12.1 warnings
-
----
- src/unix/stream.c | 9 +++++++++
- src/uv-common.c   | 9 +++++++++
- 2 files changed, 18 insertions(+)
-
-diff --git a/src/unix/stream.c b/src/unix/stream.c
-index c6cc50e7..fa25812a 100644
---- a/src/unix/stream.c
-+++ b/src/unix/stream.c
-@@ -938,7 +938,16 @@ static void uv__write_callbacks(uv_stream_t* stream) {
-   if (QUEUE_EMPTY(&stream->write_completed_queue))
-     return;
- 
-+// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
-+// it
-+#if __GNUC__ >= 12
-+#pragma GCC diagnostic push
-+#pragma GCC diagnostic ignored "-Wdangling-pointer="
-+#endif  // __GNUC__ >= 12
-   QUEUE_MOVE(&stream->write_completed_queue, &pq);
-+#if __GNUC__ >= 12
-+#pragma GCC diagnostic pop
-+#endif  // __GNUC__ >= 12
- 
-   while (!QUEUE_EMPTY(&pq)) {
-     /* Pop a req off write_completed_queue. */
-diff --git a/src/uv-common.c b/src/uv-common.c
-index c9a32c03..8ab600df 100644
---- a/src/uv-common.c
-+++ b/src/uv-common.c
-@@ -504,7 +504,16 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
-   QUEUE* q;
-   uv_handle_t* h;
- 
-+// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
-+// it
-+#if __GNUC__ >= 12
-+#pragma GCC diagnostic push
-+#pragma GCC diagnostic ignored "-Wdangling-pointer="
-+#endif  // __GNUC__ >= 12
-   QUEUE_MOVE(&loop->handle_queue, &queue);
-+#if __GNUC__ >= 12
-+#pragma GCC diagnostic pop
-+#endif  // __GNUC__ >= 12
-   while (!QUEUE_EMPTY(&queue)) {
-     q = QUEUE_HEAD(&queue);
-     h = QUEUE_DATA(q, uv_handle_t, handle_queue);
diff --git a/upstream_utils/libuv_patches/0008-Use-C-atomics.patch b/upstream_utils/libuv_patches/0008-Use-C-atomics.patch
new file mode 100644
index 0000000..ffdc588
--- /dev/null
+++ b/upstream_utils/libuv_patches/0008-Use-C-atomics.patch
@@ -0,0 +1,531 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Thu, 13 Jul 2023 22:13:47 -0700
+Subject: [PATCH 08/10] Use C++ atomics
+
+---
+ src/unix/async.c  | 25 +++++++++++++------------
+ src/unix/core.c   |  3 ++-
+ src/unix/fs.c     | 32 +++++++++++++++++---------------
+ src/unix/kqueue.c | 10 ++++++----
+ src/unix/linux.c  | 45 +++++++++++++++++++++++----------------------
+ src/unix/tty.c    |  5 +++--
+ src/uv-common.c   |  2 +-
+ src/uv-common.h   |  8 +++-----
+ 8 files changed, 68 insertions(+), 62 deletions(-)
+
+diff --git a/src/unix/async.c b/src/unix/async.c
+index 0ff2669e30a628dbb2df9e28ba14b38cf14114e5..fef4ae93343edc0341179a1c4739dcd831ef6e26 100644
+--- a/src/unix/async.c
++++ b/src/unix/async.c
+@@ -26,7 +26,6 @@
+ #include "internal.h"
+ 
+ #include <errno.h>
+-#include <stdatomic.h>
+ #include <stdio.h>  /* snprintf() */
+ #include <assert.h>
+ #include <stdlib.h>
+@@ -38,6 +37,8 @@
+ #include <sys/eventfd.h>
+ #endif
+ 
++#include <atomic>
++
+ static void uv__async_send(uv_loop_t* loop);
+ static int uv__async_start(uv_loop_t* loop);
+ static void uv__cpu_relax(void);
+@@ -63,14 +64,14 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {
+ 
+ 
+ int uv_async_send(uv_async_t* handle) {
+-  _Atomic int* pending;
+-  _Atomic int* busy;
++  std::atomic<int>* pending;
++  std::atomic<int>* busy;
+ 
+-  pending = (_Atomic int*) &handle->pending;
+-  busy = (_Atomic int*) &handle->u.fd;
++  pending = (std::atomic<int>*) &handle->pending;
++  busy = (std::atomic<int>*) &handle->u.fd;
+ 
+   /* Do a cheap read first. */
+-  if (atomic_load_explicit(pending, memory_order_relaxed) != 0)
++  if (atomic_load_explicit(pending, std::memory_order_relaxed) != 0)
+     return 0;
+ 
+   /* Set the loop to busy. */
+@@ -90,12 +91,12 @@ int uv_async_send(uv_async_t* handle) {
+ /* Wait for the busy flag to clear before closing.
+  * Only call this from the event loop thread. */
+ static void uv__async_spin(uv_async_t* handle) {
+-  _Atomic int* pending;
+-  _Atomic int* busy;
++  std::atomic<int>* pending;
++  std::atomic<int>* busy;
+   int i;
+ 
+-  pending = (_Atomic int*) &handle->pending;
+-  busy = (_Atomic int*) &handle->u.fd;
++  pending = (std::atomic<int>*) &handle->pending;
++  busy = (std::atomic<int>*) &handle->u.fd;
+ 
+   /* Set the pending flag first, so no new events will be added by other
+    * threads after this function returns. */
+@@ -135,7 +136,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
+   struct uv__queue queue;
+   struct uv__queue* q;
+   uv_async_t* h;
+-  _Atomic int *pending;
++  std::atomic<int> *pending;
+ 
+   assert(w == &loop->async_io_watcher);
+ 
+@@ -166,7 +167,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
+     uv__queue_insert_tail(&loop->async_handles, q);
+ 
+     /* Atomically fetch and clear pending flag */
+-    pending = (_Atomic int*) &h->pending;
++    pending = (std::atomic<int>*) &h->pending;
+     if (atomic_exchange(pending, 0) == 0)
+       continue;
+ 
+diff --git a/src/unix/core.c b/src/unix/core.c
+index f53adc156a7c454c492abaeac29d90be436785fc..ce7fd2cdfdd53410dc694450bd56dffc26ff4792 100644
+--- a/src/unix/core.c
++++ b/src/unix/core.c
+@@ -45,6 +45,7 @@
+ #include <sys/utsname.h>
+ #include <sys/time.h>
+ #include <time.h> /* clock_gettime */
++#include <atomic>
+ 
+ #ifdef __sun
+ # include <sys/filio.h>
+@@ -263,7 +264,7 @@ int uv__getiovmax(void) {
+ #if defined(IOV_MAX)
+   return IOV_MAX;
+ #elif defined(_SC_IOV_MAX)
+-  static _Atomic int iovmax_cached = -1;
++  static std::atomic<int> iovmax_cached = -1;
+   int iovmax;
+ 
+   iovmax = atomic_load_explicit(&iovmax_cached, memory_order_relaxed);
+diff --git a/src/unix/fs.c b/src/unix/fs.c
+index e25d02e54dbe93e4b9c22b0140108c99ae2cb4f7..aba190a9c0240fba0128fb7fbc5d92d7fa86214b 100644
+--- a/src/unix/fs.c
++++ b/src/unix/fs.c
+@@ -46,6 +46,8 @@
+ #include <fcntl.h>
+ #include <poll.h>
+ 
++#include <atomic>
++
+ #if defined(__DragonFly__)        ||                                      \
+     defined(__FreeBSD__)          ||                                      \
+     defined(__OpenBSD__)          ||                                      \
+@@ -313,7 +315,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
+   static uv_once_t once = UV_ONCE_INIT;
+   int r;
+ #ifdef O_CLOEXEC
+-  static _Atomic int no_cloexec_support;
++  static std::atomic<int> no_cloexec_support;
+ #endif
+   static const char pattern[] = "XXXXXX";
+   static const size_t pattern_size = sizeof(pattern) - 1;
+@@ -338,7 +340,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
+   uv_once(&once, uv__mkostemp_initonce);
+ 
+ #ifdef O_CLOEXEC
+-  if (atomic_load_explicit(&no_cloexec_support, memory_order_relaxed) == 0 &&
++  if (atomic_load_explicit(&no_cloexec_support, std::memory_order_relaxed) == 0 &&
+       uv__mkostemp != NULL) {
+     r = uv__mkostemp(path, O_CLOEXEC);
+ 
+@@ -352,7 +354,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
+ 
+     /* We set the static variable so that next calls don't even
+        try to use mkostemp. */
+-    atomic_store_explicit(&no_cloexec_support, 1, memory_order_relaxed);
++    atomic_store_explicit(&no_cloexec_support, 1, std::memory_order_relaxed);
+   }
+ #endif  /* O_CLOEXEC */
+ 
+@@ -462,7 +464,7 @@ static ssize_t uv__fs_preadv(uv_file fd,
+ 
+ static ssize_t uv__fs_read(uv_fs_t* req) {
+ #if TRY_PREADV
+-  static _Atomic int no_preadv;
++  static std::atomic<int> no_preadv;
+ #endif
+   unsigned int iovmax;
+   ssize_t result;
+@@ -486,7 +488,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
+     result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off);
+ #else
+ # if TRY_PREADV
+-    if (atomic_load_explicit(&no_preadv, memory_order_relaxed)) retry:
++    if (atomic_load_explicit(&no_preadv, std::memory_order_relaxed)) retry:
+ # endif
+     {
+       result = uv__fs_preadv(req->file, req->bufs, req->nbufs, req->off);
+@@ -498,7 +500,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
+                       req->nbufs,
+                       req->off);
+       if (result == -1 && errno == ENOSYS) {
+-        atomic_store_explicit(&no_preadv, 1, memory_order_relaxed);
++        atomic_store_explicit(&no_preadv, 1, std::memory_order_relaxed);
+         goto retry;
+       }
+     }
+@@ -939,10 +941,10 @@ static int uv__is_cifs_or_smb(int fd) {
+ 
+ static ssize_t uv__fs_try_copy_file_range(int in_fd, off_t* off,
+                                           int out_fd, size_t len) {
+-  static _Atomic int no_copy_file_range_support;
++  static std::atomic<int> no_copy_file_range_support;
+   ssize_t r;
+ 
+-  if (atomic_load_explicit(&no_copy_file_range_support, memory_order_relaxed)) {
++  if (atomic_load_explicit(&no_copy_file_range_support, std::memory_order_relaxed)) {
+     errno = ENOSYS;
+     return -1;
+   }
+@@ -961,7 +963,7 @@ static ssize_t uv__fs_try_copy_file_range(int in_fd, off_t* off,
+       errno = ENOSYS;  /* Use fallback. */
+     break;
+   case ENOSYS:
+-    atomic_store_explicit(&no_copy_file_range_support, 1, memory_order_relaxed);
++    atomic_store_explicit(&no_copy_file_range_support, 1, std::memory_order_relaxed);
+     break;
+   case EPERM:
+     /* It's been reported that CIFS spuriously fails.
+@@ -1162,7 +1164,7 @@ static ssize_t uv__fs_lutime(uv_fs_t* req) {
+ 
+ static ssize_t uv__fs_write(uv_fs_t* req) {
+ #if TRY_PREADV
+-  static _Atomic int no_pwritev;
++  static std::atomic<int> no_pwritev;
+ #endif
+   ssize_t r;
+ 
+@@ -1191,7 +1193,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
+     r = pwritev(req->file, (struct iovec*) req->bufs, req->nbufs, req->off);
+ #else
+ # if TRY_PREADV
+-    if (atomic_load_explicit(&no_pwritev, memory_order_relaxed)) retry:
++    if (atomic_load_explicit(&no_pwritev, std::memory_order_relaxed)) retry:
+ # endif
+     {
+       r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
+@@ -1203,7 +1205,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
+                   req->nbufs,
+                   req->off);
+       if (r == -1 && errno == ENOSYS) {
+-        atomic_store_explicit(&no_pwritev, 1, memory_order_relaxed);
++        atomic_store_explicit(&no_pwritev, 1, std::memory_order_relaxed);
+         goto retry;
+       }
+     }
+@@ -1483,14 +1485,14 @@ static int uv__fs_statx(int fd,
+                         uv_stat_t* buf) {
+   STATIC_ASSERT(UV_ENOSYS != -1);
+ #ifdef __linux__
+-  static _Atomic int no_statx;
++  static std::atomic<int> no_statx;
+   struct uv__statx statxbuf;
+   int dirfd;
+   int flags;
+   int mode;
+   int rc;
+ 
+-  if (atomic_load_explicit(&no_statx, memory_order_relaxed))
++  if (atomic_load_explicit(&no_statx, std::memory_order_relaxed))
+     return UV_ENOSYS;
+ 
+   dirfd = AT_FDCWD;
+@@ -1524,7 +1526,7 @@ static int uv__fs_statx(int fd,
+      * implemented, rc might return 1 with 0 set as the error code in which
+      * case we return ENOSYS.
+      */
+-    atomic_store_explicit(&no_statx, 1, memory_order_relaxed);
++    atomic_store_explicit(&no_statx, 1, std::memory_order_relaxed);
+     return UV_ENOSYS;
+   }
+ 
+diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c
+index 28e55aae6c613576ede7024a5c73d746e134d865..ffe0f9191cc7b0c233447db358077d8814e0217e 100644
+--- a/src/unix/kqueue.c
++++ b/src/unix/kqueue.c
+@@ -34,6 +34,8 @@
+ #include <fcntl.h>
+ #include <time.h>
+ 
++#include <atomic>
++
+ /*
+  * Required on
+  * - Until at least FreeBSD 11.0
+@@ -60,7 +62,7 @@ int uv__kqueue_init(uv_loop_t* loop) {
+ 
+ 
+ #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+-static _Atomic int uv__has_forked_with_cfrunloop;
++static std::atomic<int> uv__has_forked_with_cfrunloop;
+ #endif
+ 
+ int uv__io_fork(uv_loop_t* loop) {
+@@ -84,7 +86,7 @@ int uv__io_fork(uv_loop_t* loop) {
+     */
+     atomic_store_explicit(&uv__has_forked_with_cfrunloop,
+                           1,
+-                          memory_order_relaxed);
++                          std::memory_order_relaxed);
+     uv__free(loop->cf_state);
+     loop->cf_state = NULL;
+   }
+@@ -541,7 +543,7 @@ int uv_fs_event_start(uv_fs_event_t* handle,
+     goto fallback;
+ 
+   if (0 == atomic_load_explicit(&uv__has_forked_with_cfrunloop,
+-                                memory_order_relaxed)) {
++                                std::memory_order_relaxed)) {
+     int r;
+     /* The fallback fd is no longer needed */
+     uv__close_nocheckstdio(fd);
+@@ -577,7 +579,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
+ 
+ #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+   if (0 == atomic_load_explicit(&uv__has_forked_with_cfrunloop,
+-                                memory_order_relaxed))
++                                std::memory_order_relaxed))
+     if (handle->cf_cb != NULL)
+       r = uv__fsevents_close(handle);
+ #endif
+diff --git a/src/unix/linux.c b/src/unix/linux.c
+index 157443792f1216c83b4221c3810d17c81c5913c4..e3dfb186dc531e5c8197a81681c00d693e0913c6 100644
+--- a/src/unix/linux.c
++++ b/src/unix/linux.c
+@@ -27,7 +27,6 @@
+ #include "internal.h"
+ 
+ #include <inttypes.h>
+-#include <stdatomic.h>
+ #include <stddef.h>  /* offsetof */
+ #include <stdint.h>
+ #include <stdio.h>
+@@ -133,6 +132,8 @@
+ # include <netpacket/packet.h>
+ #endif /* HAVE_IFADDRS_H */
+ 
++#include <atomic>
++
+ enum {
+   UV__IORING_SETUP_SQPOLL = 2u,
+ };
+@@ -311,14 +312,14 @@ static struct watcher_root* uv__inotify_watchers(uv_loop_t* loop) {
+ 
+ 
+ unsigned uv__kernel_version(void) {
+-  static _Atomic unsigned cached_version;
++  static std::atomic<unsigned int> cached_version;
+   struct utsname u;
+   unsigned version;
+   unsigned major;
+   unsigned minor;
+   unsigned patch;
+ 
+-  version = atomic_load_explicit(&cached_version, memory_order_relaxed);
++  version = std::atomic_load_explicit(&cached_version, std::memory_order_relaxed);
+   if (version != 0)
+     return version;
+ 
+@@ -329,7 +330,7 @@ unsigned uv__kernel_version(void) {
+     return 0;
+ 
+   version = major * 65536 + minor * 256 + patch;
+-  atomic_store_explicit(&cached_version, version, memory_order_relaxed);
++  std::atomic_store_explicit(&cached_version, version, std::memory_order_relaxed);
+ 
+   return version;
+ }
+@@ -424,16 +425,16 @@ static int uv__use_io_uring(void) {
+   return 0;  /* Possibly available but blocked by seccomp. */
+ #else
+   /* Ternary: unknown=0, yes=1, no=-1 */
+-  static _Atomic int use_io_uring;
++  static std::atomic<int> use_io_uring;
+   char* val;
+   int use;
+ 
+-  use = atomic_load_explicit(&use_io_uring, memory_order_relaxed);
++  use = std::atomic_load_explicit(&use_io_uring, std::memory_order_relaxed);
+ 
+   if (use == 0) {
+     val = getenv("UV_USE_IO_URING");
+     use = val == NULL || atoi(val) ? 1 : -1;
+-    atomic_store_explicit(&use_io_uring, use, memory_order_relaxed);
++    std::atomic_store_explicit(&use_io_uring, use, std::memory_order_relaxed);
+   }
+ 
+   return use > 0;
+@@ -709,8 +710,8 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou,
+   if (iou->ringfd == -1)
+     return NULL;
+ 
+-  head = atomic_load_explicit((_Atomic uint32_t*) iou->sqhead,
+-                              memory_order_acquire);
++  head = std::atomic_load_explicit((std::atomic<uint32_t>*) iou->sqhead,
++                              std::memory_order_acquire);
+   tail = *iou->sqtail;
+   mask = iou->sqmask;
+ 
+@@ -739,12 +740,12 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou,
+ static void uv__iou_submit(struct uv__iou* iou) {
+   uint32_t flags;
+ 
+-  atomic_store_explicit((_Atomic uint32_t*) iou->sqtail,
++  std::atomic_store_explicit((std::atomic<uint32_t>*) iou->sqtail,
+                         *iou->sqtail + 1,
+-                        memory_order_release);
++                        std::memory_order_release);
+ 
+-  flags = atomic_load_explicit((_Atomic uint32_t*) iou->sqflags,
+-                               memory_order_acquire);
++  flags = std::atomic_load_explicit((std::atomic<uint32_t>*) iou->sqflags,
++                               std::memory_order_acquire);
+ 
+   if (flags & UV__IORING_SQ_NEED_WAKEUP)
+     if (uv__io_uring_enter(iou->ringfd, 0, 0, UV__IORING_ENTER_SQ_WAKEUP))
+@@ -1076,8 +1077,8 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) {
+   int rc;
+ 
+   head = *iou->cqhead;
+-  tail = atomic_load_explicit((_Atomic uint32_t*) iou->cqtail,
+-                              memory_order_acquire);
++  tail = std::atomic_load_explicit((std::atomic<uint32_t>*) iou->cqtail,
++                              std::memory_order_acquire);
+   mask = iou->cqmask;
+   cqe = (uv__io_uring_cqe*)iou->cqe;
+   nevents = 0;
+@@ -1109,15 +1110,15 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) {
+     nevents++;
+   }
+ 
+-  atomic_store_explicit((_Atomic uint32_t*) iou->cqhead,
++  std::atomic_store_explicit((std::atomic<uint32_t>*) iou->cqhead,
+                         tail,
+-                        memory_order_release);
++                        std::memory_order_release);
+ 
+   /* Check whether CQE's overflowed, if so enter the kernel to make them
+    * available. Don't grab them immediately but in the next loop iteration to
+    * avoid loop starvation. */
+-  flags = atomic_load_explicit((_Atomic uint32_t*) iou->sqflags,
+-                               memory_order_acquire);
++  flags = std::atomic_load_explicit((std::atomic<uint32_t>*) iou->sqflags,
++                               std::memory_order_acquire);
+ 
+   if (flags & UV__IORING_SQ_CQ_OVERFLOW) {
+     do
+@@ -1531,7 +1532,7 @@ update_timeout:
+ }
+ 
+ uint64_t uv__hrtime(uv_clocktype_t type) {
+-  static _Atomic clock_t fast_clock_id = -1;
++  static std::atomic<clock_t> fast_clock_id = -1;
+   struct timespec t;
+   clock_t clock_id;
+ 
+@@ -1547,7 +1548,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
+   if (type != UV_CLOCK_FAST)
+     goto done;
+ 
+-  clock_id = atomic_load_explicit(&fast_clock_id, memory_order_relaxed);
++  clock_id = std::atomic_load_explicit(&fast_clock_id, std::memory_order_relaxed);
+   if (clock_id != -1)
+     goto done;
+ 
+@@ -1556,7 +1557,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
+     if (t.tv_nsec <= 1 * 1000 * 1000)
+       clock_id = CLOCK_MONOTONIC_COARSE;
+ 
+-  atomic_store_explicit(&fast_clock_id, clock_id, memory_order_relaxed);
++  std::atomic_store_explicit(&fast_clock_id, clock_id, std::memory_order_relaxed);
+ 
+ done:
+ 
+diff --git a/src/unix/tty.c b/src/unix/tty.c
+index 1bd217b5a15eed13a8349c479b53471dd36ca216..1304c6d8685cfd122cffea066dc668d1dfc9ae02 100644
+--- a/src/unix/tty.c
++++ b/src/unix/tty.c
+@@ -22,7 +22,6 @@
+ #include "uv.h"
+ #include "internal.h"
+ 
+-#include <stdatomic.h>
+ #include <stdlib.h>
+ #include <assert.h>
+ #include <unistd.h>
+@@ -30,6 +29,8 @@
+ #include <errno.h>
+ #include <sys/ioctl.h>
+ 
++#include <atomic>
++
+ #if defined(__MVS__) && !defined(IMAXBEL)
+ #define IMAXBEL 0
+ #endif
+@@ -64,7 +65,7 @@ static int isreallyatty(int file) {
+ 
+ static int orig_termios_fd = -1;
+ static struct termios orig_termios;
+-static _Atomic int termios_spinlock;
++static std::atomic<int> termios_spinlock;
+ 
+ int uv__tcsetattr(int fd, int how, const struct termios *term) {
+   int rc;
+diff --git a/src/uv-common.c b/src/uv-common.c
+index bfcc3ef10f4fd7763221638947da6e02e7a17c33..5c6d84155408ae4f7c3c6ff9b48bd09ccd16a92e 100644
+--- a/src/uv-common.c
++++ b/src/uv-common.c
+@@ -951,7 +951,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
+ __attribute__((destructor))
+ #endif
+ void uv_library_shutdown(void) {
+-  static int was_shutdown;
++  static std::atomic<int> was_shutdown;
+ 
+   if (uv__exchange_int_relaxed(&was_shutdown, 1))
+     return;
+diff --git a/src/uv-common.h b/src/uv-common.h
+index cd57e5a35153d0557351b60cce0c5be7a4468b60..5dce8eaf2705b47935b218181f6dd69af0d5b61b 100644
+--- a/src/uv-common.h
++++ b/src/uv-common.h
+@@ -32,15 +32,13 @@
+ #include <stddef.h>
+ #include <stdint.h>
+ 
++#include <atomic>
++
+ #include "uv.h"
+ #include "uv/tree.h"
+ #include "queue.h"
+ #include "strscpy.h"
+ 
+-#ifndef _MSC_VER
+-# include <stdatomic.h>
+-#endif
+-
+ #if EDOM > 0
+ # define UV__ERR(x) (-(x))
+ #else
+@@ -70,7 +68,7 @@ extern int snprintf(char*, size_t, const char*, ...);
+   InterlockedExchangeNoFence((LONG volatile*)(p), v)
+ #else
+ #define uv__exchange_int_relaxed(p, v)                                        \
+-  atomic_exchange_explicit((_Atomic int*)(p), v, memory_order_relaxed)
++  std::atomic_exchange_explicit((std::atomic<int>*)(p), v, std::memory_order_relaxed)
+ #endif
+ 
+ #define UV__UDP_DGRAM_MAXSIZE (64 * 1024)
diff --git a/upstream_utils/libuv_patches/0009-Avoid-unused-variable-warning-on-Mac.patch b/upstream_utils/libuv_patches/0009-Avoid-unused-variable-warning-on-Mac.patch
deleted file mode 100644
index 8db2deb..0000000
--- a/upstream_utils/libuv_patches/0009-Avoid-unused-variable-warning-on-Mac.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-From d83eaeff1f53bc3dede8a46a05cdb3ca94d1aac4 Mon Sep 17 00:00:00 2001
-From: Peter Johnson <johnson.peter@gmail.com>
-Date: Sun, 5 Jun 2022 15:40:35 -0700
-Subject: [PATCH 9/9] Avoid unused variable warning on Mac
-
----
- src/unix/darwin.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/unix/darwin.c b/src/unix/darwin.c
-index eeb35720..ed51a6ad 100644
---- a/src/unix/darwin.c
-+++ b/src/unix/darwin.c
-@@ -257,6 +257,7 @@ static int uv__get_cpu_speed(uint64_t* speed) {
-   // clock_frequency_str's lifetimes after their initialization
-   {
-     kr = pIOMasterPort(MACH_PORT_NULL, &mach_port);
-+    (void) kr;
-     assert(kr == KERN_SUCCESS);
-     CFMutableDictionaryRef classes_to_match
-         = pIOServiceMatching("IOPlatformDevice");
diff --git a/upstream_utils/libuv_patches/0009-Remove-static-from-array-indices.patch b/upstream_utils/libuv_patches/0009-Remove-static-from-array-indices.patch
new file mode 100644
index 0000000..f95fc5f
--- /dev/null
+++ b/upstream_utils/libuv_patches/0009-Remove-static-from-array-indices.patch
@@ -0,0 +1,67 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Thu, 13 Jul 2023 23:30:58 -0700
+Subject: [PATCH 09/10] Remove static from array indices
+
+---
+ src/unix/linux.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/unix/linux.c b/src/unix/linux.c
+index e3dfb186dc531e5c8197a81681c00d693e0913c6..d365b623a0a25228f0c6acf1fa14a5c7a9f1efbf 100644
+--- a/src/unix/linux.c
++++ b/src/unix/linux.c
+@@ -2060,7 +2060,7 @@ static uint64_t uv__read_uint64(const char* filename) {
+  * finds the location and length of the memory controller mount path.
+  * This disregards the leading / for easy concatenation of paths.
+  * Returns NULL if the memory controller wasn't found. */
+-static char* uv__cgroup1_find_memory_controller(char buf[static 1024],
++static char* uv__cgroup1_find_memory_controller(char buf[1024],
+                                                 int* n) {
+   char* p;
+ 
+@@ -2081,7 +2081,7 @@ static char* uv__cgroup1_find_memory_controller(char buf[static 1024],
+   return p;
+ }
+ 
+-static void uv__get_cgroup1_memory_limits(char buf[static 1024], uint64_t* high,
++static void uv__get_cgroup1_memory_limits(char buf[1024], uint64_t* high,
+                                           uint64_t* max) {
+   char filename[4097];
+   char* p;
+@@ -2121,7 +2121,7 @@ update_limits:
+     *max = UINT64_MAX;
+ }
+ 
+-static void uv__get_cgroup2_memory_limits(char buf[static 1024], uint64_t* high,
++static void uv__get_cgroup2_memory_limits(char buf[1024], uint64_t* high,
+                                           uint64_t* max) {
+   char filename[4097];
+   char* p;
+@@ -2138,7 +2138,7 @@ static void uv__get_cgroup2_memory_limits(char buf[static 1024], uint64_t* high,
+   *high = uv__read_uint64(filename);
+ }
+ 
+-static uint64_t uv__get_cgroup_constrained_memory(char buf[static 1024]) {
++static uint64_t uv__get_cgroup_constrained_memory(char buf[1024]) {
+   uint64_t high;
+   uint64_t max;
+ 
+@@ -2164,7 +2164,7 @@ uint64_t uv_get_constrained_memory(void) {
+ }
+ 
+ 
+-static uint64_t uv__get_cgroup1_current_memory(char buf[static 1024]) {
++static uint64_t uv__get_cgroup1_current_memory(char buf[1024]) {
+   char filename[4097];
+   uint64_t current;
+   char* p;
+@@ -2188,7 +2188,7 @@ static uint64_t uv__get_cgroup1_current_memory(char buf[static 1024]) {
+   return uv__read_uint64("/sys/fs/cgroup/memory/memory.usage_in_bytes");
+ }
+ 
+-static uint64_t uv__get_cgroup2_current_memory(char buf[static 1024]) {
++static uint64_t uv__get_cgroup2_current_memory(char buf[1024]) {
+   char filename[4097];
+   char* p;
+   int n;
diff --git a/upstream_utils/libuv_patches/0010-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch b/upstream_utils/libuv_patches/0010-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch
new file mode 100644
index 0000000..07d02f5
--- /dev/null
+++ b/upstream_utils/libuv_patches/0010-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch
@@ -0,0 +1,42 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Fri, 14 Jul 2023 16:40:18 -0700
+Subject: [PATCH 10/10] Add pragmas for missing libraries and set _WIN32_WINNT
+ to Windows 10
+
+This makes GetSystemTimePreciseAsFileTime() available.
+
+The #define value is from
+https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt.
+---
+ include/uv/win.h | 2 +-
+ src/win/util.c   | 2 ++
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/include/uv/win.h b/include/uv/win.h
+index 6d0afe69e7dd4caf4c9459e548fe75cf0c51b501..613065df435d813cd517efbc138b13ee46f01f2d 100644
+--- a/include/uv/win.h
++++ b/include/uv/win.h
+@@ -20,7 +20,7 @@
+  */
+ 
+ #ifndef _WIN32_WINNT
+-# define _WIN32_WINNT   0x0600
++# define _WIN32_WINNT   0x0A00
+ #endif
+ 
+ #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
+diff --git a/src/win/util.c b/src/win/util.c
+index 9324992ec521cc3496e3e9304e600963a3f20897..4b76417fcbac2480725471740c037deb859e17ca 100644
+--- a/src/win/util.c
++++ b/src/win/util.c
+@@ -73,7 +73,9 @@ static char *process_title;
+ static CRITICAL_SECTION process_title_lock;
+ 
+ #pragma comment(lib, "Advapi32.lib")
++#pragma comment(lib, "Dbghelp.lib")
+ #pragma comment(lib, "IPHLPAPI.lib")
++#pragma comment(lib, "Ole32.lib")
+ #pragma comment(lib, "Psapi.lib")
+ #pragma comment(lib, "Userenv.lib")
+ #pragma comment(lib, "kernel32.lib")
diff --git a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch b/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch
deleted file mode 100644
index 5d6916d..0000000
--- a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 3d09b3d7b78ffc037a32725cc4002976b908d965 Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Sat, 7 May 2022 20:50:26 -0400
-Subject: [PATCH 01/28] Fix spelling/language errors
-
----
- llvm/include/llvm/Support/ErrorHandling.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h
-index f980510d3..6791df6be 100644
---- a/llvm/include/llvm/Support/ErrorHandling.h
-+++ b/llvm/include/llvm/Support/ErrorHandling.h
-@@ -44,7 +44,7 @@ namespace llvm {
-   void install_fatal_error_handler(fatal_error_handler_t handler,
-                                    void *user_data = nullptr);
- 
--  /// Restores default error handling behaviour.
-+  /// Restores default error handling behavior.
-   void remove_fatal_error_handler();
- 
-   /// ScopedFatalErrorHandler - This is a simple helper class which just
diff --git a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch
similarity index 75%
rename from upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch
rename to upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch
index eb5b759..48327f8 100644
--- a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch
+++ b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch
@@ -1,40 +1,43 @@
-From afca62cd2f1616bcf2e648dc121a057d59168424 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sat, 7 May 2022 22:09:18 -0400
-Subject: [PATCH 02/28] Remove StringRef, ArrayRef, and Optional
+Subject: [PATCH 01/31] Remove StringRef, ArrayRef, and Optional
 
 ---
  llvm/include/llvm/ADT/PointerUnion.h          |  1 -
- llvm/include/llvm/ADT/SmallSet.h              | 13 ++--
+ llvm/include/llvm/ADT/SmallSet.h              |  2 +-
  llvm/include/llvm/ADT/SmallString.h           | 77 ++++++++++---------
- llvm/include/llvm/ADT/StringMap.h             | 34 ++++----
- llvm/include/llvm/ADT/StringMapEntry.h        | 25 +++---
+ llvm/include/llvm/ADT/SmallVector.h           |  7 +-
+ llvm/include/llvm/ADT/StringMap.h             | 38 ++++-----
+ llvm/include/llvm/ADT/StringMapEntry.h        | 20 ++---
  llvm/include/llvm/Support/Chrono.h            | 10 +--
  llvm/include/llvm/Support/Compiler.h          |  2 +-
- llvm/include/llvm/Support/ConvertUTF.h        | 28 ++++---
- llvm/include/llvm/Support/DJB.h               |  6 +-
+ llvm/include/llvm/Support/ConvertUTF.h        | 31 ++++----
  llvm/include/llvm/Support/ErrorHandling.h     |  9 +--
  .../llvm/Support/SmallVectorMemoryBuffer.h    |  6 +-
- llvm/include/llvm/Support/VersionTuple.h      | 20 ++---
+ llvm/include/llvm/Support/VersionTuple.h      |  6 --
  .../llvm/Support/Windows/WindowsSupport.h     |  4 +-
- llvm/include/llvm/Support/raw_ostream.h       | 51 ++++++------
- llvm/lib/Support/ConvertUTFWrapper.cpp        | 32 ++++----
+ llvm/include/llvm/Support/raw_ostream.h       | 46 ++++++-----
+ llvm/include/llvm/Support/xxhash.h            | 16 ++--
+ llvm/lib/Support/ConvertUTFWrapper.cpp        | 38 ++++-----
  llvm/lib/Support/ErrorHandling.cpp            | 13 ++--
  llvm/lib/Support/SmallVector.cpp              |  5 +-
  llvm/lib/Support/StringMap.cpp                | 12 +--
  llvm/lib/Support/raw_ostream.cpp              | 25 +++---
- llvm/unittests/ADT/DenseMapTest.cpp           | 25 ------
+ llvm/lib/Support/xxhash.cpp                   | 10 +--
+ llvm/unittests/ADT/DenseMapTest.cpp           | 29 +------
  llvm/unittests/ADT/FunctionExtrasTest.cpp     | 12 +--
  llvm/unittests/ADT/HashingTest.cpp            |  2 +-
  llvm/unittests/ADT/SmallPtrSetTest.cpp        |  1 -
  llvm/unittests/ADT/SmallStringTest.cpp        | 50 ++++++------
- llvm/unittests/ADT/SmallVectorTest.cpp        | 20 +----
+ llvm/unittests/ADT/SmallVectorTest.cpp        | 30 ++------
  llvm/unittests/ADT/StringMapTest.cpp          | 32 ++++----
- llvm/unittests/Support/ConvertUTFTest.cpp     | 37 +++++----
- 27 files changed, 248 insertions(+), 304 deletions(-)
+ llvm/unittests/Support/ConvertUTFTest.cpp     | 41 +++++-----
+ llvm/unittests/Support/xxhashTest.cpp         |  4 +-
+ 30 files changed, 264 insertions(+), 315 deletions(-)
 
 diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
-index 04d566bbc..1d4cc747c 100644
+index 7d4ed02b622626bb8043acb57b8ce7ed97a5f949..8ac68dbc0a791b8ac0e0ca865e69024cb642aa70 100644
 --- a/llvm/include/llvm/ADT/PointerUnion.h
 +++ b/llvm/include/llvm/ADT/PointerUnion.h
 @@ -17,7 +17,6 @@
@@ -42,18 +45,15 @@
  #include "llvm/ADT/DenseMapInfo.h"
  #include "llvm/ADT/PointerIntPair.h"
 -#include "llvm/ADT/STLExtras.h"
+ #include "llvm/Support/Casting.h"
  #include "llvm/Support/PointerLikeTypeTraits.h"
  #include <algorithm>
- #include <cassert>
 diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
-index 0eed85449..bfe93e997 100644
+index a16e8ac6f07552d98250e808190b00ee270f12b3..aeee5f97799aea7e7588d7afba1e47b4fa3d8c7b 100644
 --- a/llvm/include/llvm/ADT/SmallSet.h
 +++ b/llvm/include/llvm/ADT/SmallSet.h
-@@ -14,15 +14,14 @@
- #ifndef LLVM_ADT_SMALLSET_H
- #define LLVM_ADT_SMALLSET_H
+@@ -16,12 +16,12 @@
  
--#include "llvm/ADT/None.h"
  #include "llvm/ADT/SmallPtrSet.h"
  #include "llvm/ADT/SmallVector.h"
 -#include "llvm/ADT/STLExtras.h"
@@ -66,38 +66,8 @@
  #include <set>
  #include <type_traits>
  #include <utility>
-@@ -179,16 +178,16 @@ public:
-   /// concept.
-   // FIXME: Add iterators that abstract over the small and large form, and then
-   // return those here.
--  std::pair<NoneType, bool> insert(const T &V) {
-+  std::pair<std::nullopt_t, bool> insert(const T &V) {
-     if (!isSmall())
--      return std::make_pair(None, Set.insert(V).second);
-+      return std::make_pair(std::nullopt, Set.insert(V).second);
- 
-     VIterator I = vfind(V);
-     if (I != Vector.end())    // Don't reinsert if it already exists.
--      return std::make_pair(None, false);
-+      return std::make_pair(std::nullopt, false);
-     if (Vector.size() < N) {
-       Vector.push_back(V);
--      return std::make_pair(None, true);
-+      return std::make_pair(std::nullopt, true);
-     }
- 
-     // Otherwise, grow from vector to set.
-@@ -197,7 +196,7 @@ public:
-       Vector.pop_back();
-     }
-     Set.insert(V);
--    return std::make_pair(None, true);
-+    return std::make_pair(std::nullopt, true);
-   }
- 
-   template <typename IterT>
 diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h
-index 874968f0a..50cbdade4 100644
+index 0052c86fb37b82dcdf577a7acf06e3a47f54da61..4d673cc8b1c49cf8a3f19653de53881cd12662ee 100644
 --- a/llvm/include/llvm/ADT/SmallString.h
 +++ b/llvm/include/llvm/ADT/SmallString.h
 @@ -15,8 +15,9 @@
@@ -171,7 +141,7 @@
        std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize);
        CurrentSize += Ref.size();
      }
-@@ -89,29 +90,29 @@ public:
+@@ -89,30 +90,30 @@ public:
  
    /// Check for string equality.  This is more efficient than compare() when
    /// the relative ordering of inequal strings isn't needed.
@@ -186,8 +156,9 @@
      return str().equals_insensitive(RHS);
    }
  
-   /// Compare two strings; the result is -1, 0, or 1 if this string is
-   /// lexicographically less than, equal to, or greater than the \p RHS.
+   /// compare - Compare two strings; the result is negative, zero, or positive
+   /// if this string is lexicographically less than, equal to, or greater than
+   /// the \p RHS.
 -  int compare(StringRef RHS) const {
 +  int compare(std::string_view RHS) const {
      return str().compare(RHS);
@@ -206,7 +177,7 @@
      return str().compare_numeric(RHS);
    }
  
-@@ -120,12 +121,12 @@ public:
+@@ -121,12 +122,12 @@ public:
    /// @{
  
    /// startswith - Check if this string starts with the given \p Prefix.
@@ -221,7 +192,7 @@
      return str().endswith(Suffix);
    }
  
-@@ -145,7 +146,7 @@ public:
+@@ -146,7 +147,7 @@ public:
    ///
    /// \returns The index of the first occurrence of \p Str, or npos if not
    /// found.
@@ -230,7 +201,7 @@
      return str().find(Str, From);
    }
  
-@@ -153,7 +154,7 @@ public:
+@@ -154,7 +155,7 @@ public:
    ///
    /// \returns The index of the last occurrence of \p C, or npos if not
    /// found.
@@ -239,7 +210,7 @@
      return str().rfind(C, From);
    }
  
-@@ -161,7 +162,7 @@ public:
+@@ -162,7 +163,7 @@ public:
    ///
    /// \returns The index of the last occurrence of \p Str, or npos if not
    /// found.
@@ -248,7 +219,7 @@
      return str().rfind(Str);
    }
  
-@@ -175,7 +176,7 @@ public:
+@@ -176,7 +177,7 @@ public:
    /// not found.
    ///
    /// Complexity: O(size() + Chars.size())
@@ -257,7 +228,7 @@
      return str().find_first_of(Chars, From);
    }
  
-@@ -189,13 +190,13 @@ public:
+@@ -190,13 +191,13 @@ public:
    /// \p Chars, or npos if not found.
    ///
    /// Complexity: O(size() + Chars.size())
@@ -273,7 +244,7 @@
      return str().find_last_of(C, From);
    }
  
-@@ -204,7 +205,7 @@ public:
+@@ -205,7 +206,7 @@ public:
    ///
    /// Complexity: O(size() + Chars.size())
    size_t find_last_of(
@@ -282,7 +253,7 @@
      return str().find_last_of(Chars, From);
    }
  
-@@ -219,7 +220,7 @@ public:
+@@ -220,7 +221,7 @@ public:
  
    /// Return the number of non-overlapped occurrences of \p Str in the
    /// string.
@@ -291,7 +262,7 @@
      return str().count(Str);
    }
  
-@@ -236,7 +237,7 @@ public:
+@@ -237,7 +238,7 @@ public:
    /// \param N The number of characters to included in the substring. If \p N
    /// exceeds the number of characters remaining in the string, the string
    /// suffix (starting with \p Start) will be returned.
@@ -300,7 +271,7 @@
      return str().substr(Start, N);
    }
  
-@@ -250,14 +251,14 @@ public:
+@@ -251,14 +252,14 @@ public:
    /// substring. If this is npos, or less than \p Start, or exceeds the
    /// number of characters remaining in the string, the string suffix
    /// (starting with \p Start) will be returned.
@@ -318,7 +289,7 @@
  
    // TODO: Make this const, if it's safe...
    const char* c_str() {
-@@ -266,20 +267,20 @@ public:
+@@ -267,20 +268,20 @@ public:
      return this->data();
    }
  
@@ -343,8 +314,45 @@
      this->append(RHS.begin(), RHS.end());
      return *this;
    }
+diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
+index 53a107b1574c6a35c66c7fe3c61deb2ffc84b991..4559864ed231206b098936dae4fc378bfa986371 100644
+--- a/llvm/include/llvm/ADT/SmallVector.h
++++ b/llvm/include/llvm/ADT/SmallVector.h
+@@ -27,13 +27,12 @@
+ #include <limits>
+ #include <memory>
+ #include <new>
++#include <span>
+ #include <type_traits>
+ #include <utility>
+ 
+ namespace llvm {
+ 
+-template <typename T> class ArrayRef;
+-
+ template <typename IteratorT> class iterator_range;
+ 
+ template <class Iterator>
+@@ -117,7 +116,7 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
+ };
+ 
+ /// This is the part of SmallVectorTemplateBase which does not depend on whether
+-/// the type T is a POD. The extra dummy template argument is used by ArrayRef
++/// the type T is a POD. The extra dummy template argument is used by span
+ /// to avoid unnecessarily requiring T to be complete.
+ template <typename T, typename = void>
+ class SmallVectorTemplateCommon
+@@ -1233,7 +1232,7 @@ public:
+ 
+   template <typename U,
+             typename = std::enable_if_t<std::is_convertible<U, T>::value>>
+-  explicit SmallVector(ArrayRef<U> A) : SmallVectorImpl<T>(N) {
++  explicit SmallVector(span<const U> A) : SmallVectorImpl<T>(N) {
+     this->append(A.begin(), A.end());
+   }
+ 
 diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h
-index 23248093c..8747cdb35 100644
+index 466f95254d102e98343290b211f317f749d7692b..34dfbf83c681f4e81a9dadd9382ddca6ef8d6c1d 100644
 --- a/llvm/include/llvm/ADT/StringMap.h
 +++ b/llvm/include/llvm/ADT/StringMap.h
 @@ -60,12 +60,12 @@ protected:
@@ -371,9 +379,9 @@
  
    /// Allocate the table with the specified number of buckets and otherwise
    /// setup the map as empty.
-@@ -126,7 +126,7 @@ public:
+@@ -127,7 +127,7 @@ public:
        : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
-         Allocator(A) {}
+         AllocTy(A) {}
  
 -  StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
 +  StringMap(std::initializer_list<std::pair<std::string_view, ValueTy>> List)
@@ -403,23 +411,36 @@
    /// constructed value if no such entry exists.
 -  ValueTy lookup(StringRef Key) const {
 +  ValueTy lookup(std::string_view Key) const {
-     const_iterator it = find(Key);
-     if (it != end())
-       return it->second;
-@@ -240,10 +240,10 @@ public:
+     const_iterator Iter = find(Key);
+     if (Iter != end())
+       return Iter->second;
+@@ -240,7 +240,7 @@ public:
+ 
+   /// at - Return the entry for the specified key, or abort if no such
+   /// entry exists.
+-  const ValueTy &at(StringRef Val) const {
++  const ValueTy &at(std::string_view Val) const {
+     auto Iter = this->find(std::move(Val));
+     assert(Iter != this->end() && "StringMap::at failed due to a missing key");
+     return Iter->second;
+@@ -248,13 +248,13 @@ public:
  
    /// Lookup the ValueTy for the \p Key, or create a default constructed value
    /// if the key is not in the map.
 -  ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
 +  ValueTy &operator[](std::string_view Key) { return try_emplace(Key).first->second; }
  
+   /// contains - Return true if the element is in the map, false otherwise.
+-  bool contains(StringRef Key) const { return find(Key) != end(); }
++  bool contains(std::string_view Key) const { return find(Key) != end(); }
+ 
    /// count - Return 1 if the element is in the map, 0 otherwise.
--  size_type count(StringRef Key) const { return find(Key) == end() ? 0 : 1; }
-+  size_type count(std::string_view Key) const { return find(Key) == end() ? 0 : 1; }
+-  size_type count(StringRef Key) const { return contains(Key) ? 1 : 0; }
++  size_type count(std::string_view Key) const { return contains(Key) ? 1 : 0; }
  
    template <typename InputTy>
    size_type count(const StringMapEntry<InputTy> &MapEntry) const {
-@@ -293,7 +293,7 @@ public:
+@@ -304,7 +304,7 @@ public:
    /// isn't already in the map. The bool component of the returned pair is true
    /// if and only if the insertion takes place, and the iterator component of
    /// the pair points to the element with key equivalent to the key of the pair.
@@ -428,7 +449,7 @@
      return try_emplace(KV.first, std::move(KV.second));
    }
  
-@@ -308,14 +308,14 @@ public:
+@@ -319,14 +319,14 @@ public:
    ///  Inserts elements from initializer list ilist. If multiple elements in
    /// the range have keys that compare equivalent, it is unspecified which
    /// element is inserted
@@ -445,17 +466,17 @@
      auto Ret = try_emplace(Key, std::forward<V>(Val));
      if (!Ret.second)
        Ret.first->second = std::forward<V>(Val);
-@@ -327,7 +327,7 @@ public:
+@@ -338,7 +338,7 @@ public:
    /// if and only if the insertion takes place, and the iterator component of
    /// the pair points to the element with key equivalent to the key of the pair.
    template <typename... ArgsTy>
--  std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&... Args) {
-+  std::pair<iterator, bool> try_emplace(std::string_view Key, ArgsTy &&... Args) {
+-  std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
++  std::pair<iterator, bool> try_emplace(std::string_view Key, ArgsTy &&...Args) {
      unsigned BucketNo = LookupBucketFor(Key);
      StringMapEntryBase *&Bucket = TheTable[BucketNo];
      if (Bucket && Bucket != getTombstoneVal())
-@@ -373,7 +373,7 @@ public:
-     V.Destroy(Allocator);
+@@ -385,7 +385,7 @@ public:
+     V.Destroy(getAllocator());
    }
  
 -  bool erase(StringRef Key) {
@@ -463,7 +484,7 @@
      iterator I = find(Key);
      if (I == end())
        return false;
-@@ -470,17 +470,17 @@ template <typename ValueTy>
+@@ -482,17 +482,17 @@ template <typename ValueTy>
  class StringMapKeyIterator
      : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
                                     StringMapConstIterator<ValueTy>,
@@ -485,22 +506,20 @@
  
  } // end namespace llvm
 diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
-index 6e13c8618..39976a02b 100644
+index 98b51cc1aebd59eba20076e6d8a4eebc0eebb982..388e81c361642113937f7d5680de73a50635b07d 100644
 --- a/llvm/include/llvm/ADT/StringMapEntry.h
 +++ b/llvm/include/llvm/ADT/StringMapEntry.h
-@@ -16,9 +16,8 @@
+@@ -16,8 +16,8 @@
  #ifndef LLVM_ADT_STRINGMAPENTRY_H
  #define LLVM_ADT_STRINGMAPENTRY_H
  
--#include "llvm/ADT/None.h"
 -#include "llvm/ADT/StringRef.h"
--#include "llvm/ADT/STLFunctionalExtras.h"
-+#include <optional>
+ #include <optional>
 +#include <string_view>
  
  namespace llvm {
  
-@@ -37,13 +36,13 @@ protected:
+@@ -36,13 +36,13 @@ protected:
    /// type-erase the allocator and put it in a source file.
    template <typename AllocatorTy>
    static void *allocateWithKey(size_t EntrySize, size_t EntryAlign,
@@ -516,26 +535,9 @@
                                            AllocatorTy &Allocator) {
    size_t KeyLength = Key.size();
  
-@@ -85,13 +84,13 @@ public:
-   void setValue(const ValueTy &V) { second = V; }
- };
+@@ -105,8 +105,8 @@ public:
  
--template <> class StringMapEntryStorage<NoneType> : public StringMapEntryBase {
-+template <> class StringMapEntryStorage<std::nullopt_t> : public StringMapEntryBase {
- public:
--  explicit StringMapEntryStorage(size_t keyLength, NoneType = None)
-+  explicit StringMapEntryStorage(size_t keyLength, std::nullopt_t = std::nullopt)
-       : StringMapEntryBase(keyLength) {}
-   StringMapEntryStorage(StringMapEntryStorage &entry) = delete;
- 
--  NoneType getValue() const { return None; }
-+  std::nullopt_t getValue() const { return std::nullopt; }
- };
- 
- /// StringMapEntry - This is used to represent one value that is inserted into
-@@ -102,8 +101,8 @@ class StringMapEntry final : public StringMapEntryStorage<ValueTy> {
- public:
-   using StringMapEntryStorage<ValueTy>::StringMapEntryStorage;
+   using ValueType = ValueTy;
  
 -  StringRef getKey() const {
 -    return StringRef(getKeyData(), this->getKeyLength());
@@ -544,7 +546,7 @@
    }
  
    /// getKeyData - Return the start of the string data that is the key for this
-@@ -113,14 +112,14 @@ public:
+@@ -116,15 +116,15 @@ public:
      return reinterpret_cast<const char *>(this + 1);
    }
  
@@ -557,13 +559,24 @@
    /// Create a StringMapEntry for the specified key construct the value using
    /// \p InitiVals.
    template <typename AllocatorTy, typename... InitTy>
--  static StringMapEntry *Create(StringRef key, AllocatorTy &allocator,
-+  static StringMapEntry *Create(std::string_view key, AllocatorTy &allocator,
-                                 InitTy &&... initVals) {
+-  static StringMapEntry *create(StringRef key, AllocatorTy &allocator,
+-                                InitTy &&...initVals) {
++  static StringMapEntry *create(std::string_view key, AllocatorTy &allocator,
++                                InitTy &&... initVals) {
      return new (StringMapEntryBase::allocateWithKey(
          sizeof(StringMapEntry), alignof(StringMapEntry), key, allocator))
+         StringMapEntry(key.size(), std::forward<InitTy>(initVals)...);
+@@ -167,7 +167,7 @@ struct tuple_size<llvm::StringMapEntry<ValueTy>>
+ 
+ template <std::size_t I, typename ValueTy>
+ struct tuple_element<I, llvm::StringMapEntry<ValueTy>>
+-    : std::conditional<I == 0, llvm::StringRef, ValueTy> {};
++    : std::conditional<I == 0, std::string_view, ValueTy> {};
+ } // namespace std
+ 
+ #endif // LLVM_ADT_STRINGMAPENTRY_H
 diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h
-index 9c2bd45d2..a7dea19d9 100644
+index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2bc7b64af 100644
 --- a/llvm/include/llvm/Support/Chrono.h
 +++ b/llvm/include/llvm/Support/Chrono.h
 @@ -70,7 +70,7 @@ raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP);
@@ -606,10 +619,10 @@
      bool show_unit = consumeShowUnit(Style);
  
 diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
-index 80b2dfaec..f5d726ec8 100644
+index 10d5cec231a523c943c37a5464cb3943627239a9..92376629c607461061bc60597a47aed1e535af52 100644
 --- a/llvm/include/llvm/Support/Compiler.h
 +++ b/llvm/include/llvm/Support/Compiler.h
-@@ -312,7 +312,7 @@
+@@ -300,7 +300,7 @@
  #endif
  
  /// LLVM_GSL_POINTER - Apply this to non-owning classes like
@@ -619,26 +632,23 @@
  #define LLVM_GSL_POINTER [[gsl::Pointer]]
  #else
 diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h
-index 374cdb907..7f1527f51 100644
+index c892bb3c03cb569994429649bdbb96e4118dcef1..5c0e3009c25446a34882fb98329b1d955231bb39 100644
 --- a/llvm/include/llvm/Support/ConvertUTF.h
 +++ b/llvm/include/llvm/Support/ConvertUTF.h
-@@ -89,12 +89,12 @@
- #ifndef LLVM_SUPPORT_CONVERTUTF_H
- #define LLVM_SUPPORT_CONVERTUTF_H
+@@ -107,10 +107,9 @@
  
-+#include "wpi/span.h"
-+
  #include <cstddef>
  #include <string>
 -
 -#if defined(_WIN32)
++#include <span>
 +#include <string_view>
  #include <system_error>
 -#endif
  
  // Wrap everything in namespace llvm so that programs can link with llvm and
  // their own version of the unicode libraries.
-@@ -183,12 +183,10 @@ unsigned getNumBytesForUTF8(UTF8 firstByte);
+@@ -204,12 +203,10 @@ unsigned getNumBytesForUTF8(UTF8 firstByte);
  /*************************************************************************/
  /* Below are LLVM-specific wrappers of the functions above. */
  
@@ -652,7 +662,7 @@
   * WideCharWidth. The converted data is written to ResultPtr, which needs to
   * point to at least WideCharWidth * (Source.Size() + 1) bytes. On success,
   * ResultPtr will point one after the end of the copied string. On failure,
-@@ -196,14 +194,14 @@ class StringRef;
+@@ -217,14 +214,14 @@ class StringRef;
   * the first character which could not be converted.
   * \return true on success.
   */
@@ -670,7 +680,7 @@
  
  /**
  * Converts a UTF-8 C-string to a std::wstring.
-@@ -261,7 +259,7 @@ inline ConversionResult convertUTF8Sequence(const UTF8 **source,
+@@ -282,7 +279,7 @@ inline ConversionResult convertUTF8Sequence(const UTF8 **source,
   * Returns true if a blob of text starts with a UTF-16 big or little endian byte
   * order mark.
   */
@@ -679,7 +689,7 @@
  
  /**
   * Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
-@@ -270,7 +268,7 @@ bool hasUTF16ByteOrderMark(ArrayRef<char> SrcBytes);
+@@ -291,7 +288,7 @@ bool hasUTF16ByteOrderMark(ArrayRef<char> SrcBytes);
   * \param [out] Out Converted UTF-8 is stored here on success.
   * \returns true on success
   */
@@ -688,7 +698,7 @@
  
  /**
  * Converts a UTF16 string into a UTF8 std::string.
-@@ -279,22 +277,22 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
+@@ -300,7 +297,7 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
  * \param [out] Out Converted UTF-8 is stored here on success.
  * \returns true on success
  */
@@ -696,6 +706,24 @@
 +bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out);
  
  /**
+  * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+@@ -309,7 +306,7 @@ bool convertUTF16ToUTF8String(ArrayRef<UTF16> Src, std::string &Out);
+  * \param [out] Out Converted UTF-8 is stored here on success.
+  * \returns true on success
+  */
+-bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
++bool convertUTF32ToUTF8String(span<const char> SrcBytes, std::string &Out);
+ 
+ /**
+  * Converts a UTF32 string into a UTF8 std::string.
+@@ -318,22 +315,22 @@ bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
+  * \param [out] Out Converted UTF-8 is stored here on success.
+  * \returns true on success
+  */
+-bool convertUTF32ToUTF8String(ArrayRef<UTF32> Src, std::string &Out);
++bool convertUTF32ToUTF8String(span<const UTF32> Src, std::string &Out);
+ 
+ /**
   * Converts a UTF-8 string into a UTF-16 string with native endianness.
   *
   * \returns true on success
@@ -715,29 +743,8 @@
  std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
                              SmallVectorImpl<char> &utf8);
  /// Convert from UTF16 to the current code page used in the system
-diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h
-index 8a04a324a..8737cd144 100644
---- a/llvm/include/llvm/Support/DJB.h
-+++ b/llvm/include/llvm/Support/DJB.h
-@@ -13,13 +13,13 @@
- #ifndef LLVM_SUPPORT_DJB_H
- #define LLVM_SUPPORT_DJB_H
- 
--#include "llvm/ADT/StringRef.h"
-+#include <string_view>
- 
- namespace llvm {
- 
- /// The Bernstein hash function used by the DWARF accelerator tables.
--inline uint32_t djbHash(StringRef Buffer, uint32_t H = 5381) {
--  for (unsigned char C : Buffer.bytes())
-+inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) {
-+  for (unsigned char C : Buffer)
-     H = (H << 5) + H + C;
-   return H;
- }
 diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h
-index 6791df6be..3f726d40b 100644
+index 9c8e3448f3a03e3540adb8b9dd730c77dd9b20ba..68c27a8c67c4f378b92cfa726659ef7824b56dea 100644
 --- a/llvm/include/llvm/Support/ErrorHandling.h
 +++ b/llvm/include/llvm/Support/ErrorHandling.h
 @@ -15,10 +15,10 @@
@@ -769,7 +776,7 @@
  
  /// Installs a new bad alloc error handler that should be used whenever a
 diff --git a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
-index f7f2d4e54..b5e321b5f 100644
+index f7f2d4e54e705d6f29812dc93d1fb0a3ca2dee12..b5e321b5f74ce35940649b9d1342b3cdf0c4931f 100644
 --- a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
 +++ b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
 @@ -35,8 +35,8 @@ public:
@@ -793,56 +800,18 @@
    BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }
  
 diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
-index 1a1072d22..3d6573bf5 100644
+index 828a6db54708dfa9a1a4b4456a92945a92ad80cb..953b40701dc934c1a356b5413c9c6c692d5f5679 100644
 --- a/llvm/include/llvm/Support/VersionTuple.h
 +++ b/llvm/include/llvm/Support/VersionTuple.h
-@@ -16,14 +16,13 @@
- 
- #include "llvm/ADT/DenseMapInfo.h"
- #include "llvm/ADT/Hashing.h"
--#include "llvm/ADT/Optional.h"
- #include "llvm/Support/HashBuilder.h"
-+#include <optional>
- #include <string>
- #include <tuple>
- 
- namespace llvm {
+@@ -25,7 +25,6 @@ namespace llvm {
+ template <typename HasherT, support::endianness Endianness>
+ class HashBuilderImpl;
  class raw_ostream;
 -class StringRef;
  
  /// Represents a version number in the form major[.minor[.subminor[.build]]].
  class VersionTuple {
-@@ -70,23 +69,23 @@ public:
-   unsigned getMajor() const { return Major; }
- 
-   /// Retrieve the minor version number, if provided.
--  Optional<unsigned> getMinor() const {
-+  std::optional<unsigned> getMinor() const {
-     if (!HasMinor)
--      return None;
-+      return std::nullopt;
-     return Minor;
-   }
- 
-   /// Retrieve the subminor version number, if provided.
--  Optional<unsigned> getSubminor() const {
-+  std::optional<unsigned> getSubminor() const {
-     if (!HasSubminor)
--      return None;
-+      return std::nullopt;
-     return Subminor;
-   }
- 
-   /// Retrieve the build version number, if provided.
--  Optional<unsigned> getBuild() const {
-+  std::optional<unsigned> getBuild() const {
-     if (!HasBuild)
--      return None;
-+      return std::nullopt;
-     return Build;
-   }
- 
-@@ -173,11 +172,6 @@ public:
+@@ -182,11 +181,6 @@ public:
  
    /// Retrieve a string representation of the version number.
    std::string getAsString() const;
@@ -855,7 +824,7 @@
  
  /// Print a version number.
 diff --git a/llvm/include/llvm/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h
-index 917822678..180803fbd 100644
+index d3aacd14b2097b1e7e13c1003987c1fd52e0cf76..aabdb2f14668a990329b57f5454a0d7db73e12ce 100644
 --- a/llvm/include/llvm/Support/Windows/WindowsSupport.h
 +++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h
 @@ -35,8 +35,6 @@
@@ -867,7 +836,7 @@
  #include "llvm/Config/llvm-config.h" // Get build system configuration settings
  #include "llvm/Support/Allocator.h"
  #include "llvm/Support/Chrono.h"
-@@ -71,7 +69,7 @@ bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix);
+@@ -74,7 +72,7 @@ bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix);
  [[noreturn]] inline void ReportLastErrorFatal(const char *Msg) {
    std::string ErrMsg;
    MakeErrMsg(&ErrMsg, Msg);
@@ -877,21 +846,25 @@
  
  template <typename HandleTraits>
 diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
-index 58adb41cb..9a1dd7a60 100644
+index 1e01eb9ea19c4187302a91457b6d34fbe5b67584..2463f1af612a78cafafe3c0e16d496e607cdc322 100644
 --- a/llvm/include/llvm/Support/raw_ostream.h
 +++ b/llvm/include/llvm/Support/raw_ostream.h
-@@ -14,9 +14,7 @@
+@@ -14,13 +14,12 @@
  #define LLVM_SUPPORT_RAW_OSTREAM_H
  
  #include "llvm/ADT/SmallVector.h"
 -#include "llvm/ADT/StringRef.h"
--#include "llvm/ADT/Optional.h"
 -#include "llvm/Support/DataTypes.h"
-+#include "llvm/ADT/span.h"
  #include <cassert>
  #include <cstddef>
  #include <cstdint>
-@@ -210,7 +208,22 @@ public:
+ #include <cstring>
+ #include <optional>
++#include <span>
+ #include <string>
+ #include <string_view>
+ #include <system_error>
+@@ -208,7 +207,22 @@ public:
      return *this;
    }
  
@@ -915,7 +888,7 @@
      // Inline fast path, particularly for strings with a known length.
      size_t Size = Str.size();
  
-@@ -229,7 +242,7 @@ public:
+@@ -241,7 +255,7 @@ public:
      // Inline fast path, particularly for constant strings where a sufficiently
      // smart compiler will simplify strlen.
  
@@ -924,20 +897,18 @@
    }
  
    raw_ostream &operator<<(const std::string &Str) {
-@@ -237,12 +250,6 @@ public:
+@@ -249,10 +263,6 @@ public:
      return write(Str.data(), Str.length());
    }
  
--#if __cplusplus > 201402L
 -  raw_ostream &operator<<(const std::string_view &Str) {
 -    return write(Str.data(), Str.length());
 -  }
--#endif
 -
    raw_ostream &operator<<(const SmallVectorImpl<char> &Str) {
      return write(Str.data(), Str.size());
    }
-@@ -275,7 +282,7 @@ public:
+@@ -285,7 +295,7 @@ public:
  
    /// Output \p Str, turning '\\', '\t', '\n', '"', and anything that doesn't
    /// satisfy llvm::isPrint into an escape sequence.
@@ -946,16 +917,7 @@
  
    raw_ostream &write(unsigned char C);
    raw_ostream &write(const char *Ptr, size_t Size);
-@@ -446,7 +453,7 @@ class raw_fd_ostream : public raw_pwrite_stream {
-   bool ShouldClose;
-   bool SupportsSeeking = false;
-   bool IsRegularFile = false;
--  mutable Optional<bool> HasColors;
-+  mutable std::optional<bool> HasColors;
- 
- #ifdef _WIN32
-   /// True if this fd refers to a Windows console device. Mintty and other
-@@ -491,14 +498,14 @@ public:
+@@ -501,14 +511,14 @@ public:
    /// As a special case, if Filename is "-", then the stream will use
    /// STDOUT_FILENO instead of opening a file. This will not close the stdout
    /// descriptor.
@@ -975,7 +937,7 @@
                   sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
                   sys::fs::OpenFlags Flags);
  
-@@ -603,7 +610,7 @@ public:
+@@ -613,7 +623,7 @@ public:
    /// Open the specified file for reading/writing/seeking. If an error occurs,
    /// information about the error is put into EC, and the stream should be
    /// immediately destroyed.
@@ -984,7 +946,7 @@
  
    /// This reads the \p Size bytes into a buffer pointed by \p Ptr.
    ///
-@@ -683,8 +690,8 @@ public:
+@@ -693,8 +703,8 @@ public:
  
    void flush() = delete;
  
@@ -995,7 +957,7 @@
  
    void reserveExtraSpace(uint64_t ExtraSize) override {
      OS.reserve(tell() + ExtraSize);
-@@ -741,7 +748,7 @@ class Error;
+@@ -751,7 +761,7 @@ class Error;
  /// for other names. For raw_fd_ostream instances, the stream writes to
  /// a temporary file. The final output file is atomically replaced with the
  /// temporary file after the \p Write function is finished.
@@ -1003,9 +965,39 @@
 +Error writeToOutput(std::string_view OutputFileName,
                      std::function<Error(raw_ostream &)> Write);
  
- } // end namespace llvm
+ raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t);
+diff --git a/llvm/include/llvm/Support/xxhash.h b/llvm/include/llvm/Support/xxhash.h
+index 0cef3a54e50d70177a7401324f7a4daca83c6599..3e19ebabb7ad0ff437220d9fdfe59a313386762a 100644
+--- a/llvm/include/llvm/Support/xxhash.h
++++ b/llvm/include/llvm/Support/xxhash.h
+@@ -38,16 +38,18 @@
+ #ifndef LLVM_SUPPORT_XXHASH_H
+ #define LLVM_SUPPORT_XXHASH_H
+ 
+-#include "llvm/ADT/ArrayRef.h"
+-#include "llvm/ADT/StringRef.h"
++#include <stdint.h>
++
++#include <span>
++#include <string_view>
+ 
+ namespace llvm {
+-uint64_t xxHash64(llvm::StringRef Data);
+-uint64_t xxHash64(llvm::ArrayRef<uint8_t> Data);
++uint64_t xxHash64(std::string_view Data);
++uint64_t xxHash64(span<const uint8_t> Data);
+ 
+-uint64_t xxh3_64bits(ArrayRef<uint8_t> data);
+-inline uint64_t xxh3_64bits(StringRef data) {
+-  return xxh3_64bits(ArrayRef(data.bytes_begin(), data.size()));
++uint64_t xxh3_64bits(span<const uint8_t> data);
++inline uint64_t xxh3_64bits(std::string_view data) {
++  return xxh3_64bits(span(reinterpret_cast<const uint8_t*>(data.data()), data.size()));
+ }
+ }
+ 
 diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp
-index 392c4c489..396ab0c65 100644
+index 3fa7365e72d34a5db941d1cbe2b1beebad5c10e6..d53462e742e61d3476915d5b2c5aa63772e78a8a 100644
 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp
 +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp
 @@ -6,24 +6,24 @@
@@ -1014,10 +1006,10 @@
  
 -#include "llvm/ADT/ArrayRef.h"
 -#include "llvm/ADT/StringRef.h"
-+#include "llvm/ADT/span.h"
  #include "llvm/Support/ConvertUTF.h"
  #include "llvm/Support/ErrorHandling.h"
  #include "llvm/Support/SwapByteOrder.h"
++#include <span>
  #include <string>
 +#include <string_view>
  #include <vector>
@@ -1038,15 +1030,14 @@
        result = sourceIllegal;
        ErrorPtr = Pos;
      } else {
-@@ -77,13 +77,13 @@ bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) {
+@@ -76,12 +76,12 @@ bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) {
    return true;
  }
  
 -bool hasUTF16ByteOrderMark(ArrayRef<char> S) {
 +bool hasUTF16ByteOrderMark(span<const char> S) {
-   return (S.size() >= 2 &&
-           ((S[0] == '\xff' && S[1] == '\xfe') ||
-            (S[0] == '\xfe' && S[1] == '\xff')));
+   return (S.size() >= 2 && ((S[0] == '\xff' && S[1] == '\xfe') ||
+                             (S[0] == '\xfe' && S[1] == '\xff')));
  }
  
 -bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
@@ -1054,17 +1045,35 @@
    assert(Out.empty());
  
    // Error out on an uneven byte count.
-@@ -134,14 +134,14 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
+@@ -132,14 +132,14 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
    return true;
  }
  
--bool convertUTF16ToUTF8String(ArrayRef<UTF16> Src, std::string &Out)
-+bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out)
- {
+-bool convertUTF16ToUTF8String(ArrayRef<UTF16> Src, std::string &Out) {
++bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out) {
    return convertUTF16ToUTF8String(
 -      llvm::ArrayRef<char>(reinterpret_cast<const char *>(Src.data()),
 +      span<const char>(reinterpret_cast<const char *>(Src.data()),
-       Src.size() * sizeof(UTF16)), Out);
+                            Src.size() * sizeof(UTF16)),
+       Out);
+ }
+ 
+-bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
++bool convertUTF32ToUTF8String(span<const char> SrcBytes, std::string &Out) {
+   assert(Out.empty());
+ 
+   // Error out on an uneven byte count.
+@@ -190,14 +190,14 @@ bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
+   return true;
+ }
+ 
+-bool convertUTF32ToUTF8String(ArrayRef<UTF32> Src, std::string &Out) {
++bool convertUTF32ToUTF8String(span<const UTF32> Src, std::string &Out) {
+   return convertUTF32ToUTF8String(
+-      llvm::ArrayRef<char>(reinterpret_cast<const char *>(Src.data()),
++      span<const char>(reinterpret_cast<const char *>(Src.data()),
+                            Src.size() * sizeof(UTF32)),
+       Out);
  }
  
 -bool convertUTF8ToUTF16String(StringRef SrcUTF8,
@@ -1072,7 +1081,7 @@
                                SmallVectorImpl<UTF16> &DstUTF16) {
    assert(DstUTF16.empty());
  
-@@ -152,8 +152,8 @@ bool convertUTF8ToUTF16String(StringRef SrcUTF8,
+@@ -208,8 +208,8 @@ bool convertUTF8ToUTF16String(StringRef SrcUTF8,
      return true;
    }
  
@@ -1083,7 +1092,7 @@
  
    // Allocate the same number of UTF-16 code units as UTF-8 code units. Encoding
    // as UTF-16 should always require the same amount or less code units than the
-@@ -184,7 +184,7 @@ static_assert(sizeof(wchar_t) == 1 || sizeof(wchar_t) == 2 ||
+@@ -240,7 +240,7 @@ static_assert(sizeof(wchar_t) == 1 || sizeof(wchar_t) == 2 ||
                "Expected wchar_t to be 1, 2, or 4 bytes");
  
  template <typename TResult>
@@ -1092,7 +1101,7 @@
                                               TResult &Result) {
    // Even in the case of UTF-16, the number of bytes in a UTF-8 string is
    // at least as large as the number of elements in the resulting wide
-@@ -200,7 +200,7 @@ static inline bool ConvertUTF8toWideInternal(llvm::StringRef Source,
+@@ -256,7 +256,7 @@ static inline bool ConvertUTF8toWideInternal(llvm::StringRef Source,
    return true;
  }
  
@@ -1101,7 +1110,7 @@
    return ConvertUTF8toWideInternal(Source, Result);
  }
  
-@@ -209,7 +209,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result) {
+@@ -265,7 +265,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result) {
      Result.clear();
      return true;
    }
@@ -1110,7 +1119,7 @@
  }
  
  bool convertWideToUTF8(const std::wstring &Source, std::string &Result) {
-@@ -224,7 +224,7 @@ bool convertWideToUTF8(const std::wstring &Source, std::string &Result) {
+@@ -280,7 +280,7 @@ bool convertWideToUTF8(const std::wstring &Source, std::string &Result) {
      return true;
    } else if (sizeof(wchar_t) == 2) {
      return convertUTF16ToUTF8String(
@@ -1120,7 +1129,7 @@
          Result);
    } else if (sizeof(wchar_t) == 4) {
 diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
-index 80c0e0043..8ae8fb8b4 100644
+index b8b3b7424ac6b1de782e739782f9671194ce77a1..0aa13a0f78eb370b2a673ca4a773f26820575052 100644
 --- a/llvm/lib/Support/ErrorHandling.cpp
 +++ b/llvm/lib/Support/ErrorHandling.cpp
 @@ -14,7 +14,6 @@
@@ -1169,7 +1178,7 @@
      (void)written; // If something went wrong, we deliberately just give up.
    }
 diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
-index 8cafbc7fa..8bad715e4 100644
+index f7e7e80332cc337f6dfa388d1e218e6f3ec95cf2..6cefdff7c28060ca18b522acf5279af3a206e23a 100644
 --- a/llvm/lib/Support/SmallVector.cpp
 +++ b/llvm/lib/Support/SmallVector.cpp
 @@ -11,7 +11,6 @@
@@ -1199,19 +1208,19 @@
  }
  
 diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp
-index 012c785b4..317f4ee43 100644
+index 67c05a87959cf0c243d17646ae2f28f6c9f0d708..7be219323f6d76f32a9a841115f2f146141cdbab 100644
 --- a/llvm/lib/Support/StringMap.cpp
 +++ b/llvm/lib/Support/StringMap.cpp
-@@ -70,7 +70,7 @@ void StringMapImpl::init(unsigned InitSize) {
+@@ -81,7 +81,7 @@ void StringMapImpl::init(unsigned InitSize) {
  /// specified bucket will be non-null.  Otherwise, it will be null.  In either
  /// case, the FullHashValue field of the bucket will be set to the hash value
  /// of the string.
 -unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
 +unsigned StringMapImpl::LookupBucketFor(std::string_view Name) {
-   unsigned HTSize = NumBuckets;
-   if (HTSize == 0) { // Hash table unallocated so far?
+   // Hash table unallocated so far?
+   if (NumBuckets == 0)
      init(16);
-@@ -110,7 +110,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
+@@ -121,7 +121,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
        // Do the comparison like this because Name isn't necessarily
        // null-terminated!
        char *ItemStr = (char *)BucketItem + ItemSize;
@@ -1220,16 +1229,16 @@
          // We found a match!
          return BucketNo;
        }
-@@ -128,7 +128,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
+@@ -139,7 +139,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
  /// FindKey - Look up the bucket that contains the specified key. If it exists
  /// in the map, return the bucket number of the key.  Otherwise return -1.
  /// This does not modify the map.
 -int StringMapImpl::FindKey(StringRef Key) const {
 +int StringMapImpl::FindKey(std::string_view Key) const {
-   unsigned HTSize = NumBuckets;
-   if (HTSize == 0)
+   if (NumBuckets == 0)
      return -1; // Really empty table?
-@@ -154,7 +154,7 @@ int StringMapImpl::FindKey(StringRef Key) const {
+   unsigned FullHashValue = xxh3_64bits(Key);
+@@ -166,7 +166,7 @@ int StringMapImpl::FindKey(StringRef Key) const {
        // Do the comparison like this because NameStart isn't necessarily
        // null-terminated!
        char *ItemStr = (char *)BucketItem + ItemSize;
@@ -1238,7 +1247,7 @@
          // We found a match!
          return BucketNo;
        }
-@@ -173,14 +173,14 @@ int StringMapImpl::FindKey(StringRef Key) const {
+@@ -185,14 +185,14 @@ int StringMapImpl::FindKey(StringRef Key) const {
  /// delete it.  This aborts if the value isn't in the table.
  void StringMapImpl::RemoveKey(StringMapEntryBase *V) {
    const char *VStr = (char *)V + ItemSize;
@@ -1256,10 +1265,10 @@
    if (Bucket == -1)
      return nullptr;
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index 69d4fe96b..e4c318eb8 100644
+index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d83ac20248 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
-@@ -159,7 +159,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) {
+@@ -166,7 +166,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) {
  }
  
  
@@ -1268,7 +1277,7 @@
                                          bool UseHexEscapes) {
    for (unsigned char c : Str) {
      switch (c) {
-@@ -563,7 +563,7 @@ void format_object_base::home() {
+@@ -569,7 +569,7 @@ void format_object_base::home() {
  //  raw_fd_ostream
  //===----------------------------------------------------------------------===//
  
@@ -1277,7 +1286,7 @@
                   sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
                   sys::fs::OpenFlags Flags) {
    assert((Access & sys::fs::FA_Write) &&
-@@ -589,25 +589,25 @@ static int getFD(StringRef Filename, std::error_code &EC,
+@@ -595,25 +595,25 @@ static int getFD(StringRef Filename, std::error_code &EC,
    return FD;
  }
  
@@ -1308,7 +1317,7 @@
                                 sys::fs::CreationDisposition Disp,
                                 sys::fs::FileAccess Access,
                                 sys::fs::OpenFlags Flags)
-@@ -679,8 +679,7 @@ raw_fd_ostream::~raw_fd_ostream() {
+@@ -685,8 +685,7 @@ raw_fd_ostream::~raw_fd_ostream() {
    // has_error() and clear the error flag with clear_error() before
    // destructing raw_ostream objects which may have errors.
    if (has_error())
@@ -1318,7 +1327,7 @@
                         /*gen_crash_diag=*/false);
  }
  
-@@ -699,7 +698,7 @@ raw_fd_ostream::~raw_fd_ostream() {
+@@ -705,7 +704,7 @@ raw_fd_ostream::~raw_fd_ostream() {
  // the input is UTF-8 or transcode from the local codepage to UTF-8 before
  // quoting it. If they don't, this may mess up the encoding, but this is still
  // probably the best compromise we can make.
@@ -1327,7 +1336,7 @@
    SmallVector<wchar_t, 256> WideText;
  
    // Fall back to ::write if it wasn't valid UTF-8.
-@@ -742,7 +741,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
+@@ -748,7 +747,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
    // If this is a Windows console device, try re-encoding from UTF-8 to UTF-16
    // and using WriteConsoleW. If that fails, fall back to plain write().
    if (IsWindowsConsole)
@@ -1336,7 +1345,7 @@
        return;
  #endif
  
-@@ -906,7 +905,7 @@ raw_ostream &llvm::nulls() {
+@@ -919,7 +918,7 @@ raw_ostream &llvm::nulls() {
  // File Streams
  //===----------------------------------------------------------------------===//
  
@@ -1345,7 +1354,7 @@
      : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways,
                             sys::fs::FA_Write | sys::fs::FA_Read,
                             sys::fs::OF_None),
-@@ -984,7 +983,7 @@ void buffer_ostream::anchor() {}
+@@ -997,7 +996,7 @@ void buffer_ostream::anchor() {}
  
  void buffer_unique_ostream::anchor() {}
  
@@ -1354,11 +1363,61 @@
                            std::function<Error(raw_ostream &)> Write) {
    if (OutputFileName == "-")
      return Write(outs());
+diff --git a/llvm/lib/Support/xxhash.cpp b/llvm/lib/Support/xxhash.cpp
+index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85fa201073 100644
+--- a/llvm/lib/Support/xxhash.cpp
++++ b/llvm/lib/Support/xxhash.cpp
+@@ -84,11 +84,11 @@ static uint64_t XXH64_avalanche(uint64_t hash) {
+   return hash;
+ }
+ 
+-uint64_t llvm::xxHash64(StringRef Data) {
++uint64_t llvm::xxHash64(std::string_view Data) {
+   size_t Len = Data.size();
+   uint64_t Seed = 0;
+-  const unsigned char *P = Data.bytes_begin();
+-  const unsigned char *const BEnd = Data.bytes_end();
++  const unsigned char *P = reinterpret_cast<const unsigned char*>(Data.data());
++  const unsigned char *const BEnd = P + Data.size();
+   uint64_t H64;
+ 
+   if (Len >= 32) {
+@@ -144,7 +144,7 @@ uint64_t llvm::xxHash64(StringRef Data) {
+   return XXH64_avalanche(H64);
+ }
+ 
+-uint64_t llvm::xxHash64(ArrayRef<uint8_t> Data) {
++uint64_t llvm::xxHash64(span<const uint8_t> Data) {
+   return xxHash64({(const char *)Data.data(), Data.size()});
+ }
+ 
+@@ -394,7 +394,7 @@ static uint64_t XXH3_hashLong_64b(const uint8_t *input, size_t len,
+                         (uint64_t)len * PRIME64_1);
+ }
+ 
+-uint64_t llvm::xxh3_64bits(ArrayRef<uint8_t> data) {
++uint64_t llvm::xxh3_64bits(span<const uint8_t> data) {
+   auto *in = data.data();
+   size_t len = data.size();
+   if (len <= 16)
 diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
-index 4dd314c5c..e505b1907 100644
+index cc3244528f27e2bd7eaa385d8b7f49b2fbb7a3e6..b710ac07461ba58faa99cedeae7f209dc0f5902b 100644
 --- a/llvm/unittests/ADT/DenseMapTest.cpp
 +++ b/llvm/unittests/ADT/DenseMapTest.cpp
-@@ -481,31 +481,6 @@ TEST(DenseMapCustomTest, ReserveTest) {
+@@ -9,11 +9,11 @@
+ #include "llvm/ADT/DenseMap.h"
+ #include "llvm/ADT/DenseMapInfo.h"
+ #include "llvm/ADT/DenseMapInfoVariant.h"
+-#include "llvm/ADT/StringRef.h"
+ #include "gmock/gmock.h"
+ #include "gtest/gtest.h"
+ #include <map>
+ #include <set>
++#include <string_view>
+ #include <utility>
+ #include <variant>
+ 
+@@ -499,31 +499,6 @@ TEST(DenseMapCustomTest, ReserveTest) {
    }
  }
  
@@ -1390,8 +1449,17 @@
  // Key traits that allows lookup with either an unsigned or char* key;
  // In the latter case, "a" == 0, "b" == 1 and so on.
  struct TestDenseMapInfo {
+@@ -761,7 +736,7 @@ TEST(DenseMapCustomTest, VariantSupport) {
+ // Test that gTest prints map entries as pairs instead of opaque objects.
+ // See third-party/unittest/googletest/internal/custom/gtest-printers.h
+ TEST(DenseMapCustomTest, PairPrinting) {
+-  DenseMap<int, StringRef> Map = {{1, "one"}, {2, "two"}};
++  DenseMap<int, std::string_view> Map = {{1, "one"}, {2, "two"}};
+   EXPECT_EQ(R"({ (1, "one"), (2, "two") })", ::testing::PrintToString(Map));
+ }
+ 
 diff --git a/llvm/unittests/ADT/FunctionExtrasTest.cpp b/llvm/unittests/ADT/FunctionExtrasTest.cpp
-index fc856a976..aff9d61c7 100644
+index fc856a976946bf6decda9b6724cac66afc7bdcd6..aff9d61c7f0d48834123b04b74a2e4f7c86a56d8 100644
 --- a/llvm/unittests/ADT/FunctionExtrasTest.cpp
 +++ b/llvm/unittests/ADT/FunctionExtrasTest.cpp
 @@ -249,23 +249,23 @@ TEST(UniqueFunctionTest, Const) {
@@ -1425,10 +1493,10 @@
  TEST(UniqueFunctionTest, SFINAE) {
    EXPECT_EQ("not a function", returns("boo!"));
 diff --git a/llvm/unittests/ADT/HashingTest.cpp b/llvm/unittests/ADT/HashingTest.cpp
-index bb19a5699..0634767a4 100644
+index 01a8a962b8e2e33ca8f189c049e9548ced42ec3a..62aff9c3b21eea785ca71c6e290c9c4f3a20ae00 100644
 --- a/llvm/unittests/ADT/HashingTest.cpp
 +++ b/llvm/unittests/ADT/HashingTest.cpp
-@@ -277,7 +277,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) {
+@@ -295,7 +295,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) {
  #endif
    };
    for (unsigned i = 0; i < sizeof(golden_data)/sizeof(*golden_data); ++i) {
@@ -1438,7 +1506,7 @@
  #if 0 // Enable this to generate paste-able text for the above structure.
      std::string member_str = "\"" + str.str() + "\",";
 diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
-index 414298c4e..6f3c94eed 100644
+index a97f2617cbf70783f3569709f7ee1bff03baebd2..7ed8670fd31ea2a14e6ba7f59a8ac8e35046890c 100644
 --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
 +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
 @@ -12,7 +12,6 @@
@@ -1450,7 +1518,7 @@
  #include "gtest/gtest.h"
  
 diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp
-index b207f582e..bee3875d1 100644
+index 2f4df8afeafa592cb9616bb78feb4964187786f2..6cf14700b34739420cd3dc4ff8a4c16ce162f715 100644
 --- a/llvm/unittests/ADT/SmallStringTest.cpp
 +++ b/llvm/unittests/ADT/SmallStringTest.cpp
 @@ -50,43 +50,43 @@ TEST_F(SmallStringTest, AssignRepeated) {
@@ -1589,19 +1657,37 @@
    theString = "hellx xello hell ello world foo bar hello";
    EXPECT_EQ(36U, theString.find("hello"));
 diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp
-index 3fbea5299..fe827546a 100644
+index 137dd43b473068eae34b39edc4b9b8b9633bab95..7029038d18d433cef987bedbfa4fda269b24fb8f 100644
 --- a/llvm/unittests/ADT/SmallVectorTest.cpp
 +++ b/llvm/unittests/ADT/SmallVectorTest.cpp
-@@ -11,7 +11,7 @@
+@@ -11,10 +11,10 @@
  //===----------------------------------------------------------------------===//
  
  #include "llvm/ADT/SmallVector.h"
 -#include "llvm/ADT/ArrayRef.h"
-+#include "llvm/ADT/span.h"
  #include "llvm/Support/Compiler.h"
  #include "gtest/gtest.h"
  #include <list>
-@@ -1070,24 +1070,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) {
++#include <span>
+ #include <stdarg.h>
+ 
+ using namespace llvm;
+@@ -252,11 +252,11 @@ TYPED_TEST(SmallVectorTest, ConstructorIterTest) {
+ }
+ 
+ // Constructor test.
+-TYPED_TEST(SmallVectorTest, ConstructorFromArrayRefSimpleTest) {
+-  SCOPED_TRACE("ConstructorFromArrayRefSimpleTest");
++TYPED_TEST(SmallVectorTest, ConstructorFromSpanSimpleTest) {
++  SCOPED_TRACE("ConstructorFromSpanSimpleTest");
+   std::array<Constructable, 3> StdArray = {Constructable(1), Constructable(2),
+                                            Constructable(3)};
+-  ArrayRef<Constructable> Array = StdArray;
++  span<const Constructable> Array = StdArray;
+   auto &V = this->theVector;
+   V = SmallVector<Constructable, 4>(Array);
+   assertValuesInOrder(V, 3u, 1, 2, 3);
+@@ -1129,24 +1129,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) {
    EXPECT_EQ(NestedV[0][0][0], 42);
  }
  
@@ -1609,25 +1695,38 @@
 -  SmallVector<int, 2> V1 = {};
 -  EXPECT_TRUE(V1.empty());
 -  V1 = {0, 0};
--  EXPECT_TRUE(makeArrayRef(V1).equals({0, 0}));
+-  EXPECT_TRUE(ArrayRef(V1).equals({0, 0}));
 -  V1 = {-1, -1};
--  EXPECT_TRUE(makeArrayRef(V1).equals({-1, -1}));
+-  EXPECT_TRUE(ArrayRef(V1).equals({-1, -1}));
 -
 -  SmallVector<int, 2> V2 = {1, 2, 3, 4};
--  EXPECT_TRUE(makeArrayRef(V2).equals({1, 2, 3, 4}));
+-  EXPECT_TRUE(ArrayRef(V2).equals({1, 2, 3, 4}));
 -  V2.assign({4});
--  EXPECT_TRUE(makeArrayRef(V2).equals({4}));
+-  EXPECT_TRUE(ArrayRef(V2).equals({4}));
 -  V2.append({3, 2});
--  EXPECT_TRUE(makeArrayRef(V2).equals({4, 3, 2}));
+-  EXPECT_TRUE(ArrayRef(V2).equals({4, 3, 2}));
 -  V2.insert(V2.begin() + 1, 5);
--  EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2}));
+-  EXPECT_TRUE(ArrayRef(V2).equals({4, 5, 3, 2}));
 -}
 -
- template <class VectorT>
- class SmallVectorReferenceInvalidationTest : public SmallVectorTestBase {
- protected:
+ TEST(SmallVectorTest, ToVector) {
+   {
+     std::vector<char> v = {'a', 'b', 'c'};
+@@ -1183,10 +1165,10 @@ private:
+   To T;
+ };
+ 
+-TEST(SmallVectorTest, ConstructFromArrayRefOfConvertibleType) {
++TEST(SmallVectorTest, ConstructFromSpanOfConvertibleType) {
+   To to1{1}, to2{2}, to3{3};
+   std::vector<From> StdVector = {From(to1), From(to2), From(to3)};
+-  ArrayRef<From> Array = StdVector;
++  span<const From> Array = StdVector;
+   {
+     llvm::SmallVector<To> Vector(Array);
+ 
 diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
-index 817fec6c3..86907ab61 100644
+index f9b138e9a472137139397d9cae76823711594211..7f10b3d7d3a8894b1ab0ac660268d94a8b89e082 100644
 --- a/llvm/unittests/ADT/StringMapTest.cpp
 +++ b/llvm/unittests/ADT/StringMapTest.cpp
 @@ -7,8 +7,6 @@
@@ -1639,33 +1738,33 @@
  #include "llvm/Support/DataTypes.h"
  #include "gtest/gtest.h"
  #include <limits>
-@@ -38,10 +36,10 @@ protected:
- 
+@@ -43,10 +41,10 @@ protected:
      // Lookup tests
+     EXPECT_FALSE(testMap.contains(testKey));
      EXPECT_EQ(0u, testMap.count(testKey));
 -    EXPECT_EQ(0u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
 +    EXPECT_EQ(0u, testMap.count(std::string_view(testKeyFirst, testKeyLength)));
      EXPECT_EQ(0u, testMap.count(testKeyStr));
      EXPECT_TRUE(testMap.find(testKey) == testMap.end());
--    EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) == 
-+    EXPECT_TRUE(testMap.find(std::string_view(testKeyFirst, testKeyLength)) == 
+-    EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
++    EXPECT_TRUE(testMap.find(std::string_view(testKeyFirst, testKeyLength)) ==
                  testMap.end());
      EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end());
    }
-@@ -61,10 +59,10 @@ protected:
- 
+@@ -67,10 +65,10 @@ protected:
      // Lookup tests
+     EXPECT_TRUE(testMap.contains(testKey));
      EXPECT_EQ(1u, testMap.count(testKey));
 -    EXPECT_EQ(1u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
 +    EXPECT_EQ(1u, testMap.count(std::string_view(testKeyFirst, testKeyLength)));
      EXPECT_EQ(1u, testMap.count(testKeyStr));
      EXPECT_TRUE(testMap.find(testKey) == testMap.begin());
--    EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) == 
-+    EXPECT_TRUE(testMap.find(std::string_view(testKeyFirst, testKeyLength)) == 
+-    EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
++    EXPECT_TRUE(testMap.find(std::string_view(testKeyFirst, testKeyLength)) ==
                  testMap.begin());
      EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin());
    }
-@@ -104,10 +102,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) {
+@@ -108,10 +106,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) {
  
    // Lookup tests
    EXPECT_EQ(0u, constTestMap.count(testKey));
@@ -1678,25 +1777,25 @@
                constTestMap.end());
    EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
  }
-@@ -235,7 +233,7 @@ TEST_F(StringMapTest, StringMapEntryTest) {
+@@ -251,7 +249,7 @@ TEST_F(StringMapTest, StringMapEntryTest) {
    MallocAllocator Allocator;
    StringMap<uint32_t>::value_type *entry =
-       StringMap<uint32_t>::value_type::Create(
+       StringMap<uint32_t>::value_type::create(
 -          StringRef(testKeyFirst, testKeyLength), Allocator, 1u);
 +          std::string_view(testKeyFirst, testKeyLength), Allocator, 1u);
    EXPECT_STREQ(testKey, entry->first().data());
    EXPECT_EQ(1u, entry->second);
    entry->Destroy(Allocator);
-@@ -246,7 +244,7 @@ TEST_F(StringMapTest, InsertTest) {
+@@ -261,7 +259,7 @@ TEST_F(StringMapTest, StringMapEntryTest) {
+ TEST_F(StringMapTest, InsertTest) {
    SCOPED_TRACE("InsertTest");
-   testMap.insert(
-       StringMap<uint32_t>::value_type::Create(
--          StringRef(testKeyFirst, testKeyLength),
-+          std::string_view(testKeyFirst, testKeyLength),
-           testMap.getAllocator(), 1u));
+   testMap.insert(StringMap<uint32_t>::value_type::create(
+-      StringRef(testKeyFirst, testKeyLength), testMap.getAllocator(), 1u));
++      std::string_view(testKeyFirst, testKeyLength), testMap.getAllocator(), 1u));
    assertSingleItemMap();
  }
-@@ -316,10 +314,10 @@ TEST_F(StringMapTest, IterMapKeysVector) {
+ 
+@@ -330,10 +328,10 @@ TEST_F(StringMapTest, IterMapKeysVector) {
    Map["C"] = 3;
    Map["D"] = 3;
  
@@ -1709,7 +1808,7 @@
    EXPECT_EQ(Expected, Keys);
  }
  
-@@ -333,7 +331,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) {
+@@ -347,7 +345,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) {
    auto Keys = to_vector<4>(Map.keys());
    llvm::sort(Keys);
  
@@ -1718,13 +1817,13 @@
    EXPECT_EQ(Expected, Keys);
  }
  
-@@ -375,13 +373,13 @@ private:
+@@ -389,13 +387,13 @@ private:
  TEST_F(StringMapTest, MoveOnly) {
    StringMap<MoveOnly> t;
    t.insert(std::make_pair("Test", MoveOnly(42)));
 -  StringRef Key = "Test";
 +  std::string_view Key = "Test";
-   StringMapEntry<MoveOnly>::Create(Key, t.getAllocator(), MoveOnly(42))
+   StringMapEntry<MoveOnly>::create(Key, t.getAllocator(), MoveOnly(42))
        ->Destroy(t.getAllocator());
  }
  
@@ -1732,9 +1831,9 @@
 -  StringRef Key = "Test";
 +  std::string_view Key = "Test";
    MallocAllocator Allocator;
-   StringMapEntry<MoveOnly>::Create(Key, Allocator, Immovable())
+   StringMapEntry<MoveOnly>::create(Key, Allocator, Immovable())
        ->Destroy(Allocator);
-@@ -556,7 +554,7 @@ TEST(StringMapCustomTest, InitialSizeTest) {
+@@ -580,7 +578,7 @@ TEST(StringMapCustomTest, InitialSizeTest) {
      CountCtorCopyAndMove::Copy = 0;
      for (int i = 0; i < Size; ++i)
        Map.insert(std::pair<std::string, CountCtorCopyAndMove>(
@@ -1743,7 +1842,7 @@
            std::forward_as_tuple(i)));
      // After the initial move, the map will move the Elts in the Entry.
      EXPECT_EQ((unsigned)Size * 2, CountCtorCopyAndMove::Move);
-@@ -625,7 +623,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) {
+@@ -649,7 +647,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) {
    else
      LargeValue = std::numeric_limits<unsigned>::max() + 1ULL;
    StringMapEntry<int> LargeEntry(LargeValue);
@@ -1753,7 +1852,7 @@
  
    // Test that the entry can hold at least max size_t.
 diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp
-index 7bda6ea28..9c798437a 100644
+index 6e75fbae0969ba1bf0a76c4d79a123e405a8dae7..3b07d344f15a555f11ad5f8177a0a65b8a4fa472 100644
 --- a/llvm/unittests/Support/ConvertUTFTest.cpp
 +++ b/llvm/unittests/Support/ConvertUTFTest.cpp
 @@ -7,7 +7,6 @@
@@ -1773,7 +1872,16 @@
    std::string Result;
    bool Success = convertUTF16ToUTF8String(Ref, Result);
    EXPECT_TRUE(Success);
-@@ -28,7 +27,7 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
+@@ -29,7 +28,7 @@ TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF32) static const char Src[] =
+       "\xFF\xFE\x00\x00\xA0\x0C\x00\x00\x5F\x00\x00\x00\xA0\x0C\x00\x00";
+-  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
++  span<const char> Ref(Src, sizeof(Src) - 1);
+   std::string Result;
+   bool Success = convertUTF32ToUTF8String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -40,7 +39,7 @@ TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
  TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
    // Src is the look of disapproval.
    alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
@@ -1782,7 +1890,16 @@
    std::string Result;
    bool Success = convertUTF16ToUTF8String(Ref, Result);
    EXPECT_TRUE(Success);
-@@ -39,7 +38,7 @@ TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
+@@ -52,7 +51,7 @@ TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF32) static const char Src[] =
+       "\x00\x00\xFE\xFF\x00\x00\x0C\xA0\x00\x00\x00\x5F\x00\x00\x0C\xA0";
+-  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
++  span<const char> Ref(Src, sizeof(Src) - 1);
+   std::string Result;
+   bool Success = convertUTF32ToUTF8String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -63,7 +62,7 @@ TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
  TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
    // Src is the look of disapproval.
    static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
@@ -1791,41 +1908,42 @@
    SmallVector<UTF16, 5> Result;
    bool Success = convertUTF8ToUTF16String(Ref, Result);
    EXPECT_TRUE(Success);
-@@ -51,37 +50,37 @@ TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
+@@ -75,38 +74,38 @@ TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
  
  TEST(ConvertUTFTest, OddLengthInput) {
    std::string Result;
--  bool Success = convertUTF16ToUTF8String(makeArrayRef("xxxxx", 5), Result);
+-  bool Success = convertUTF16ToUTF8String(ArrayRef("xxxxx", 5), Result);
 +  bool Success = convertUTF16ToUTF8String(span<const char>("xxxxx", 5), Result);
    EXPECT_FALSE(Success);
  }
  
  TEST(ConvertUTFTest, Empty) {
    std::string Result;
--  bool Success = convertUTF16ToUTF8String(llvm::ArrayRef<char>(None), Result);
-+  bool Success = convertUTF16ToUTF8String(span<const char>(), Result);
+   bool Success =
+-      convertUTF16ToUTF8String(llvm::ArrayRef<char>(std::nullopt), Result);
++      convertUTF16ToUTF8String(span<const char>(), Result);
    EXPECT_TRUE(Success);
    EXPECT_TRUE(Result.empty());
  }
  
  TEST(ConvertUTFTest, HasUTF16BOM) {
--  bool HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xff\xfe", 2));
+-  bool HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xff\xfe", 2));
 +  bool HasBOM = hasUTF16ByteOrderMark("\xff\xfe");
    EXPECT_TRUE(HasBOM);
--  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff", 2));
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff", 2));
 +  HasBOM = hasUTF16ByteOrderMark("\xfe\xff");
    EXPECT_TRUE(HasBOM);
--  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff ", 3));
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff ", 3));
 +  HasBOM = hasUTF16ByteOrderMark("\xfe\xff ");
    EXPECT_TRUE(HasBOM); // Don't care about odd lengths.
--  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff\x00asdf", 6));
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff\x00asdf", 6));
 +  HasBOM = hasUTF16ByteOrderMark("\xfe\xff\x00asdf");
    EXPECT_TRUE(HasBOM);
  
--  HasBOM = hasUTF16ByteOrderMark(None);
+-  HasBOM = hasUTF16ByteOrderMark(std::nullopt);
 +  HasBOM = hasUTF16ByteOrderMark("");
    EXPECT_FALSE(HasBOM);
--  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe", 1));
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe", 1));
 +  HasBOM = hasUTF16ByteOrderMark("\xfe");
    EXPECT_FALSE(HasBOM);
  }
@@ -1833,12 +1951,12 @@
  TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
    // Src is the look of disapproval.
    alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
--  ArrayRef<UTF16> SrcRef = makeArrayRef((const UTF16 *)Src, 4);
+-  ArrayRef<UTF16> SrcRef = ArrayRef((const UTF16 *)Src, 4);
 +  span<const UTF16> SrcRef((const UTF16 *)Src, 4);
    std::string Result;
    bool Success = convertUTF16ToUTF8String(SrcRef, Result);
    EXPECT_TRUE(Success);
-@@ -98,7 +97,7 @@ TEST(ConvertUTFTest, ConvertUTF8toWide) {
+@@ -123,7 +122,7 @@ TEST(ConvertUTFTest, ConvertUTF8toWide) {
    std::wstring Expected(L"\x0ca0_\x0ca0");
    EXPECT_EQ(Expected, Result);
    Result.clear();
@@ -1847,7 +1965,7 @@
    EXPECT_TRUE(Success);
    EXPECT_EQ(Expected, Result);
  }
-@@ -147,7 +146,7 @@ struct ConvertUTFResultContainer {
+@@ -172,7 +171,7 @@ struct ConvertUTFResultContainer {
  };
  
  std::pair<ConversionResult, std::vector<unsigned>>
@@ -1856,7 +1974,7 @@
    const UTF8 *SourceStart = reinterpret_cast<const UTF8 *>(S.data());
  
    const UTF8 *SourceNext = SourceStart;
-@@ -164,7 +163,7 @@ ConvertUTF8ToUnicodeScalarsLenient(StringRef S) {
+@@ -189,7 +188,7 @@ ConvertUTF8ToUnicodeScalarsLenient(StringRef S) {
  }
  
  std::pair<ConversionResult, std::vector<unsigned>>
@@ -1865,7 +1983,7 @@
    const UTF8 *SourceStart = reinterpret_cast<const UTF8 *>(S.data());
  
    const UTF8 *SourceNext = SourceStart;
-@@ -182,7 +181,7 @@ ConvertUTF8ToUnicodeScalarsPartialLenient(StringRef S) {
+@@ -207,7 +206,7 @@ ConvertUTF8ToUnicodeScalarsPartialLenient(StringRef S) {
  
  ::testing::AssertionResult
  CheckConvertUTF8ToUnicodeScalars(ConvertUTFResultContainer Expected,
@@ -1874,7 +1992,7 @@
    ConversionResult ErrorCode;
    std::vector<unsigned> Decoded;
    if (!Partial)
-@@ -277,7 +276,7 @@ TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {
+@@ -302,7 +301,7 @@ TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {
    // U+0000 NULL
    EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
        ConvertUTFResultContainer(conversionOK).withScalars(0x0000),
@@ -1883,7 +2001,7 @@
  
    // U+0080 PADDING CHARACTER
    EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
-@@ -1051,7 +1050,7 @@ TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {
+@@ -1076,7 +1075,7 @@ TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {
    // U+0000 NULL
    EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
        ConvertUTFResultContainer(conversionOK).withScalars(0x0000),
@@ -1892,3 +2010,25 @@
  
    // Overlong sequences of the above.
    EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
+diff --git a/llvm/unittests/Support/xxhashTest.cpp b/llvm/unittests/Support/xxhashTest.cpp
+index 7d78de6772b5159459572fe11633c76d04b86907..d61a5acd21f4d685ca631d3adb20c2649e050bc3 100644
+--- a/llvm/unittests/Support/xxhashTest.cpp
++++ b/llvm/unittests/Support/xxhashTest.cpp
+@@ -12,7 +12,7 @@
+ using namespace llvm;
+ 
+ TEST(xxhashTest, Basic) {
+-  EXPECT_EQ(0xef46db3751d8e999U, xxHash64(StringRef()));
++  EXPECT_EQ(0xef46db3751d8e999U, xxHash64(std::string_view()));
+   EXPECT_EQ(0x33bf00a859c4ba3fU, xxHash64("foo"));
+   EXPECT_EQ(0x48a37c90ad27a659U, xxHash64("bar"));
+   EXPECT_EQ(0x69196c1b3af0bff9U,
+@@ -31,7 +31,7 @@ TEST(xxhashTest, xxh3) {
+   }
+ 
+ #define F(len, expected)                                                       \
+-  EXPECT_EQ(uint64_t(expected), xxh3_64bits(ArrayRef(a, size_t(len))))
++  EXPECT_EQ(uint64_t(expected), xxh3_64bits(span(a, size_t(len))))
+   F(0, 0x2d06800538d394c2);
+   F(1, 0xd0d496e05c553485);
+   F(2, 0x84d625edb7055eac);
diff --git a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch
similarity index 61%
rename from upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch
rename to upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch
index a67e326..fe5c48e 100644
--- a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch
+++ b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch
@@ -1,21 +1,20 @@
-From 5fccde024bea117d90d215390f09c7d779195ea5 Mon Sep 17 00:00:00 2001
+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 03/28] Wrap std::min/max calls in parens, for Windows warnings
+Subject: [PATCH 02/31] 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/Support/ConvertUTF.h |  2 +-
- llvm/include/llvm/Support/MathExtras.h | 22 +++++++++++-----------
- llvm/lib/Support/SmallVector.cpp       |  2 +-
- 5 files changed, 21 insertions(+), 21 deletions(-)
+ llvm/include/llvm/Support/MathExtras.h | 18 +++++++++---------
+ 4 files changed, 18 insertions(+), 18 deletions(-)
 
 diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
-index 7673b66ca..975c3b97e 100644
+index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004be6facafb 100644
 --- a/llvm/include/llvm/ADT/DenseMap.h
 +++ b/llvm/include/llvm/ADT/DenseMap.h
-@@ -390,7 +390,7 @@ protected:
+@@ -416,7 +416,7 @@ protected:
        return 0;
      // +1 is required because of the strict equality.
      // For example if NumEntries is 48, we need to return 401.
@@ -24,7 +23,7 @@
    }
  
    void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) {
-@@ -826,7 +826,7 @@ public:
+@@ -852,7 +852,7 @@ public:
      // Reduce the number of buckets.
      unsigned NewNumBuckets = 0;
      if (OldNumEntries)
@@ -34,10 +33,10 @@
        this->BaseT::initEmpty();
        return;
 diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
-index a4a790323..8686f7bb5 100644
+index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0489e14c9 100644
 --- a/llvm/include/llvm/ADT/SmallVector.h
 +++ b/llvm/include/llvm/ADT/SmallVector.h
-@@ -49,12 +49,12 @@ protected:
+@@ -55,12 +55,12 @@ protected:
  
    /// The maximum value of the Size_T used.
    static constexpr size_t SizeTypeMax() {
@@ -52,7 +51,7 @@
  
    /// 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
-@@ -79,7 +79,7 @@ protected:
+@@ -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());
@@ -61,7 +60,7 @@
    }
  };
  
-@@ -259,7 +259,7 @@ public:
+@@ -279,7 +279,7 @@ public:
  
    size_type size_in_bytes() const { return size() * sizeof(T); }
    size_type max_size() const {
@@ -70,7 +69,7 @@
    }
  
    size_t capacity_in_bytes() const { return capacity() * sizeof(T); }
-@@ -444,7 +444,7 @@ void SmallVectorTemplateBase<T, TriviallyCopyable>::takeAllocationForGrow(
+@@ -467,7 +467,7 @@ void SmallVectorTemplateBase<T, TriviallyCopyable>::takeAllocationForGrow(
      free(this->begin());
  
    this->BeginX = NewElts;
@@ -79,7 +78,7 @@
  }
  
  /// SmallVectorTemplateBase<TriviallyCopyable = true> - This is where we put
-@@ -693,7 +693,7 @@ public:
+@@ -712,7 +712,7 @@ public:
      }
  
      // Assign over existing elements.
@@ -89,10 +88,10 @@
        std::uninitialized_fill_n(this->end(), NumElts - this->size(), Elt);
      else if (NumElts < this->size())
 diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h
-index 7f1527f51..b085c8a17 100644
+index 5c0e3009c25446a34882fb98329b1d955231bb39..72321022beb373945f7935ed72944fd68eb7d02f 100644
 --- a/llvm/include/llvm/Support/ConvertUTF.h
 +++ b/llvm/include/llvm/Support/ConvertUTF.h
-@@ -112,7 +112,7 @@ namespace llvm {
+@@ -127,7 +127,7 @@ namespace llvm {
  typedef unsigned int    UTF32;  /* at least 32 bits */
  typedef unsigned short  UTF16;  /* at least 16 bits */
  typedef unsigned char   UTF8;   /* typically 8 bits */
@@ -102,68 +101,41 @@
  /* 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 753b1998c..db9fbc148 100644
+index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf366215068b62f527 100644
 --- a/llvm/include/llvm/Support/MathExtras.h
 +++ b/llvm/include/llvm/Support/MathExtras.h
-@@ -97,7 +97,7 @@ template <typename T, std::size_t SizeOfT> struct TrailingZerosCounter {
-     // Bisection method.
-     unsigned ZeroBits = 0;
-     T Shift = std::numeric_limits<T>::digits >> 1;
--    T Mask = std::numeric_limits<T>::max() >> Shift;
-+    T Mask = (std::numeric_limits<T>::max)() >> Shift;
-     while (Shift) {
-       if ((Val & Mask) == 0) {
-         Val >>= Shift;
-@@ -238,7 +238,7 @@ unsigned countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
- ///   valid arguments.
- template <typename T> T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
-   if (ZB == ZB_Max && Val == 0)
--    return std::numeric_limits<T>::max();
-+    return (std::numeric_limits<T>::max)();
- 
-   return countTrailingZeros(Val, ZB_Undefined);
- }
-@@ -279,7 +279,7 @@ template <typename T> T maskLeadingZeros(unsigned N) {
- ///   valid arguments.
- template <typename T> T findLastSet(T Val, ZeroBehavior ZB = ZB_Max) {
-   if (ZB == ZB_Max && Val == 0)
--    return std::numeric_limits<T>::max();
-+    return (std::numeric_limits<T>::max)();
- 
-   // Use ^ instead of - because both gcc and llvm can remove the associated ^
-   // in the __builtin_clz intrinsic on x86.
-@@ -594,26 +594,26 @@ inline double Log2(double Value) {
+@@ -311,26 +311,26 @@ template <> constexpr inline 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) {
--  return 31 - countLeadingZeros(Value);
-+  return static_cast<unsigned>(31 - countLeadingZeros(Value));
+-  return 31 - llvm::countl_zero(Value);
++  return static_cast<unsigned>(31 - llvm::countl_zero(Value));
  }
  
  /// Return the floor log base 2 of the specified value, -1 if the value is zero.
  /// (64 bit edition.)
  inline unsigned Log2_64(uint64_t Value) {
--  return 63 - countLeadingZeros(Value);
-+  return static_cast<unsigned>(63 - countLeadingZeros(Value));
+-  return 63 - llvm::countl_zero(Value);
++  return static_cast<unsigned>(63 - llvm::countl_zero(Value));
  }
  
  /// Return the ceil log base 2 of the specified value, 32 if the value is zero.
  /// (32 bit edition).
  /// Ex. Log2_32_Ceil(32) == 5, Log2_32_Ceil(1) == 0, Log2_32_Ceil(6) == 3
  inline unsigned Log2_32_Ceil(uint32_t Value) {
--  return 32 - countLeadingZeros(Value - 1);
-+  return static_cast<unsigned>(32 - countLeadingZeros(Value - 1));
+-  return 32 - llvm::countl_zero(Value - 1);
++  return static_cast<unsigned>(32 - llvm::countl_zero(Value - 1));
  }
  
  /// Return the ceil log base 2 of the specified value, 64 if the value is zero.
  /// (64 bit edition.)
  inline unsigned Log2_64_Ceil(uint64_t Value) {
--  return 64 - countLeadingZeros(Value - 1);
-+  return static_cast<unsigned>(64 - countLeadingZeros(Value - 1));
+-  return 64 - llvm::countl_zero(Value - 1);
++  return static_cast<unsigned>(64 - llvm::countl_zero(Value - 1));
  }
  
- /// Return the greatest common divisor of the values using Euclid's algorithm.
-@@ -807,7 +807,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
+ /// 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) {
    T Z = X + Y;
    Overflowed = (Z < X || Z < Y);
    if (Overflowed)
@@ -172,7 +144,16 @@
    else
      return Z;
  }
-@@ -832,7 +832,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
+@@ -492,7 +492,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)
+-    return SaturatingAdd(std::numeric_limits<T>::max(), T(1), Args...);
++    return SaturatingAdd((std::numeric_limits<T>::max)(), T(1), Args...);
+   return SaturatingAdd(XY, Z, Args...);
+ }
+ 
+@@ -516,7 +516,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);
@@ -181,7 +162,7 @@
    int Log2Max = Log2_64(Max);
    if (Log2Z < Log2Max) {
      return X * Y;
-@@ -952,9 +952,9 @@ std::enable_if_t<std::is_signed<T>::value, T> MulOverflow(T X, T Y, T &Result) {
+@@ -636,9 +636,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)
@@ -193,16 +174,3 @@
  }
  
  } // End llvm namespace
-diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
-index 8bad715e4..a2b4899e1 100644
---- a/llvm/lib/Support/SmallVector.cpp
-+++ b/llvm/lib/Support/SmallVector.cpp
-@@ -104,7 +104,7 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
-   // In theory 2*capacity can overflow if the capacity is 64 bit, but the
-   // original capacity would never be large enough for this to be a problem.
-   size_t NewCapacity = 2 * OldCapacity + 1; // Always grow.
--  return std::min(std::max(NewCapacity, MinSize), MaxSize);
-+  return (std::min)((std::max)(NewCapacity, MinSize), MaxSize);
- }
- 
- // Note: Moving this function into the header may cause performance regression.
diff --git a/upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch
similarity index 75%
rename from upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch
rename to upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch
index 6e57262..c4e5176 100644
--- a/upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch
+++ b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch
@@ -1,17 +1,17 @@
-From 376285281b6173ee3d6650d71148bc173e4a9f7a Mon Sep 17 00:00:00 2001
+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 04/28] Change unique_function storage size
+Subject: [PATCH 03/31] 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 5a37417dd..8a9d78f41 100644
+index 4cf1de488c7bde2692d4878ccb4c4d60241e3a66..9d10b16e3cbe9c0df818a3254fcd3a6032d54b39 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<llvm::disjunction<
+@@ -78,7 +78,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<
  
  template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
  protected:
@@ -28,4 +28,4 @@
 +    // 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
+     mutable std::aligned_storage_t<InlineStorageSize, alignof(void *)>
diff --git a/upstream_utils/llvm_patches/0005-Threading-updates.patch b/upstream_utils/llvm_patches/0004-Threading-updates.patch
similarity index 88%
rename from upstream_utils/llvm_patches/0005-Threading-updates.patch
rename to upstream_utils/llvm_patches/0004-Threading-updates.patch
index 1ccd217..98c1d8a 100644
--- a/upstream_utils/llvm_patches/0005-Threading-updates.patch
+++ b/upstream_utils/llvm_patches/0004-Threading-updates.patch
@@ -1,7 +1,7 @@
-From bc86b62f72cbb76a0911996f4b1c6ce476cd1fac Mon Sep 17 00:00:00 2001
+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 05/28] Threading updates
+Subject: [PATCH 04/31] Threading updates
 
 - Remove guards for threads and exception
 - Prefer scope gaurd over lock gaurd
@@ -12,10 +12,10 @@
  3 files changed, 11 insertions(+), 43 deletions(-)
 
 diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
-index f5d726ec8..ede1cb172 100644
+index 92376629c607461061bc60597a47aed1e535af52..2662839b27bf368cd5da0668099c4b44cbc6435d 100644
 --- a/llvm/include/llvm/Support/Compiler.h
 +++ b/llvm/include/llvm/Support/Compiler.h
-@@ -540,7 +540,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
+@@ -530,7 +530,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.
@@ -23,7 +23,7 @@
  #if __has_feature(cxx_thread_local) || defined(_MSC_VER)
  #define LLVM_THREAD_LOCAL thread_local
  #else
-@@ -548,11 +547,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
+@@ -538,11 +537,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
  // we only need the restricted functionality that provides.
  #define LLVM_THREAD_LOCAL __thread
  #endif
@@ -36,7 +36,7 @@
  /// \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 8ae8fb8b4..89440b5ab 100644
+index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb8ba1276e 100644
 --- a/llvm/lib/Support/ErrorHandling.cpp
 +++ b/llvm/lib/Support/ErrorHandling.cpp
 @@ -44,7 +44,6 @@ static void *ErrorHandlerUserData = nullptr;
@@ -83,7 +83,7 @@
      handler = ErrorHandler;
      handlerData = ErrorHandlerUserData;
    }
-@@ -123,18 +115,14 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
+@@ -126,18 +118,14 @@ 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) {
@@ -104,7 +104,7 @@
    BadAllocErrorHandler = nullptr;
    BadAllocErrorHandlerUserData = nullptr;
  }
-@@ -145,9 +133,7 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
+@@ -148,9 +136,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.
@@ -115,7 +115,7 @@
      Handler = BadAllocErrorHandler;
      HandlerData = BadAllocErrorHandlerUserData;
    }
-@@ -157,10 +143,6 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
+@@ -160,10 +146,6 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
      llvm_unreachable("bad alloc handler should not return");
    }
  
@@ -126,7 +126,7 @@
    // 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";
-@@ -169,15 +151,8 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
+@@ -172,15 +154,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();
@@ -142,7 +142,7 @@
  // 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() {
-@@ -192,7 +167,6 @@ void llvm::install_out_of_memory_new_handler() {
+@@ -195,7 +170,6 @@ void llvm::install_out_of_memory_new_handler() {
    assert((old == nullptr || old == out_of_memory_new_handler) &&
           "new-handler already installed");
  }
@@ -151,7 +151,7 @@
  void llvm::llvm_unreachable_internal(const char *msg, const char *file,
                                       unsigned line) {
 diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp
-index a6ae67066..fc798b7ec 100644
+index a6ae67066ea0423334e8ee52106f220cd456e25e..fc798b7ec1b788e232c7374b9968dc71d4f506f0 100644
 --- a/llvm/lib/Support/ManagedStatic.cpp
 +++ b/llvm/lib/Support/ManagedStatic.cpp
 @@ -12,23 +12,23 @@
diff --git a/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch
similarity index 76%
rename from upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch
rename to upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch
index bcb4950..e74cf17 100644
--- a/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch
+++ b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch
@@ -1,18 +1,18 @@
-From 008e921f77933f475174d74a6b70309c6fbe0771 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sat, 7 May 2022 22:28:13 -0400
-Subject: [PATCH 06/28] \#ifdef guard safety
+Subject: [PATCH 05/31] \#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 | 50 ++++++++++++++++++++++++++++
- 1 file changed, 50 insertions(+)
+ 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 ede1cb172..8b8260b50 100644
+index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e848519998685b 100644
 --- a/llvm/include/llvm/Support/Compiler.h
 +++ b/llvm/include/llvm/Support/Compiler.h
-@@ -86,6 +86,7 @@
+@@ -90,6 +90,7 @@
  /// * 1928: VS2019, version 16.8 + 16.9
  /// * 1929: VS2019, version 16.10 + 16.11
  /// * 1930: VS2022, version 17.0
@@ -20,29 +20,15 @@
  #ifdef _MSC_VER
  #define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version))
  
-@@ -99,6 +100,7 @@
+@@ -103,6 +104,7 @@
  #else
  #define LLVM_MSC_PREREQ(version) 0
  #endif
 +#endif
  
- /// Does the compiler support ref-qualifiers for *this?
- ///
-@@ -112,11 +114,13 @@
- ///
- /// This can be used to provide lvalue/rvalue overrides of member functions.
- /// The rvalue override should be guarded by LLVM_HAS_RVALUE_REFERENCE_THIS
-+#ifndef LLVM_LVALUE_FUNCTION
- #if LLVM_HAS_RVALUE_REFERENCE_THIS
- #define LLVM_LVALUE_FUNCTION &
- #else
- #define LLVM_LVALUE_FUNCTION
- #endif
-+#endif
- 
  /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
  /// into a shared library, then the class should be private to the library and
-@@ -140,21 +144,26 @@
+@@ -139,17 +141,21 @@
  #define LLVM_EXTERNAL_VISIBILITY
  #endif
  
@@ -62,22 +48,9 @@
  #endif
 +#endif
  
- /// LLVM_NODISCARD - Warn if a type or return value is discarded.
- 
- // Use the 'nodiscard' attribute in C++17 or newer mode.
-+#ifndef LLVM_NODISCARD
- #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
- #define LLVM_NODISCARD [[nodiscard]]
- #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result)
-@@ -168,6 +177,7 @@
- #else
- #define LLVM_NODISCARD
- #endif
-+#endif
- 
- // Indicate that a non-static, non-const C++ member function reinitializes
- // the entire object to a known state, independent of the previous state of
-@@ -190,11 +200,13 @@
+ #if defined(__clang__)
+ #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
+@@ -178,11 +184,13 @@
  // more portable solution:
  //   (void)unused_var_name;
  // Prefer cast-to-void wherever it is sufficient.
@@ -91,7 +64,7 @@
  
  // FIXME: Provide this for PE/COFF targets.
  #if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) &&  \
-@@ -204,6 +216,7 @@
+@@ -192,6 +200,7 @@
  #define LLVM_ATTRIBUTE_WEAK
  #endif
  
@@ -99,7 +72,7 @@
  // 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__)
-@@ -212,13 +225,16 @@
+@@ -200,13 +209,16 @@
  #else
  #define LLVM_READNONE
  #endif
@@ -116,7 +89,7 @@
  
  #if __has_attribute(minsize)
  #define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize))
-@@ -226,6 +242,7 @@
+@@ -214,6 +226,7 @@
  #define LLVM_ATTRIBUTE_MINSIZE
  #endif
  
@@ -124,7 +97,7 @@
  #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)
-@@ -233,9 +250,11 @@
+@@ -221,9 +234,11 @@
  #define LLVM_LIKELY(EXPR) (EXPR)
  #define LLVM_UNLIKELY(EXPR) (EXPR)
  #endif
@@ -136,7 +109,7 @@
  #if __has_attribute(noinline)
  #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline))
  #elif defined(_MSC_VER)
-@@ -243,9 +262,11 @@
+@@ -231,9 +246,11 @@
  #else
  #define LLVM_ATTRIBUTE_NOINLINE
  #endif
@@ -148,7 +121,7 @@
  #if __has_attribute(always_inline)
  #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline))
  #elif defined(_MSC_VER)
-@@ -253,6 +274,7 @@
+@@ -241,6 +258,7 @@
  #else
  #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
  #endif
@@ -156,7 +129,7 @@
  
  /// 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
-@@ -263,6 +285,7 @@
+@@ -251,6 +269,7 @@
  #define LLVM_ATTRIBUTE_NODEBUG
  #endif
  
@@ -164,7 +137,7 @@
  #if __has_attribute(returns_nonnull)
  #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
  #elif defined(_MSC_VER)
-@@ -270,9 +293,11 @@
+@@ -258,9 +277,11 @@
  #else
  #define LLVM_ATTRIBUTE_RETURNS_NONNULL
  #endif
@@ -176,7 +149,7 @@
  #ifdef __GNUC__
  #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
  #elif defined(_MSC_VER)
-@@ -280,8 +305,10 @@
+@@ -268,8 +289,10 @@
  #else
  #define LLVM_ATTRIBUTE_RETURNS_NOALIAS
  #endif
@@ -187,7 +160,7 @@
  #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
  #define LLVM_FALLTHROUGH [[fallthrough]]
  #elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
-@@ -293,6 +320,7 @@
+@@ -281,6 +304,7 @@
  #else
  #define LLVM_FALLTHROUGH
  #endif
@@ -195,7 +168,7 @@
  
  /// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that
  /// they are constant initialized.
-@@ -321,20 +349,25 @@
+@@ -309,11 +333,13 @@
  
  /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
  /// pedantic diagnostics.
@@ -207,23 +180,17 @@
  #endif
 +#endif
  
- // LLVM_ATTRIBUTE_DEPRECATED(decl, "message")
- // This macro will be removed.
- // Use C++14's attribute instead: [[deprecated("message")]]
-+#ifndef LLVM_ATTRIBUTE_DEPRECATED
- #define LLVM_ATTRIBUTE_DEPRECATED(decl, message) [[deprecated(message)]] decl
-+#endif
- 
  /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
  /// to an expression which states that it is undefined behavior for the
- /// compiler to reach this point.  Otherwise is not defined.
+@@ -322,14 +348,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.
 +#ifndef LLVM_BUILTIN_UNREACHABLE
  #if __has_builtin(__builtin_unreachable) || defined(__GNUC__)
  # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
  #elif defined(_MSC_VER)
-@@ -342,9 +375,11 @@
- #else
- # define LLVM_BUILTIN_UNREACHABLE
+ # define LLVM_BUILTIN_UNREACHABLE __assume(false)
  #endif
 +#endif
  
@@ -233,7 +200,7 @@
  #if __has_builtin(__builtin_trap) || defined(__GNUC__)
  # define LLVM_BUILTIN_TRAP __builtin_trap()
  #elif defined(_MSC_VER)
-@@ -356,10 +391,12 @@
+@@ -341,10 +370,12 @@
  #else
  # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
  #endif
@@ -246,7 +213,7 @@
  #if __has_builtin(__builtin_debugtrap)
  # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
  #elif defined(_MSC_VER)
-@@ -373,9 +410,11 @@
+@@ -358,9 +389,11 @@
  // program to abort if encountered.
  # define LLVM_BUILTIN_DEBUGTRAP
  #endif
@@ -258,7 +225,7 @@
  #if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__)
  # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
  #elif defined(LLVM_BUILTIN_UNREACHABLE)
-@@ -384,6 +423,7 @@
+@@ -369,6 +402,7 @@
  #else
  # define LLVM_ASSUME_ALIGNED(p, a) (p)
  #endif
@@ -266,7 +233,7 @@
  
  /// \macro LLVM_PACKED
  /// Used to specify a packed structure.
-@@ -403,6 +443,7 @@
+@@ -388,6 +422,7 @@
  ///   long long l;
  /// };
  /// LLVM_PACKED_END
@@ -274,29 +241,15 @@
  #ifdef _MSC_VER
  # define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
  # define LLVM_PACKED_START __pragma(pack(push, 1))
-@@ -412,11 +453,13 @@
+@@ -397,6 +432,7 @@
  # define LLVM_PACKED_START _Pragma("pack(push, 1)")
  # define LLVM_PACKED_END   _Pragma("pack(pop)")
  #endif
 +#endif
  
- /// \macro LLVM_PTR_SIZE
- /// A constant integer equivalent to the value of sizeof(void*).
- /// Generally used in combination with alignas or when doing computation in the
- /// preprocessor.
-+#ifndef LLVM_PTR_SIZE
- #ifdef __SIZEOF_POINTER__
- # define LLVM_PTR_SIZE __SIZEOF_POINTER__
- #elif defined(_WIN64)
-@@ -428,6 +471,7 @@
- #else
- # define LLVM_PTR_SIZE sizeof(void *)
- #endif
-+#endif
- 
  /// \macro LLVM_MEMORY_SANITIZER_BUILD
  /// Whether LLVM itself is built with MemorySanitizer instrumentation.
-@@ -498,11 +542,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
+@@ -488,11 +524,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
  
  /// \macro LLVM_NO_SANITIZE
  /// Disable a particular sanitizer for a function.
@@ -310,7 +263,7 @@
  
  /// Mark debug helper function definitions like dump() that should not be
  /// stripped from debug builds.
-@@ -510,17 +556,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
+@@ -500,17 +538,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.
@@ -331,7 +284,7 @@
  #if defined(_MSC_VER)
  #define LLVM_PRETTY_FUNCTION __FUNCSIG__
  #elif defined(__GNUC__) || defined(__clang__)
-@@ -528,6 +577,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
+@@ -518,6 +559,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
  #else
  #define LLVM_PRETTY_FUNCTION __func__
  #endif
diff --git a/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch b/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch
new file mode 100644
index 0000000..0d841d9
--- /dev/null
+++ b/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch
@@ -0,0 +1,115 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: PJ Reiniger <pj.reiniger@gmail.com>
+Date: Sat, 7 May 2022 22:37:34 -0400
+Subject: [PATCH 06/31] Explicitly use std::
+
+---
+ llvm/include/llvm/ADT/SmallSet.h       |  2 +-
+ llvm/lib/Support/ErrorHandling.cpp     |  2 +-
+ llvm/unittests/ADT/SmallPtrSetTest.cpp |  2 +-
+ llvm/unittests/ADT/SmallSetTest.cpp    | 10 +++++-----
+ llvm/unittests/ADT/StringMapTest.cpp   |  2 +-
+ 5 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
+index aeee5f97799aea7e7588d7afba1e47b4fa3d8c7b..4969dfb0d61c2fad805c9cb7bc0184ea6d47bf23 100644
+--- a/llvm/include/llvm/ADT/SmallSet.h
++++ b/llvm/include/llvm/ADT/SmallSet.h
+@@ -269,7 +269,7 @@ bool operator==(const SmallSet<T, LN, C> &LHS, const SmallSet<T, RN, C> &RHS) {
+     return false;
+ 
+   // All elements in LHS must also be in RHS
+-  return all_of(LHS, [&RHS](const T &E) { return RHS.count(E); });
++  return std::all_of(LHS.begin(), LHS.end(), [&RHS](const T &E) { return RHS.count(E); });
+ }
+ 
+ /// Inequality comparison for SmallSet.
+diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
+index 637b669a7d0dae69ef4b34955f21a9fb8ba1276e..0b87b375de67dc18647e3ebe646bf323dd05e8c5 100644
+--- a/llvm/lib/Support/ErrorHandling.cpp
++++ b/llvm/lib/Support/ErrorHandling.cpp
+@@ -213,7 +213,7 @@ void LLVMResetFatalErrorHandler() {
+ // I'd rather not double the line count of the following.
+ #define MAP_ERR_TO_COND(x, y)                                                  \
+   case x:                                                                      \
+-    return make_error_code(errc::y)
++    return std::make_error_code(std::errc::y)
+ 
+ std::error_code llvm::mapWindowsError(unsigned EV) {
+   switch (EV) {
+diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
+index 7ed8670fd31ea2a14e6ba7f59a8ac8e35046890c..531f81ab5b3fc1dcff731230f3cb7649cb90aedf 100644
+--- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
++++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
+@@ -298,7 +298,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) {
+ 
+   // Sort.  We should hit the first element just once and the final element N
+   // times.
+-  llvm::sort(Found);
++  std::sort(std::begin(Found), std::end(Found));
+   for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F)
+     EXPECT_EQ(F - Found + 1, *F);
+ }
+diff --git a/llvm/unittests/ADT/SmallSetTest.cpp b/llvm/unittests/ADT/SmallSetTest.cpp
+index b50b368ae663614f050c220432c05b32c201db00..f9d84fa8a42a7feaaffa3aa080e84574dc3671b3 100644
+--- a/llvm/unittests/ADT/SmallSetTest.cpp
++++ b/llvm/unittests/ADT/SmallSetTest.cpp
+@@ -11,8 +11,8 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/ADT/SmallSet.h"
+-#include "llvm/ADT/STLExtras.h"
+ #include "gtest/gtest.h"
++#include <algorithm>
+ #include <string>
+ 
+ using namespace llvm;
+@@ -94,7 +94,7 @@ TEST(SmallSetTest, IteratorInt) {
+ 
+   std::vector<int> V(s1.begin(), s1.end());
+   // Make sure the elements are in the expected order.
+-  llvm::sort(V);
++  std::sort(V.begin(), V.end());
+   for (int i = 0; i < 3; i++)
+     EXPECT_EQ(i, V[i]);
+ 
+@@ -105,7 +105,7 @@ TEST(SmallSetTest, IteratorInt) {
+ 
+   V.assign(s1.begin(), s1.end());
+   // Make sure the elements are in the expected order.
+-  llvm::sort(V);
++  std::sort(V.begin(), V.end());
+   for (int i = 0; i < 6; i++)
+     EXPECT_EQ(i, V[i]);
+ }
+@@ -120,7 +120,7 @@ TEST(SmallSetTest, IteratorString) {
+   s1.insert("str 1");
+ 
+   std::vector<std::string> V(s1.begin(), s1.end());
+-  llvm::sort(V);
++  std::sort(V.begin(), V.end());
+   EXPECT_EQ(2u, s1.size());
+   EXPECT_EQ("str 1", V[0]);
+   EXPECT_EQ("str 2", V[1]);
+@@ -131,7 +131,7 @@ TEST(SmallSetTest, IteratorString) {
+ 
+   V.assign(s1.begin(), s1.end());
+   // Make sure the elements are in the expected order.
+-  llvm::sort(V);
++  std::sort(V.begin(), V.end());
+   EXPECT_EQ(4u, s1.size());
+   EXPECT_EQ("str 0", V[0]);
+   EXPECT_EQ("str 1", V[1]);
+diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
+index 7f10b3d7d3a8894b1ab0ac660268d94a8b89e082..acd8b566f9c7a6efc2c9204624c01104dd34daf6 100644
+--- a/llvm/unittests/ADT/StringMapTest.cpp
++++ b/llvm/unittests/ADT/StringMapTest.cpp
+@@ -343,7 +343,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) {
+   Map["D"] = 3;
+ 
+   auto Keys = to_vector<4>(Map.keys());
+-  llvm::sort(Keys);
++  std::sort(Keys.begin(), Keys.end());
+ 
+   SmallVector<std::string_view, 4> Expected = {"A", "B", "C", "D"};
+   EXPECT_EQ(Expected, Keys);
diff --git a/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch b/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch
deleted file mode 100644
index cfbe9a1..0000000
--- a/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-From c26562caae6a685716a8785ad8689833c9996549 Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Sat, 7 May 2022 22:37:34 -0400
-Subject: [PATCH 07/28] Explicitly use std::
-
----
- llvm/include/llvm/ADT/SmallSet.h       | 2 +-
- llvm/include/llvm/Support/MathExtras.h | 2 +-
- llvm/lib/Support/ErrorHandling.cpp     | 2 +-
- llvm/unittests/ADT/SmallPtrSetTest.cpp | 2 +-
- llvm/unittests/ADT/StringMapTest.cpp   | 2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
-index bfe93e997..403e108fd 100644
---- a/llvm/include/llvm/ADT/SmallSet.h
-+++ b/llvm/include/llvm/ADT/SmallSet.h
-@@ -270,7 +270,7 @@ bool operator==(const SmallSet<T, LN, C> &LHS, const SmallSet<T, RN, C> &RHS) {
-     return false;
- 
-   // All elements in LHS must also be in RHS
--  return all_of(LHS, [&RHS](const T &E) { return RHS.count(E); });
-+  return std::all_of(LHS.begin(), LHS.end(), [&RHS](const T &E) { return RHS.count(E); });
- }
- 
- /// Inequality comparison for SmallSet.
-diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
-index db9fbc148..da843ef79 100644
---- a/llvm/include/llvm/Support/MathExtras.h
-+++ b/llvm/include/llvm/Support/MathExtras.h
-@@ -586,7 +586,7 @@ inline double Log2(double Value) {
- #if defined(__ANDROID_API__) && __ANDROID_API__ < 18
-   return __builtin_log(Value) / __builtin_log(2.0);
- #else
--  return log2(Value);
-+  return std::log2(Value);
- #endif
- }
- 
-diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
-index 89440b5ab..f80e28e87 100644
---- a/llvm/lib/Support/ErrorHandling.cpp
-+++ b/llvm/lib/Support/ErrorHandling.cpp
-@@ -210,7 +210,7 @@ void LLVMResetFatalErrorHandler() {
- // I'd rather not double the line count of the following.
- #define MAP_ERR_TO_COND(x, y)                                                  \
-   case x:                                                                      \
--    return make_error_code(errc::y)
-+    return std::make_error_code(std::errc::y)
- 
- std::error_code llvm::mapWindowsError(unsigned EV) {
-   switch (EV) {
-diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
-index 6f3c94eed..531f81ab5 100644
---- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
-+++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
-@@ -298,7 +298,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) {
- 
-   // Sort.  We should hit the first element just once and the final element N
-   // times.
--  llvm::sort(std::begin(Found), std::end(Found));
-+  std::sort(std::begin(Found), std::end(Found));
-   for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F)
-     EXPECT_EQ(F - Found + 1, *F);
- }
-diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
-index 86907ab61..6d0c0942c 100644
---- a/llvm/unittests/ADT/StringMapTest.cpp
-+++ b/llvm/unittests/ADT/StringMapTest.cpp
-@@ -329,7 +329,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) {
-   Map["D"] = 3;
- 
-   auto Keys = to_vector<4>(Map.keys());
--  llvm::sort(Keys);
-+  std::sort(Keys.begin(), Keys.end());
- 
-   SmallVector<std::string_view, 4> Expected = {"A", "B", "C", "D"};
-   EXPECT_EQ(Expected, Keys);
diff --git a/upstream_utils/llvm_patches/0008-Remove-format_provider.patch b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch
similarity index 89%
rename from upstream_utils/llvm_patches/0008-Remove-format_provider.patch
rename to upstream_utils/llvm_patches/0007-Remove-format_provider.patch
index 1e43a8b..6495bb9 100644
--- a/upstream_utils/llvm_patches/0008-Remove-format_provider.patch
+++ b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch
@@ -1,16 +1,16 @@
-From f35fcb2c40caceed14437e65131e9fe1cf94deac Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sat, 7 May 2022 22:53:50 -0400
-Subject: [PATCH 08/28] Remove format_provider
+Subject: [PATCH 07/31] Remove format_provider
 
 ---
  llvm/include/llvm/Support/Chrono.h      | 109 ------------------------
  llvm/include/llvm/Support/raw_ostream.h |   6 --
- llvm/unittests/Support/Chrono.cpp       |  61 -------------
- 3 files changed, 176 deletions(-)
+ llvm/unittests/Support/Chrono.cpp       |  67 ---------------
+ 3 files changed, 182 deletions(-)
 
 diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h
-index a7dea19d9..9f9a2b5ca 100644
+index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7cf77eb564 100644
 --- a/llvm/include/llvm/Support/Chrono.h
 +++ b/llvm/include/llvm/Support/Chrono.h
 @@ -10,7 +10,6 @@
@@ -137,10 +137,10 @@
  
  #endif // LLVM_SUPPORT_CHRONO_H
 diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
-index 9a1dd7a60..a25ca5b7b 100644
+index 2463f1af612a78cafafe3c0e16d496e607cdc322..5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5 100644
 --- a/llvm/include/llvm/Support/raw_ostream.h
 +++ b/llvm/include/llvm/Support/raw_ostream.h
-@@ -28,12 +28,6 @@
+@@ -27,12 +27,6 @@
  
  namespace llvm {
  
@@ -150,14 +150,14 @@
 -class FormattedString;
 -class FormattedNumber;
 -class FormattedBytes;
- template <class T> class LLVM_NODISCARD Expected;
+ template <class T> class [[nodiscard]] Expected;
  
  namespace sys {
 diff --git a/llvm/unittests/Support/Chrono.cpp b/llvm/unittests/Support/Chrono.cpp
-index 9a08a5c1b..3c049de18 100644
+index daf8a8a350f08c748ba05af44f43f3faca8e2c61..3c049de18c0a80465f4b0a8c054df2602d5e9b1c 100644
 --- a/llvm/unittests/Support/Chrono.cpp
 +++ b/llvm/unittests/Support/Chrono.cpp
-@@ -30,37 +30,6 @@ TEST(Chrono, TimeTConversion) {
+@@ -30,43 +30,6 @@ TEST(Chrono, TimeTConversion) {
    EXPECT_EQ(TP, toTimePoint(toTimeT(TP)));
  }
  
@@ -173,15 +173,21 @@
 -  TM.tm_isdst = -1;
 -  TimePoint<> T =
 -      system_clock::from_time_t(mktime(&TM)) + nanoseconds(123456789);
+-  TimePoint<> T2 =
+-      system_clock::from_time_t(mktime(&TM)) + nanoseconds(23456789);
 -
 -  // operator<< uses the format YYYY-MM-DD HH:MM:SS.NNNNNNNNN
 -  std::string S;
 -  raw_string_ostream OS(S);
 -  OS << T;
 -  EXPECT_EQ("2006-01-02 15:04:05.123456789", OS.str());
+-  S.clear();
+-  OS << T2;
+-  EXPECT_EQ("2006-01-02 15:04:05.023456789", OS.str());
 -
 -  // formatv default style matches operator<<.
 -  EXPECT_EQ("2006-01-02 15:04:05.123456789", formatv("{0}", T).str());
+-  EXPECT_EQ("2006-01-02 15:04:05.023456789", formatv("{0}", T2).str());
 -  // formatv supports strftime-style format strings.
 -  EXPECT_EQ("15:04:05", formatv("{0:%H:%M:%S}", T).str());
 -  // formatv supports our strftime extensions for sub-second precision.
@@ -195,7 +201,7 @@
  // Test that toTimePoint and toTimeT can be called with a arguments with varying
  // precisions.
  TEST(Chrono, ImplicitConversions) {
-@@ -78,34 +47,4 @@ TEST(Chrono, ImplicitConversions) {
+@@ -84,34 +47,4 @@ TEST(Chrono, ImplicitConversions) {
    EXPECT_EQ(TimeT, toTimeT(Nano));
  }
  
diff --git a/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch
similarity index 82%
rename from upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch
rename to upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch
index 2255dd1..15442f1 100644
--- a/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch
+++ b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch
@@ -1,7 +1,7 @@
-From 2c53d8ac36f378fda347f36ef2bc7fbc2038cb93 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 13:34:07 -0400
-Subject: [PATCH 09/28] Add compiler warning pragmas
+Subject: [PATCH 08/31] Add compiler warning pragmas
 
 ---
  llvm/include/llvm/ADT/FunctionExtras.h | 11 +++++++++++
@@ -17,7 +17,7 @@
  10 files changed, 72 insertions(+), 4 deletions(-)
 
 diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
-index 8a9d78f41..3efa73587 100644
+index 9d10b16e3cbe9c0df818a3254fcd3a6032d54b39..1daeae915eb506b32a2d1296d2f0fe4e6dab606e 100644
 --- a/llvm/include/llvm/ADT/FunctionExtras.h
 +++ b/llvm/include/llvm/ADT/FunctionExtras.h
 @@ -55,6 +55,13 @@ namespace llvm {
@@ -34,7 +34,7 @@
  namespace detail {
  
  template <typename T>
-@@ -411,6 +418,10 @@ public:
+@@ -409,6 +416,10 @@ public:
    }
  };
  
@@ -46,10 +46,10 @@
  
  #endif // LLVM_ADT_FUNCTIONEXTRAS_H
 diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
-index 74a87a3d8..47ff1b2bc 100644
+index ef983105c7bae67bb2ef832e4473939a0406e0df..781bdb7416392e3f60a1ac3a38fbcf5324b5395f 100644
 --- a/llvm/include/llvm/ADT/Hashing.h
 +++ b/llvm/include/llvm/ADT/Hashing.h
-@@ -55,6 +55,11 @@
+@@ -56,6 +56,11 @@
  #include <tuple>
  #include <utility>
  
@@ -61,7 +61,7 @@
  namespace llvm {
  template <typename T, typename Enable> struct DenseMapInfo;
  
-@@ -687,4 +692,8 @@ template <> struct DenseMapInfo<hash_code, void> {
+@@ -683,4 +688,8 @@ template <> struct DenseMapInfo<hash_code, void> {
  
  } // namespace llvm
  
@@ -71,7 +71,7 @@
 +
  #endif
 diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
-index 8686f7bb5..1e311ea56 100644
+index 84f4d0931a30f4be29549354c85cb4c0489e14c9..b42438a9b16c273f9ef5b5cce6192873c78cb964 100644
 --- a/llvm/include/llvm/ADT/SmallVector.h
 +++ b/llvm/include/llvm/ADT/SmallVector.h
 @@ -14,6 +14,14 @@
@@ -90,10 +90,10 @@
  #include "llvm/Support/type_traits.h"
  #include <algorithm>
 diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
-index da843ef79..fac12dd0e 100644
+index 0bd572d07fcbf2ff56998dbf366215068b62f527..cd5a64a746b2eb7491e9b6cf8570bdf436d94a6d 100644
 --- a/llvm/include/llvm/Support/MathExtras.h
 +++ b/llvm/include/llvm/Support/MathExtras.h
-@@ -435,6 +435,11 @@ inline uint64_t maxUIntN(uint64_t N) {
+@@ -208,6 +208,11 @@ inline uint64_t maxUIntN(uint64_t N) {
    return UINT64_MAX >> (64 - N);
  }
  
@@ -105,7 +105,7 @@
  /// Gets the minimum value for a N-bit signed integer.
  inline int64_t minIntN(int64_t N) {
    assert(N > 0 && N <= 64 && "integer width out of range");
-@@ -442,6 +447,10 @@ inline int64_t minIntN(int64_t N) {
+@@ -215,6 +220,10 @@ inline int64_t minIntN(int64_t N) {
    return UINT64_C(1) + ~(UINT64_C(1) << (N - 1));
  }
  
@@ -117,7 +117,7 @@
  inline int64_t maxIntN(int64_t N) {
    assert(N > 0 && N <= 64 && "integer width out of range");
 diff --git a/llvm/include/llvm/Support/MemAlloc.h b/llvm/include/llvm/Support/MemAlloc.h
-index d6012bd5a..01007deb8 100644
+index d6012bd5a6985d8405136039aa85931605cd8a40..01007deb89bba625b1b3ad3e703d0c16ed6f757b 100644
 --- a/llvm/include/llvm/Support/MemAlloc.h
 +++ b/llvm/include/llvm/Support/MemAlloc.h
 @@ -22,6 +22,14 @@
@@ -146,7 +146,7 @@
 +
  #endif
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index e4c318eb8..ee01a9522 100644
+index 9966a0056ae4f24a7a38346ee1c2f5d83ac20248..a23f567a37abdc199363607446f33f29e021d7ad 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
 @@ -10,6 +10,10 @@
@@ -158,10 +158,10 @@
 +#endif
 +
  #include "llvm/Support/raw_ostream.h"
- #include "llvm/ADT/STLArrayExtras.h"
  #include "llvm/ADT/StringExtras.h"
+ #include "llvm/Config/config.h"
 diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
-index e505b1907..9fe83a45d 100644
+index b710ac07461ba58faa99cedeae7f209dc0f5902b..1f232d3046292c0da940ba4bef7d50604556e4c2 100644
 --- a/llvm/unittests/ADT/DenseMapTest.cpp
 +++ b/llvm/unittests/ADT/DenseMapTest.cpp
 @@ -6,6 +6,10 @@
@@ -173,10 +173,10 @@
 +#endif
 +
  #include "llvm/ADT/DenseMap.h"
- #include "gtest/gtest.h"
- #include <map>
+ #include "llvm/ADT/DenseMapInfo.h"
+ #include "llvm/ADT/DenseMapInfoVariant.h"
 diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp
-index 552f9956b..20ebcd753 100644
+index 1a371cbfba81e8ea4b57c4077ca94c86c3db8991..62fafcaf04a67d4c67b98b8f42d837ccca245fe9 100644
 --- a/llvm/unittests/ADT/MapVectorTest.cpp
 +++ b/llvm/unittests/ADT/MapVectorTest.cpp
 @@ -6,6 +6,13 @@
@@ -194,11 +194,11 @@
  #include "llvm/ADT/iterator_range.h"
  #include "gtest/gtest.h"
 diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp
-index fe827546a..0e68bad6c 100644
+index 7029038d18d433cef987bedbfa4fda269b24fb8f..f8c37820ef9fdfe0af067f5aa8d2297ed15e73bc 100644
 --- a/llvm/unittests/ADT/SmallVectorTest.cpp
 +++ b/llvm/unittests/ADT/SmallVectorTest.cpp
 @@ -17,6 +17,10 @@
- #include <list>
+ #include <span>
  #include <stdarg.h>
  
 +#if defined(__GNUC__)
@@ -209,7 +209,7 @@
  
  namespace {
 diff --git a/llvm/unittests/Support/AlignOfTest.cpp b/llvm/unittests/Support/AlignOfTest.cpp
-index f84895c18..6a50205b1 100644
+index f84895c18602d3936d623ed79c5d9689cd57cc91..6a50205b143b7ff553066f048a45bf4e1ecc475b 100644
 --- a/llvm/unittests/Support/AlignOfTest.cpp
 +++ b/llvm/unittests/Support/AlignOfTest.cpp
 @@ -31,10 +31,9 @@ namespace {
diff --git a/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch
similarity index 89%
rename from upstream_utils/llvm_patches/0010-Remove-unused-functions.patch
rename to upstream_utils/llvm_patches/0009-Remove-unused-functions.patch
index 50f5300..13bec69 100644
--- a/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch
+++ b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch
@@ -1,21 +1,21 @@
-From df2dc9fdb3d57e01423104a71a6a1d1d6382644a Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 13:43:50 -0400
-Subject: [PATCH 10/28] Remove unused functions
+Subject: [PATCH 09/31] Remove unused functions
 
 ---
- llvm/include/llvm/ADT/SmallString.h      |  80 ------
+ llvm/include/llvm/ADT/SmallString.h      |  85 +-----
  llvm/include/llvm/Support/Errno.h        |   9 -
- llvm/include/llvm/Support/VersionTuple.h |  40 ---
- llvm/include/llvm/Support/raw_ostream.h  | 115 +-------
- llvm/lib/Support/raw_ostream.cpp         | 328 -----------------------
- 5 files changed, 8 insertions(+), 564 deletions(-)
+ llvm/include/llvm/Support/VersionTuple.h |  39 ---
+ llvm/include/llvm/Support/raw_ostream.h  | 127 +--------
+ llvm/lib/Support/raw_ostream.cpp         | 329 -----------------------
+ 5 files changed, 10 insertions(+), 579 deletions(-)
 
 diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h
-index 50cbdade4..bfa965fd6 100644
+index 4d673cc8b1c49cf8a3f19653de53881cd12662ee..bfa965fd68a09d7ca3b332e38585ae37a5982ed0 100644
 --- a/llvm/include/llvm/ADT/SmallString.h
 +++ b/llvm/include/llvm/ADT/SmallString.h
-@@ -88,48 +88,12 @@ public:
+@@ -88,49 +88,12 @@ public:
    /// @name String Comparison
    /// @{
  
@@ -30,8 +30,11 @@
 -    return str().equals_insensitive(RHS);
 -  }
 -
-   /// Compare two strings; the result is -1, 0, or 1 if this string is
-   /// lexicographically less than, equal to, or greater than the \p RHS.
+-  /// compare - Compare two strings; the result is negative, zero, or positive
+-  /// if this string is lexicographically less than, equal to, or greater than
+-  /// the \p RHS.
++  /// Compare two strings; the result is -1, 0, or 1 if this string is
++  /// lexicographically less than, equal to, or greater than the \p RHS.
    int compare(std::string_view RHS) const {
      return str().compare(RHS);
    }
@@ -64,7 +67,7 @@
    /// @}
    /// @name String Searching
    /// @{
-@@ -210,50 +174,6 @@ public:
+@@ -211,50 +174,6 @@ public:
    }
  
    /// @}
@@ -116,10 +119,10 @@
    // Extra methods.
  
 diff --git a/llvm/include/llvm/Support/Errno.h b/llvm/include/llvm/Support/Errno.h
-index 07df6765d..d9bf68bb3 100644
+index e095c66b90860001d90b5c2eb74f6032de6de454..787805dac6c5e3c8cb85dabeb80254443d60806c 100644
 --- a/llvm/include/llvm/Support/Errno.h
 +++ b/llvm/include/llvm/Support/Errno.h
-@@ -20,15 +20,6 @@
+@@ -19,15 +19,6 @@
  namespace llvm {
  namespace sys {
  
@@ -136,24 +139,16 @@
  inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F,
                                         const Args &... As) {
 diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
-index 3d6573bf5..a28e12adc 100644
+index 953b40701dc934c1a356b5413c9c6c692d5f5679..30cf717973fb15ff65a47a2d80795c351b0d2768 100644
 --- a/llvm/include/llvm/Support/VersionTuple.h
 +++ b/llvm/include/llvm/Support/VersionTuple.h
-@@ -16,7 +16,6 @@
- 
- #include "llvm/ADT/DenseMapInfo.h"
- #include "llvm/ADT/Hashing.h"
--#include "llvm/Support/HashBuilder.h"
- #include <optional>
- #include <string>
- #include <tuple>
-@@ -159,45 +158,6 @@ public:
+@@ -168,45 +168,6 @@ public:
    friend bool operator>=(const VersionTuple &X, const VersionTuple &Y) {
      return !(X < Y);
    }
 -
--  friend llvm::hash_code hash_value(const VersionTuple &VT) {
--    return llvm::hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build);
+-  friend hash_code hash_value(const VersionTuple &VT) {
+-    return hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build);
 -  }
 -
 -  template <typename HasherT, llvm::support::endianness Endianness>
@@ -194,10 +189,10 @@
  
  } // end namespace llvm
 diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
-index a25ca5b7b..d4521c8e2 100644
+index 5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5..95019180a9deb406ed4f2991c664a4cc4e956dac 100644
 --- a/llvm/include/llvm/Support/raw_ostream.h
 +++ b/llvm/include/llvm/Support/raw_ostream.h
-@@ -248,32 +248,6 @@ public:
+@@ -261,32 +261,6 @@ public:
      return write(Str.data(), Str.size());
    }
  
@@ -230,7 +225,7 @@
    /// Output \p Str, turning '\\', '\t', '\n', '"', and anything that doesn't
    /// satisfy llvm::isPrint into an escape sequence.
    raw_ostream &write_escaped(std::string_view Str, bool UseHexEscapes = false);
-@@ -281,21 +255,6 @@ public:
+@@ -294,21 +268,6 @@ public:
    raw_ostream &write(unsigned char C);
    raw_ostream &write(const char *Ptr, size_t Size);
  
@@ -252,7 +247,7 @@
    /// indent - Insert 'NumSpaces' spaces.
    raw_ostream &indent(unsigned NumSpaces);
  
-@@ -310,14 +269,19 @@ public:
+@@ -323,14 +282,19 @@ public:
    /// @param BG if true change the background, default: change foreground
    /// @returns itself so it can be used within << invocations
    virtual raw_ostream &changeColor(enum Colors Color, bool Bold = false,
@@ -275,7 +270,7 @@
  
    /// This function determines if this stream is connected to a "tty" or
    /// "console" window. That is, the output would be displayed to the user
-@@ -392,10 +356,6 @@ private:
+@@ -405,10 +369,6 @@ private:
    /// unused bytes in the buffer.
    void copy_to_buffer(const char *Ptr, size_t Size);
  
@@ -286,7 +281,7 @@
    /// Flush the tied-to stream (if present) and then write the required data.
    void flush_tied_then_write(const char *Ptr, size_t Size);
  
-@@ -447,7 +407,6 @@ class raw_fd_ostream : public raw_pwrite_stream {
+@@ -460,7 +420,6 @@ class raw_fd_ostream : public raw_pwrite_stream {
    bool ShouldClose;
    bool SupportsSeeking = false;
    bool IsRegularFile = false;
@@ -294,7 +289,7 @@
  
  #ifdef _WIN32
    /// True if this fd refers to a Windows console device. Mintty and other
-@@ -523,10 +482,6 @@ public:
+@@ -536,10 +495,6 @@ public:
    /// to the offset specified from the beginning of the file.
    uint64_t seek(uint64_t off);
  
@@ -305,7 +300,7 @@
    std::error_code error() const { return EC; }
  
    /// Return the value of the flag in this raw_fd_ostream indicating whether an
-@@ -545,38 +500,6 @@ public:
+@@ -558,38 +513,6 @@ public:
    ///      - from The Zen of Python, by Tim Peters
    ///
    void clear_error() { EC = std::error_code(); }
@@ -330,7 +325,7 @@
 -  ///     });
 -  ///   }
 -  ///   @endcode
--  LLVM_NODISCARD Expected<sys::fs::FileLocker> lock();
+-  [[nodiscard]] Expected<sys::fs::FileLocker> lock();
 -
 -  /// Tries to lock the underlying file within the specified period.
 -  ///
@@ -339,12 +334,12 @@
 -  ///          error code.
 -  ///
 -  /// It is used as @ref lock.
--  LLVM_NODISCARD
--  Expected<sys::fs::FileLocker> tryLockFor(Duration const& Timeout);
+-  [[nodiscard]] Expected<sys::fs::FileLocker>
+-  tryLockFor(Duration const &Timeout);
  };
  
  /// This returns a reference to a raw_fd_ostream for standard output. Use it
-@@ -606,17 +529,6 @@ public:
+@@ -619,17 +542,6 @@ public:
    /// immediately destroyed.
    raw_fd_stream(std::string_view Filename, std::error_code &EC);
  
@@ -362,7 +357,7 @@
    /// Check if \p OS is a pointer of type raw_fd_stream*.
    static bool classof(const raw_ostream *OS);
  };
-@@ -734,17 +646,6 @@ public:
+@@ -747,29 +659,6 @@ public:
    ~buffer_unique_ostream() override { *OS << str(); }
  };
  
@@ -377,14 +372,26 @@
 -Error writeToOutput(std::string_view OutputFileName,
 -                    std::function<Error(raw_ostream &)> Write);
 -
+-raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t);
+-
+-template <typename T, typename = decltype(std::declval<raw_ostream &>()
+-                                          << std::declval<const T &>())>
+-raw_ostream &operator<<(raw_ostream &OS, const std::optional<T> &O) {
+-  if (O)
+-    OS << *O;
+-  else
+-    OS << std::nullopt;
+-  return OS;
+-}
+-
  } // end namespace llvm
  
  #endif // LLVM_SUPPORT_RAW_OSTREAM_H
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index ee01a9522..875eda7ba 100644
+index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f472ccd5e 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
-@@ -19,7 +19,6 @@
+@@ -18,7 +18,6 @@
  #include "llvm/ADT/StringExtras.h"
  #include "llvm/Config/config.h"
  #include "llvm/Support/Compiler.h"
@@ -392,7 +399,7 @@
  #include "llvm/Support/ErrorHandling.h"
  #include "llvm/Support/FileSystem.h"
  #include "llvm/Support/Format.h"
-@@ -120,49 +119,6 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
+@@ -127,49 +126,6 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
    assert(OutBufStart <= OutBufEnd && "Invalid size!");
  }
  
@@ -442,7 +449,7 @@
  raw_ostream &raw_ostream::write_escaped(std::string_view Str,
                                          bool UseHexEscapes) {
    for (unsigned char c : Str) {
-@@ -308,172 +264,6 @@ void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) {
+@@ -315,173 +271,6 @@ void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) {
    write_impl(Ptr, Size);
  }
  
@@ -550,7 +557,7 @@
 -  const size_t Size = Bytes.size();
 -  HexPrintStyle HPS = FB.Upper ? HexPrintStyle::Upper : HexPrintStyle::Lower;
 -  uint64_t OffsetWidth = 0;
--  if (FB.FirstByteOffset.hasValue()) {
+-  if (FB.FirstByteOffset) {
 -    // Figure out how many nibbles are needed to print the largest offset
 -    // represented by this data set, so that we can align the offset field
 -    // to the right width.
@@ -570,8 +577,8 @@
 -  while (!Bytes.empty()) {
 -    indent(FB.IndentLevel);
 -
--    if (FB.FirstByteOffset.hasValue()) {
--      uint64_t Offset = FB.FirstByteOffset.getValue();
+-    if (FB.FirstByteOffset) {
+-      uint64_t Offset = *FB.FirstByteOffset;
 -      llvm::write_hex(*this, Offset + LineIndex, HPS, OffsetWidth);
 -      *this << ": ";
 -    }
@@ -612,10 +619,11 @@
 -  }
 -  return *this;
 -}
- 
+-
  template <char C>
  static raw_ostream &write_padding(raw_ostream &OS, unsigned NumChars) {
-@@ -506,63 +296,8 @@ raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) {
+   static const char Chars[] = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C,
+@@ -512,63 +301,8 @@ raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) {
    return write_padding<'\0'>(*this, NumZeros);
  }
  
@@ -679,7 +687,7 @@
  //===----------------------------------------------------------------------===//
  //  raw_fd_ostream
  //===----------------------------------------------------------------------===//
-@@ -854,31 +589,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const {
+@@ -867,31 +601,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const {
  #endif
  }
  
@@ -711,7 +719,7 @@
  void raw_fd_ostream::anchor() {}
  
  //===----------------------------------------------------------------------===//
-@@ -921,16 +631,6 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC)
+@@ -934,16 +643,6 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC)
      EC = std::make_error_code(std::errc::invalid_argument);
  }
  
@@ -728,7 +736,7 @@
  bool raw_fd_stream::classof(const raw_ostream *OS) {
    return OS->get_kind() == OStreamKind::OK_FDStream;
  }
-@@ -986,31 +686,3 @@ void raw_pwrite_stream::anchor() {}
+@@ -999,31 +698,3 @@ void raw_pwrite_stream::anchor() {}
  void buffer_ostream::anchor() {}
  
  void buffer_unique_ostream::anchor() {}
@@ -743,7 +751,7 @@
 -    return Write(Out);
 -  }
 -
--  unsigned Mode = sys::fs::all_read | sys::fs::all_write | sys::fs::all_exe;
+-  unsigned Mode = sys::fs::all_read | sys::fs::all_write;
 -  Expected<sys::fs::TempFile> Temp =
 -      sys::fs::TempFile::create(OutputFileName + ".temp-stream-%%%%%%", Mode);
 -  if (!Temp)
diff --git a/upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch
similarity index 62%
rename from upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch
rename to upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch
index 320e500..8d28e0f 100644
--- a/upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch
+++ b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch
@@ -1,18 +1,18 @@
-From ef26f059859d3a0d08b06a70519928bcd5f9bb79 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Thu, 5 May 2022 23:18:34 -0400
-Subject: [PATCH 11/28] Detemplatize SmallVectorBase
+Subject: [PATCH 10/31] Detemplatize SmallVectorBase
 
 ---
- llvm/include/llvm/ADT/SmallVector.h | 21 +++++++-----------
- llvm/lib/Support/SmallVector.cpp    | 34 +++++------------------------
- 2 files changed, 13 insertions(+), 42 deletions(-)
+ llvm/include/llvm/ADT/SmallVector.h | 27 +++++++--------------
+ llvm/lib/Support/SmallVector.cpp    | 37 +++++------------------------
+ 2 files changed, 14 insertions(+), 50 deletions(-)
 
 diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
-index 1e311ea56..4b6bbdeb2 100644
+index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4beae91b10a 100644
 --- a/llvm/include/llvm/ADT/SmallVector.h
 +++ b/llvm/include/llvm/ADT/SmallVector.h
-@@ -50,14 +50,14 @@ template <typename IteratorT> class iterator_range;
+@@ -56,14 +56,14 @@ using EnableIfConvertibleToInputIterator = std::enable_if_t<std::is_convertible<
  /// Using 64 bit size is desirable for cases like SmallVector<char>, where a
  /// 32 bit size would limit the vector to ~4GB. SmallVectors are used for
  /// buffering bitcode output - which can exceed 4GB.
@@ -30,14 +30,14 @@
    }
  
    SmallVectorBase() = delete;
-@@ -91,15 +91,10 @@ protected:
+@@ -111,15 +111,10 @@ protected:
    }
  };
  
 -template <class T>
 -using SmallVectorSizeType =
--    typename std::conditional<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
--                              uint32_t>::type;
+-    std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
+-                       uint32_t>;
 -
  /// Figure out the offset of the first element.
  template <class T, typename = void> struct SmallVectorAlignmentAndSize {
@@ -48,7 +48,7 @@
    alignas(T) char FirstEl[sizeof(T)];
  };
  
-@@ -108,8 +103,8 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
+@@ -128,8 +123,8 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
  /// to avoid unnecessarily requiring T to be complete.
  template <typename T, typename = void>
  class SmallVectorTemplateCommon
@@ -57,19 +57,32 @@
 +    : public SmallVectorBase {
 +  using Base = SmallVectorBase;
  
+ protected:
    /// Find the address of the first element.  For this pointer math to be valid
-   /// with small-size of 0 for T with lots of alignment, it's important that
-@@ -356,7 +351,7 @@ protected:
-   /// in \p NewCapacity. This is the first section of \a grow().
-   T *mallocForGrow(size_t MinSize, size_t &NewCapacity) {
-     return static_cast<T *>(
--        SmallVectorBase<SmallVectorSizeType<T>>::mallocForGrow(
-+        SmallVectorBase::mallocForGrow(
-             MinSize, sizeof(T), NewCapacity));
-   }
+@@ -451,7 +446,7 @@ template <typename T, bool TriviallyCopyable>
+ T *SmallVectorTemplateBase<T, TriviallyCopyable>::mallocForGrow(
+     size_t MinSize, size_t &NewCapacity) {
+   return static_cast<T *>(
+-      SmallVectorBase<SmallVectorSizeType<T>>::mallocForGrow(
++      SmallVectorBase::mallocForGrow(
+           this->getFirstEl(), MinSize, sizeof(T), NewCapacity));
+ }
  
+@@ -1324,12 +1319,6 @@ template <typename Out, typename R> SmallVector<Out> to_vector_of(R &&Range) {
+   return {std::begin(Range), std::end(Range)};
+ }
+ 
+-// Explicit instantiations
+-extern template class llvm::SmallVectorBase<uint32_t>;
+-#if SIZE_MAX > UINT32_MAX
+-extern template class llvm::SmallVectorBase<uint64_t>;
+-#endif
+-
+ } // end namespace llvm
+ 
+ namespace std {
 diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
-index a2b4899e1..bdfc963d7 100644
+index 6cefdff7c28060ca18b522acf5279af3a206e23a..ae64a36dcf4b9ceaf8767adbf8100f164f3738ac 100644
 --- a/llvm/lib/Support/SmallVector.cpp
 +++ b/llvm/lib/Support/SmallVector.cpp
 @@ -51,10 +51,6 @@ static_assert(sizeof(SmallVector<void *, 1>) ==
@@ -94,17 +107,31 @@
  
    // Ensure we can fit the new capacity.
    // This is only going to be applicable when the capacity is 32 bit.
-@@ -108,18 +103,16 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
+@@ -107,8 +102,7 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
+   return std::clamp(NewCapacity, MinSize, MaxSize);
+ }
+ 
+-template <class Size_T>
+-void *SmallVectorBase<Size_T>::replaceAllocation(void *NewElts, size_t TSize,
++void *SmallVectorBase::replaceAllocation(void *NewElts, size_t TSize,
+                                                  size_t NewCapacity,
+                                                  size_t VSize) {
+   void *NewEltsReplace = llvm::safe_malloc(NewCapacity * TSize);
+@@ -119,11 +113,10 @@ void *SmallVectorBase<Size_T>::replaceAllocation(void *NewElts, size_t TSize,
  }
  
  // Note: Moving this function into the header may cause performance regression.
 -template <class Size_T>
--void *SmallVectorBase<Size_T>::mallocForGrow(size_t MinSize, size_t TSize,
-+void *SmallVectorBase::mallocForGrow(size_t MinSize, size_t TSize,
+-void *SmallVectorBase<Size_T>::mallocForGrow(void *FirstEl, size_t MinSize,
++void *SmallVectorBase::mallocForGrow(void *FirstEl, size_t MinSize,
+                                              size_t TSize,
                                               size_t &NewCapacity) {
 -  NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
 +  NewCapacity = getNewCapacity(MinSize, TSize, this->capacity());
-   return llvm::safe_malloc(NewCapacity * TSize);
+   // Even if capacity is not 0 now, if the vector was originally created with
+   // capacity 0, it's possible for the malloc to return FirstEl.
+   void *NewElts = llvm::safe_malloc(NewCapacity * TSize);
+@@ -133,10 +126,9 @@ void *SmallVectorBase<Size_T>::mallocForGrow(void *FirstEl, size_t MinSize,
  }
  
  // Note: Moving this function into the header may cause performance regression.
@@ -116,8 +143,8 @@
 +  size_t NewCapacity = getNewCapacity(MinSize, TSize, this->capacity());
    void *NewElts;
    if (BeginX == FirstEl) {
-     NewElts = safe_malloc(NewCapacity * TSize);
-@@ -134,20 +127,3 @@ void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
+     NewElts = llvm::safe_malloc(NewCapacity * TSize);
+@@ -155,20 +147,3 @@ void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
    this->BeginX = NewElts;
    this->Capacity = NewCapacity;
  }
diff --git a/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch
similarity index 94%
rename from upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch
rename to upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch
index cc0bd5d..cba909f 100644
--- a/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch
+++ b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch
@@ -1,7 +1,7 @@
-From 342ebd445bb3dae8b0c119a6126a318ad378a377 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 13:48:59 -0400
-Subject: [PATCH 12/28] Add vectors to raw_ostream
+Subject: [PATCH 11/31] Add vectors to raw_ostream
 
 ---
  llvm/include/llvm/Support/raw_ostream.h | 115 ++++++++++++++++++++++++
@@ -9,18 +9,18 @@
  2 files changed, 162 insertions(+)
 
 diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
-index d4521c8e2..bf5630ab5 100644
+index 95019180a9deb406ed4f2991c664a4cc4e956dac..e7526e016a858ad728feb7cf1c5014b9691759d4 100644
 --- a/llvm/include/llvm/Support/raw_ostream.h
 +++ b/llvm/include/llvm/Support/raw_ostream.h
-@@ -25,6 +25,7 @@
- #endif
+@@ -24,6 +24,7 @@
+ #include <string_view>
  #include <system_error>
  #include <type_traits>
 +#include <vector>
  
  namespace llvm {
  
-@@ -248,12 +249,24 @@ public:
+@@ -261,12 +262,24 @@ public:
      return write(Str.data(), Str.size());
    }
  
@@ -45,7 +45,7 @@
  
    /// indent - Insert 'NumSpaces' spaces.
    raw_ostream &indent(unsigned NumSpaces);
-@@ -604,6 +617,108 @@ public:
+@@ -617,6 +630,108 @@ public:
    }
  };
  
@@ -155,10 +155,10 @@
  class raw_null_ostream : public raw_pwrite_stream {
    /// See raw_ostream::write_impl.
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index 875eda7ba..36faf744c 100644
+index 76c32155b4296fbbf3f4b164cd58d63f472ccd5e..dcdfdfd7a8e3fcc4019538a4fc9e158aeda0a8b8 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
-@@ -658,6 +658,53 @@ void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size,
+@@ -670,6 +670,53 @@ void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size,
    memcpy(OS.data() + Offset, Ptr, Size);
  }
  
diff --git a/upstream_utils/llvm_patches/0013-Extra-collections-features.patch b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch
similarity index 93%
rename from upstream_utils/llvm_patches/0013-Extra-collections-features.patch
rename to upstream_utils/llvm_patches/0012-Extra-collections-features.patch
index 19aef1a..7da2c10 100644
--- a/upstream_utils/llvm_patches/0013-Extra-collections-features.patch
+++ b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch
@@ -1,7 +1,7 @@
-From 5db7e9f9370a5e04949846cc68eeb13e2c1db187 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 3 May 2022 22:16:10 -0400
-Subject: [PATCH 13/28] Extra collections features
+Subject: [PATCH 12/31] Extra collections features
 
 ---
  llvm/include/llvm/ADT/StringMap.h | 103 +++++++++++++++++++++++++++++-
@@ -9,7 +9,7 @@
  2 files changed, 110 insertions(+), 1 deletion(-)
 
 diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h
-index 8747cdb35..16f13f048 100644
+index 34dfbf83c681f4e81a9dadd9382ddca6ef8d6c1d..c133e84f9b2e3a225cdac782c011fadbf07adab2 100644
 --- a/llvm/include/llvm/ADT/StringMap.h
 +++ b/llvm/include/llvm/ADT/StringMap.h
 @@ -42,7 +42,7 @@ protected:
@@ -21,7 +21,7 @@
        : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets),
          NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones),
          ItemSize(RHS.ItemSize) {
-@@ -420,11 +420,27 @@ public:
+@@ -432,11 +432,27 @@ public:
      return Tmp;
    }
  
@@ -49,7 +49,7 @@
  };
  
  template <typename ValueTy>
-@@ -483,6 +499,91 @@ public:
+@@ -495,6 +511,91 @@ public:
    std::string_view operator*() const { return this->wrapped()->getKey(); }
  };
  
@@ -142,7 +142,7 @@
  
  #endif // LLVM_ADT_STRINGMAP_H
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index 36faf744c..95152849c 100644
+index dcdfdfd7a8e3fcc4019538a4fc9e158aeda0a8b8..b2a726633b48b179abfd24a5de110a2301e0f877 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
 @@ -76,6 +76,14 @@ constexpr raw_ostream::Colors raw_ostream::WHITE;
diff --git a/upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch b/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch
similarity index 69%
rename from upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch
rename to upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch
index 1049911..a280def 100644
--- a/upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch
+++ b/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch
@@ -1,14 +1,14 @@
-From 9951c4b3fea6b2dbe7141070444de8df6ae4ce9b Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Wed, 4 May 2022 00:01:00 -0400
-Subject: [PATCH 14/28] EpochTracker ABI macro
+Subject: [PATCH 13/31] EpochTracker ABI macro
 
 ---
  llvm/include/llvm/ADT/EpochTracker.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/llvm/include/llvm/ADT/EpochTracker.h b/llvm/include/llvm/ADT/EpochTracker.h
-index b06888494..f35461d1c 100644
+index fc41d6f2c92d2f9876c741067b5645a74663db04..56d0acda2c1a0e390cfed086fa298b650c4a561f 100644
 --- a/llvm/include/llvm/ADT/EpochTracker.h
 +++ b/llvm/include/llvm/ADT/EpochTracker.h
 @@ -22,7 +22,7 @@
@@ -17,6 +17,6 @@
  
 -#if LLVM_ENABLE_ABI_BREAKING_CHECKS
 +#ifndef NDEBUG //ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
+ #define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE
  
  /// A base class for data structure classes wishing to make iterators
- /// ("handles") pointing into themselves fail-fast.  When building without
diff --git a/upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch
similarity index 88%
rename from upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch
rename to upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch
index 5578739..ea27672 100644
--- a/upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch
+++ b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch
@@ -1,19 +1,19 @@
-From 907608f09061ab272b0a127330b1b24e28d50a9f Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Thu, 5 May 2022 18:09:45 -0400
-Subject: [PATCH 15/28] Delete numbers from MathExtras
+Subject: [PATCH 14/31] Delete numbers from MathExtras
 
 ---
  llvm/include/llvm/Support/MathExtras.h | 36 --------------------------
  1 file changed, 36 deletions(-)
 
 diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
-index fac12dd0e..e8f1f2aca 100644
+index cd5a64a746b2eb7491e9b6cf8570bdf436d94a6d..cdf859ccfaca22a04b08a351d7c2c9789a70627e 100644
 --- a/llvm/include/llvm/Support/MathExtras.h
 +++ b/llvm/include/llvm/Support/MathExtras.h
-@@ -50,42 +50,6 @@ enum ZeroBehavior {
-   ZB_Width
- };
+@@ -24,42 +24,6 @@
+ 
+ namespace llvm {
  
 -/// Mathematical constants.
 -namespace numbers {
@@ -51,6 +51,6 @@
 -                phif        = 1.61803399F; // (0x1.9e377aP+0) https://oeis.org/A001622
 -} // namespace numbers
 -
- namespace detail {
- template <typename T, std::size_t SizeOfT> struct TrailingZerosCounter {
-   static unsigned count(T Val, ZeroBehavior) {
+ /// Create a bitmask with the N right-most bits set to 1, and all other
+ /// bits set to 0.  Only unsigned types are allowed.
+ template <typename T> T maskTrailingOnes(unsigned N) {
diff --git a/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch
similarity index 78%
rename from upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch
rename to upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch
index 8dcc9c7..c2fe9ed 100644
--- a/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch
+++ b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch
@@ -1,17 +1,17 @@
-From 9ef10e5b331d00d7d5822afdb70c1f2d9981d772 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 3 May 2022 22:50:24 -0400
-Subject: [PATCH 16/28] Add lerp and sgn
+Subject: [PATCH 15/31] Add lerp and sgn
 
 ---
  llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
 
 diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
-index e8f1f2aca..8116c58bd 100644
+index cdf859ccfaca22a04b08a351d7c2c9789a70627e..b82d9883c41008dcbbd933709c6e854ad74c5b58 100644
 --- a/llvm/include/llvm/Support/MathExtras.h
 +++ b/llvm/include/llvm/Support/MathExtras.h
-@@ -930,6 +930,26 @@ std::enable_if_t<std::is_signed<T>::value, T> MulOverflow(T X, T Y, T &Result) {
+@@ -614,6 +614,26 @@ std::enable_if_t<std::is_signed_v<T>, T> MulOverflow(T X, T Y, T &Result) {
      return UX > (static_cast<U>((std::numeric_limits<T>::max)())) / UY;
  }
  
diff --git a/upstream_utils/llvm_patches/0017-Fixup-includes.patch b/upstream_utils/llvm_patches/0016-Fixup-includes.patch
similarity index 72%
rename from upstream_utils/llvm_patches/0017-Fixup-includes.patch
rename to upstream_utils/llvm_patches/0016-Fixup-includes.patch
index f247db0..6d32c22 100644
--- a/upstream_utils/llvm_patches/0017-Fixup-includes.patch
+++ b/upstream_utils/llvm_patches/0016-Fixup-includes.patch
@@ -1,7 +1,7 @@
-From aa30b80d86cb0774efc094646339b54694ab8398 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 16:38:11 -0400
-Subject: [PATCH 17/28] Fixup includes
+Subject: [PATCH 16/31] Fixup includes
 
 ---
  llvm/include/llvm/ADT/StringMap.h                 |  4 ++++
@@ -9,14 +9,15 @@
  llvm/include/llvm/Support/PointerLikeTypeTraits.h |  1 +
  llvm/lib/Support/ConvertUTFWrapper.cpp            |  1 +
  llvm/lib/Support/ErrorHandling.cpp                |  7 +++----
- llvm/lib/Support/raw_ostream.cpp                  | 12 ++++++------
+ llvm/lib/Support/raw_ostream.cpp                  | 11 ++++++-----
  llvm/unittests/ADT/SmallPtrSetTest.cpp            |  2 ++
+ llvm/unittests/ADT/SmallVectorTest.cpp            |  1 +
  llvm/unittests/ADT/StringMapTest.cpp              |  1 +
  llvm/unittests/Support/ConvertUTFTest.cpp         |  2 ++
- 9 files changed, 24 insertions(+), 10 deletions(-)
+ 10 files changed, 25 insertions(+), 9 deletions(-)
 
 diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h
-index 16f13f048..6ae0e39a1 100644
+index c133e84f9b2e3a225cdac782c011fadbf07adab2..2173a4159111e7fea70325de82dbfce628ae3ea8 100644
 --- a/llvm/include/llvm/ADT/StringMap.h
 +++ b/llvm/include/llvm/ADT/StringMap.h
 @@ -17,6 +17,10 @@
@@ -31,7 +32,7 @@
  #include <initializer_list>
  #include <iterator>
 diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
-index 39976a02b..cdefc5449 100644
+index 388e81c361642113937f7d5680de73a50635b07d..011806f5fd89ff738ed805a82b3ddbc6fc9b08ce 100644
 --- a/llvm/include/llvm/ADT/StringMapEntry.h
 +++ b/llvm/include/llvm/ADT/StringMapEntry.h
 @@ -16,6 +16,10 @@
@@ -46,7 +47,7 @@
  #include <string_view>
  
 diff --git a/llvm/include/llvm/Support/PointerLikeTypeTraits.h b/llvm/include/llvm/Support/PointerLikeTypeTraits.h
-index 1b15f930b..acadd5e89 100644
+index 1b15f930bd87d97d51824af5e62ea5f222a6b4c9..acadd5e89a1651cfbad67a5b1b0933d1f288d094 100644
 --- a/llvm/include/llvm/Support/PointerLikeTypeTraits.h
 +++ b/llvm/include/llvm/Support/PointerLikeTypeTraits.h
 @@ -16,6 +16,7 @@
@@ -58,19 +59,19 @@
  
  namespace llvm {
 diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp
-index 396ab0c65..cff30f16c 100644
+index d53462e742e61d3476915d5b2c5aa63772e78a8a..34054140489e4d536ace4650207c783d669d850e 100644
 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp
 +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp
-@@ -8,6 +8,7 @@
+@@ -7,6 +7,7 @@
+ //===----------------------------------------------------------------------===//
  
- #include "llvm/ADT/span.h"
  #include "llvm/Support/ConvertUTF.h"
 +#include "llvm/Support/SmallVector.h"
  #include "llvm/Support/ErrorHandling.h"
  #include "llvm/Support/SwapByteOrder.h"
- #include <string>
+ #include <span>
 diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
-index f80e28e87..ec1a1633a 100644
+index 0b87b375de67dc18647e3ebe646bf323dd05e8c5..3a88178cfbbcf7062a958c7de820247bc913ab33 100644
 --- a/llvm/lib/Support/ErrorHandling.cpp
 +++ b/llvm/lib/Support/ErrorHandling.cpp
 @@ -28,12 +28,11 @@
@@ -90,20 +91,19 @@
  
  using namespace llvm;
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index 95152849c..878a3a5e9 100644
+index b2a726633b48b179abfd24a5de110a2301e0f877..3b7d8d6db5f0df31e18b91be716a4fd21e7e3549 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
-@@ -15,7 +15,8 @@
+@@ -15,6 +15,8 @@
  #endif
  
  #include "llvm/Support/raw_ostream.h"
--#include "llvm/ADT/STLArrayExtras.h"
 +#include "wpi/SmallString.h"
 +#include "wpi/SmallVector.h"
  #include "llvm/ADT/StringExtras.h"
  #include "llvm/Config/config.h"
  #include "llvm/Support/Compiler.h"
-@@ -33,12 +34,11 @@
+@@ -32,12 +34,11 @@
  #include <sys/stat.h>
  
  // <fcntl.h> may provide O_BINARY.
@@ -119,17 +119,17 @@
  #endif
  
  #if defined(__CYGWIN__)
-@@ -60,7 +60,7 @@
- 
+@@ -60,7 +61,7 @@
  #ifdef _WIN32
  #include "llvm/Support/ConvertUTF.h"
+ #include "llvm/Support/Signals.h"
 -#include "llvm/Support/Windows/WindowsSupport.h"
 +#include "Windows/WindowsSupport.h"
  #endif
  
  using namespace llvm;
 diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
-index 531f81ab5..3db8b6e37 100644
+index 531f81ab5b3fc1dcff731230f3cb7649cb90aedf..3db8b6e37d31a0a3cc304da8fc4cbbe1d89252b5 100644
 --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
 +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
 @@ -15,6 +15,8 @@
@@ -141,8 +141,20 @@
  using namespace llvm;
  
  TEST(SmallPtrSetTest, Assignment) {
+diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp
+index f8c37820ef9fdfe0af067f5aa8d2297ed15e73bc..5e91f71bc9ac0e499a64dd1591e581d0707417f6 100644
+--- a/llvm/unittests/ADT/SmallVectorTest.cpp
++++ b/llvm/unittests/ADT/SmallVectorTest.cpp
+@@ -13,6 +13,7 @@
+ #include "llvm/ADT/SmallVector.h"
+ #include "llvm/Support/Compiler.h"
+ #include "gtest/gtest.h"
++#include <array>
+ #include <list>
+ #include <span>
+ #include <stdarg.h>
 diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
-index 6d0c0942c..de6daf3da 100644
+index acd8b566f9c7a6efc2c9204624c01104dd34daf6..6b6cf564909f329c220eb225f3b7af6c35301029 100644
 --- a/llvm/unittests/ADT/StringMapTest.cpp
 +++ b/llvm/unittests/ADT/StringMapTest.cpp
 @@ -9,6 +9,7 @@
@@ -154,7 +166,7 @@
  #include <tuple>
  using namespace llvm;
 diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp
-index 9c798437a..2fee8ad5c 100644
+index 3b07d344f15a555f11ad5f8177a0a65b8a4fa472..77e70a46d3621ecfaed923d87256184addfda721 100644
 --- a/llvm/unittests/Support/ConvertUTFTest.cpp
 +++ b/llvm/unittests/Support/ConvertUTFTest.cpp
 @@ -7,6 +7,8 @@
diff --git a/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch b/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch
new file mode 100644
index 0000000..c78fd42
--- /dev/null
+++ b/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch
@@ -0,0 +1,36 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: PJ Reiniger <pj.reiniger@gmail.com>
+Date: Sun, 8 May 2022 16:42:09 -0400
+Subject: [PATCH 17/31] Use std::is_trivially_copy_constructible
+
+---
+ llvm/include/llvm/Support/type_traits.h | 16 ----------------
+ 1 file changed, 16 deletions(-)
+
+diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
+index 3fd158def34d7256a736f8fb0b30dadea2177864..3171af93fa7ffe4707c03289270cf5951e3db7c5 100644
+--- a/llvm/include/llvm/Support/type_traits.h
++++ b/llvm/include/llvm/Support/type_traits.h
+@@ -76,22 +76,6 @@ union trivial_helper {
+ 
+ } // end namespace detail
+ 
+-template <typename T>
+-struct is_copy_assignable {
+-  template<class F>
+-    static auto get(F*) -> decltype(std::declval<F &>() = std::declval<const F &>(), std::true_type{});
+-    static std::false_type get(...);
+-    static constexpr bool value = decltype(get((T*)nullptr))::value;
+-};
+-
+-template <typename T>
+-struct is_move_assignable {
+-  template<class F>
+-    static auto get(F*) -> decltype(std::declval<F &>() = std::declval<F &&>(), std::true_type{});
+-    static std::false_type get(...);
+-    static constexpr bool value = decltype(get((T*)nullptr))::value;
+-};
+-
+ } // end namespace llvm
+ 
+ #endif // LLVM_SUPPORT_TYPE_TRAITS_H
diff --git a/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch b/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch
index 4e2650e..47fdf0a 100644
--- a/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch
+++ b/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch
@@ -1,41 +1,17 @@
-From 1c3e8a6ff8d8b6c054141503c7318d69319d8d41 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 16:42:09 -0400
-Subject: [PATCH 18/28] Use std::is_trivially_copy_constructible
+Subject: [PATCH 18/31] Use std::is_trivially_copy_constructible
 
 ---
- llvm/include/llvm/ADT/PointerIntPair.h  | 12 ----
- llvm/include/llvm/Support/type_traits.h | 91 +------------------------
- 2 files changed, 2 insertions(+), 101 deletions(-)
+ llvm/include/llvm/Support/type_traits.h | 37 ++-----------------------
+ 1 file changed, 2 insertions(+), 35 deletions(-)
 
-diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
-index b7ddf8855..a48fb904b 100644
---- a/llvm/include/llvm/ADT/PointerIntPair.h
-+++ b/llvm/include/llvm/ADT/PointerIntPair.h
-@@ -128,18 +128,6 @@ public:
-   }
- };
- 
--// Specialize is_trivially_copyable to avoid limitation of llvm::is_trivially_copyable
--// when compiled with gcc 4.9.
--template <typename PointerTy, unsigned IntBits, typename IntType,
--          typename PtrTraits,
--          typename Info>
--struct is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>> : std::true_type {
--#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
--  static_assert(std::is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>>::value,
--                "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
--#endif
--};
--
- 
- template <typename PointerT, unsigned IntBits, typename PtrTraits>
- struct PointerIntPairInfo {
 diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
-index 7b7d5d991..72a2e84ad 100644
+index a6046de87d1e3e1264a0040826ea347b870a8f9e..292a2cb78b93717647cf88d00f88c2eec14f52f6 100644
 --- a/llvm/include/llvm/Support/type_traits.h
 +++ b/llvm/include/llvm/Support/type_traits.h
-@@ -92,98 +92,11 @@ union trivial_helper {
+@@ -92,44 +92,11 @@ union trivial_helper {
  
  } // end namespace detail
  
@@ -78,61 +54,7 @@
 -    static std::false_type get(...);
 -    static constexpr bool value = decltype(get((T*)nullptr))::value;
 -};
--
--
--// An implementation of `std::is_trivially_copyable` since STL version
--// is not equally supported by all compilers, especially GCC 4.9.
--// Uniform implementation of this trait is important for ABI compatibility
--// as it has an impact on SmallVector's ABI (among others).
--template <typename T>
--class is_trivially_copyable {
--
--  // copy constructors
--  static constexpr bool has_trivial_copy_constructor =
--      std::is_copy_constructible<detail::trivial_helper<T>>::value;
--  static constexpr bool has_deleted_copy_constructor =
--      !std::is_copy_constructible<T>::value;
--
--  // move constructors
--  static constexpr bool has_trivial_move_constructor =
--      std::is_move_constructible<detail::trivial_helper<T>>::value;
--  static constexpr bool has_deleted_move_constructor =
--      !std::is_move_constructible<T>::value;
--
--  // copy assign
--  static constexpr bool has_trivial_copy_assign =
--      is_copy_assignable<detail::trivial_helper<T>>::value;
--  static constexpr bool has_deleted_copy_assign =
--      !is_copy_assignable<T>::value;
--
--  // move assign
--  static constexpr bool has_trivial_move_assign =
--      is_move_assignable<detail::trivial_helper<T>>::value;
--  static constexpr bool has_deleted_move_assign =
--      !is_move_assignable<T>::value;
--
--  // destructor
--  static constexpr bool has_trivial_destructor =
--      std::is_destructible<detail::trivial_helper<T>>::value;
--
--  public:
--
--  static constexpr bool value =
--      has_trivial_destructor &&
--      (has_deleted_move_assign || has_trivial_move_assign) &&
--      (has_deleted_move_constructor || has_trivial_move_constructor) &&
--      (has_deleted_copy_assign || has_trivial_copy_assign) &&
--      (has_deleted_copy_constructor || has_trivial_copy_constructor);
--
--#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
--  static_assert(value == std::is_trivially_copyable<T>::value,
--                "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
--#endif
--};
--template <typename T>
--class is_trivially_copyable<T*> : public std::true_type {
--};
 +using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
  
- 
  } // end namespace llvm
+ 
diff --git a/upstream_utils/llvm_patches/0019-Windows-support.patch b/upstream_utils/llvm_patches/0018-Windows-support.patch
similarity index 83%
rename from upstream_utils/llvm_patches/0019-Windows-support.patch
rename to upstream_utils/llvm_patches/0018-Windows-support.patch
index 07d973b..43e0a07 100644
--- a/upstream_utils/llvm_patches/0019-Windows-support.patch
+++ b/upstream_utils/llvm_patches/0018-Windows-support.patch
@@ -1,15 +1,16 @@
-From 36f7f08e257f2b58b2894f165a38ff2a831aed8f Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Tue, 3 May 2022 20:22:38 -0400
-Subject: [PATCH 19/28] Windows support
+Subject: [PATCH 18/31] Windows support
 
 ---
  .../llvm/Support/Windows/WindowsSupport.h     | 45 +++++----
  llvm/lib/Support/ConvertUTF.cpp               | 95 +++++++++++++++++++
- 2 files changed, 124 insertions(+), 16 deletions(-)
+ llvm/lib/Support/raw_ostream.cpp              |  1 -
+ 3 files changed, 124 insertions(+), 17 deletions(-)
 
 diff --git a/llvm/include/llvm/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h
-index 180803fbd..31120cfa0 100644
+index aabdb2f14668a990329b57f5454a0d7db73e12ce..2ac474092a62d488da1ec7f07a1cd10b0781d938 100644
 --- a/llvm/include/llvm/Support/Windows/WindowsSupport.h
 +++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h
 @@ -35,8 +35,6 @@
@@ -67,9 +68,9 @@
 +  return GetWindowsOSVersion() >= llvm::VersionTuple(6, 2, 0, 0);
 +}
  
- /// Returns the Windows version as Major.Minor.0.BuildNumber. Uses
- /// RtlGetVersion or GetVersionEx under the hood depending on what is available.
-@@ -228,19 +254,6 @@ inline FILETIME toFILETIME(TimePoint<> TP) {
+ /// Determines if the program is running on Windows 11 or Windows Server 2022.
+ bool RunningWindows11OrGreater();
+@@ -231,19 +257,6 @@ inline FILETIME toFILETIME(TimePoint<> TP) {
    return Time;
  }
  
@@ -90,10 +91,10 @@
  } // end namespace llvm.
  
 diff --git a/llvm/lib/Support/ConvertUTF.cpp b/llvm/lib/Support/ConvertUTF.cpp
-index e24a918c5..c906ded91 100644
+index bc04c5ab5113563fb82d7b3b168985369b611f4b..57eb64a6017a6964ab14b40b8c6b3563cd41ffac 100644
 --- a/llvm/lib/Support/ConvertUTF.cpp
 +++ b/llvm/lib/Support/ConvertUTF.cpp
-@@ -51,6 +51,11 @@
+@@ -67,6 +67,11 @@
  #endif
  #include <assert.h>
  
@@ -105,7 +106,7 @@
  /*
   * This code extensively uses fall-through switches.
   * Keep the compiler from warning about that.
-@@ -733,6 +738,96 @@ ConversionResult ConvertUTF8toUTF32(const UTF8 **sourceStart,
+@@ -759,6 +764,96 @@ ConversionResult ConvertUTF8toUTF32(const UTF8 **sourceStart,
  
     --------------------------------------------------------------------- */
  
@@ -202,3 +203,15 @@
  } // namespace llvm
  
  ConvertUTF_RESTORE_WARNINGS
+diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
+index 3b7d8d6db5f0df31e18b91be716a4fd21e7e3549..4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f 100644
+--- a/llvm/lib/Support/raw_ostream.cpp
++++ b/llvm/lib/Support/raw_ostream.cpp
+@@ -534,7 +534,6 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
+       DWORD WinLastError = GetLastError();
+       if (WinLastError == ERROR_BROKEN_PIPE ||
+           (WinLastError == ERROR_NO_DATA && errno == EINVAL)) {
+-        llvm::sys::CallOneShotPipeSignalHandler();
+         errno = EPIPE;
+       }
+ #endif
diff --git a/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch b/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch
similarity index 88%
rename from upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch
rename to upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch
index 4315754..4d5b81c 100644
--- a/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch
+++ b/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch
@@ -1,14 +1,14 @@
-From 8834260a9ee172311cc08d0b4e4e958bf36a260f Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 16:46:20 -0400
-Subject: [PATCH 20/28] Prefer fmtlib
+Subject: [PATCH 19/31] Prefer fmtlib
 
 ---
  llvm/lib/Support/ErrorHandling.cpp | 20 ++++++--------------
  1 file changed, 6 insertions(+), 14 deletions(-)
 
 diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
-index ec1a1633a..8de7b726d 100644
+index 3a88178cfbbcf7062a958c7de820247bc913ab33..54137a331ca9e752b02c0f16ae996094a6f2fafa 100644
 --- a/llvm/lib/Support/ErrorHandling.cpp
 +++ b/llvm/lib/Support/ErrorHandling.cpp
 @@ -22,7 +22,7 @@
@@ -37,7 +37,7 @@
    }
  
    // If we reached here, we are failing ungracefully. Run the interrupt handlers
-@@ -173,11 +165,11 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
+@@ -176,11 +168,11 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
    // llvm_unreachable is intended to be used to indicate "impossible"
    // situations, and not legitimate runtime errors.
    if (msg)
diff --git a/upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch b/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch
similarity index 75%
rename from upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch
rename to upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch
index 2f246a0..18ae0e7 100644
--- a/upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch
+++ b/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch
@@ -1,23 +1,23 @@
-From 7943842aea1a05a1dd2c2c753378af569c24293b Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 16:49:36 -0400
-Subject: [PATCH 21/28] Prefer wpi's fs.h
+Subject: [PATCH 20/31] Prefer wpi's fs.h
 
 ---
  llvm/include/llvm/Support/raw_ostream.h | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
 
 diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
-index bf5630ab5..256bcec25 100644
+index e7526e016a858ad728feb7cf1c5014b9691759d4..d56999186f719f8d91f3a047a19960caf62a066c 100644
 --- a/llvm/include/llvm/Support/raw_ostream.h
 +++ b/llvm/include/llvm/Support/raw_ostream.h
-@@ -27,18 +27,15 @@
+@@ -26,18 +26,15 @@
  #include <type_traits>
  #include <vector>
  
 -namespace llvm {
 -
--template <class T> class LLVM_NODISCARD Expected;
+-template <class T> class [[nodiscard]] Expected;
  
 -namespace sys {
  namespace fs {
diff --git a/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch
similarity index 81%
rename from upstream_utils/llvm_patches/0022-Remove-unused-functions.patch
rename to upstream_utils/llvm_patches/0021-Remove-unused-functions.patch
index 244148e..4f6ba93 100644
--- a/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch
+++ b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch
@@ -1,35 +1,20 @@
-From a172c93df929ac6c9f783fd5af1e4df3604c4c66 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 19:16:51 -0400
-Subject: [PATCH 22/28] Remove unused functions
+Subject: [PATCH 21/31] Remove unused functions
 
 ---
- llvm/include/llvm/Support/DJB.h         |  3 -
  llvm/include/llvm/Support/raw_ostream.h |  5 +-
  llvm/lib/Support/ErrorHandling.cpp      | 16 -----
- llvm/lib/Support/raw_ostream.cpp        | 49 +++++++--------
+ llvm/lib/Support/raw_ostream.cpp        | 47 +++++++-------
  llvm/unittests/ADT/SmallStringTest.cpp  | 81 -------------------------
- 5 files changed, 23 insertions(+), 131 deletions(-)
+ 4 files changed, 23 insertions(+), 126 deletions(-)
 
-diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h
-index 8737cd144..67b0ae91b 100644
---- a/llvm/include/llvm/Support/DJB.h
-+++ b/llvm/include/llvm/Support/DJB.h
-@@ -24,9 +24,6 @@ inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) {
-   return H;
- }
- 
--/// Computes the Bernstein hash after folding the input according to the Dwarf 5
--/// standard case folding rules.
--uint32_t caseFoldingDjbHash(StringRef Buffer, uint32_t H = 5381);
- } // namespace llvm
- 
- #endif // LLVM_SUPPORT_DJB_H
 diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
-index 256bcec25..9b3a87e1b 100644
+index d56999186f719f8d91f3a047a19960caf62a066c..9a9a1f688313a5784a58a70f2cb4cc0d6ec70e79 100644
 --- a/llvm/include/llvm/Support/raw_ostream.h
 +++ b/llvm/include/llvm/Support/raw_ostream.h
-@@ -71,7 +71,6 @@ private:
+@@ -70,7 +70,6 @@ private:
    /// for a \see write_impl() call to handle the data which has been put into
    /// this buffer.
    char *OutBufStart, *OutBufEnd, *OutBufCur;
@@ -37,7 +22,7 @@
  
    /// Optional stream this stream is tied to. If this stream is written to, the
    /// tied-to stream will be flushed first.
-@@ -304,9 +303,9 @@ public:
+@@ -317,9 +316,9 @@ public:
  
    // Enable or disable colors. Once enable_colors(false) is called,
    // changeColor() has no effect until enable_colors(true) is called.
@@ -50,10 +35,10 @@
    /// Tie this stream to the specified stream. Replaces any existing tied-to
    /// stream. Specifying a nullptr unties the stream.
 diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
-index 8de7b726d..bc08199a1 100644
+index 54137a331ca9e752b02c0f16ae996094a6f2fafa..e253d6f7a5ca3aee75823efdb9717dcd93fff5dc 100644
 --- a/llvm/lib/Support/ErrorHandling.cpp
 +++ b/llvm/lib/Support/ErrorHandling.cpp
-@@ -178,22 +178,6 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
+@@ -181,22 +181,6 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
  #endif
  }
  
@@ -77,10 +62,10 @@
  
  #include <winerror.h>
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index 878a3a5e9..632b52235 100644
+index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d78b6a5b02 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
-@@ -167,16 +167,6 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str,
+@@ -175,16 +175,6 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str,
    return *this;
  }
  
@@ -97,7 +82,7 @@
  void raw_ostream::flush_nonempty() {
    assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");
    size_t Length = OutBufCur - OutBufStart;
-@@ -321,15 +311,22 @@ static int getFD(std::string_view Filename, std::error_code &EC,
+@@ -327,15 +317,22 @@ static int getFD(std::string_view Filename, std::error_code &EC,
    if (Filename == "-") {
      EC = std::error_code();
      // Change stdout's text/binary mode based on the Flags.
@@ -125,7 +110,7 @@
    if (EC)
      return -1;
  
-@@ -389,12 +386,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
+@@ -395,12 +392,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
  
    // Get the starting position.
    off_t loc = ::lseek(FD, 0, SEEK_CUR);
@@ -139,7 +124,7 @@
  #else
    SupportsSeeking = !EC && loc != (off_t)-1;
  #endif
-@@ -407,10 +400,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
+@@ -413,10 +406,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
  raw_fd_ostream::~raw_fd_ostream() {
    if (FD >= 0) {
      flush();
@@ -152,7 +137,7 @@
    }
  
  #ifdef __MINGW32__
-@@ -505,7 +496,11 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
+@@ -511,7 +502,11 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
  
    do {
      size_t ChunkSize = std::min(Size, MaxWriteSize);
@@ -164,7 +149,7 @@
  
      if (ret < 0) {
        // If it's a recoverable error, swallow it and retry the write.
-@@ -540,8 +535,8 @@ void raw_fd_ostream::close() {
+@@ -554,8 +549,8 @@ void raw_fd_ostream::close() {
    assert(ShouldClose);
    ShouldClose = false;
    flush();
@@ -175,17 +160,8 @@
    FD = -1;
  }
  
-@@ -550,8 +545,6 @@ uint64_t raw_fd_ostream::seek(uint64_t off) {
-   flush();
- #ifdef _WIN32
-   pos = ::_lseeki64(FD, off, SEEK_SET);
--#elif defined(HAVE_LSEEK64)
--  pos = ::lseek64(FD, off, SEEK_SET);
- #else
-   pos = ::lseek(FD, off, SEEK_SET);
- #endif
 diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp
-index bee3875d1..87600ea47 100644
+index 6cf14700b34739420cd3dc4ff8a4c16ce162f715..87600ea4704bc98acab9085d16cfafd3d586714e 100644
 --- a/llvm/unittests/ADT/SmallStringTest.cpp
 +++ b/llvm/unittests/ADT/SmallStringTest.cpp
 @@ -129,23 +129,6 @@ TEST_F(SmallStringTest, StdStringConversion) {
@@ -239,12 +215,12 @@
 -}
 -
 -TEST_F(SmallStringTest, Comparisons) {
--  EXPECT_EQ(-1, SmallString<10>("aab").compare("aad"));
+-  EXPECT_GT( 0, SmallString<10>("aab").compare("aad"));
 -  EXPECT_EQ( 0, SmallString<10>("aab").compare("aab"));
--  EXPECT_EQ( 1, SmallString<10>("aab").compare("aaa"));
--  EXPECT_EQ(-1, SmallString<10>("aab").compare("aabb"));
--  EXPECT_EQ( 1, SmallString<10>("aab").compare("aa"));
--  EXPECT_EQ( 1, SmallString<10>("\xFF").compare("\1"));
+-  EXPECT_LT( 0, SmallString<10>("aab").compare("aaa"));
+-  EXPECT_GT( 0, SmallString<10>("aab").compare("aabb"));
+-  EXPECT_LT( 0, SmallString<10>("aab").compare("aa"));
+-  EXPECT_LT( 0, SmallString<10>("\xFF").compare("\1"));
 -
 -  EXPECT_EQ(-1, SmallString<10>("AaB").compare_insensitive("aAd"));
 -  EXPECT_EQ( 0, SmallString<10>("AaB").compare_insensitive("aab"));
diff --git a/upstream_utils/llvm_patches/0023-OS-specific-changes.patch b/upstream_utils/llvm_patches/0022-OS-specific-changes.patch
similarity index 70%
rename from upstream_utils/llvm_patches/0023-OS-specific-changes.patch
rename to upstream_utils/llvm_patches/0022-OS-specific-changes.patch
index ed58dac..4b3b3b7 100644
--- a/upstream_utils/llvm_patches/0023-OS-specific-changes.patch
+++ b/upstream_utils/llvm_patches/0022-OS-specific-changes.patch
@@ -1,17 +1,17 @@
-From ae08bb29b4d2a8ea15a4b82b909c0f4aee5e9060 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sun, 8 May 2022 19:30:43 -0400
-Subject: [PATCH 23/28] OS-specific changes
+Subject: [PATCH 22/31] OS-specific changes
 
 ---
- llvm/lib/Support/ErrorHandling.cpp | 13 +++++++------
- 1 file changed, 7 insertions(+), 6 deletions(-)
+ llvm/lib/Support/ErrorHandling.cpp | 16 +++++++---------
+ 1 file changed, 7 insertions(+), 9 deletions(-)
 
 diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
-index bc08199a1..839819094 100644
+index e253d6f7a5ca3aee75823efdb9717dcd93fff5dc..5c08e469e2e44b27e69f4aa974bc59deb8217c9b 100644
 --- a/llvm/lib/Support/ErrorHandling.cpp
 +++ b/llvm/lib/Support/ErrorHandling.cpp
-@@ -96,12 +96,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
+@@ -96,15 +96,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
      fmt::print(stderr, "LLVM ERROR: {}\n", Reason);
    }
  
@@ -20,12 +20,15 @@
 -  // files registered with RemoveFileOnSignal.
 -  sys::RunInterruptHandlers();
 -
--  abort();
+-  if (GenCrashDiag)
+-    abort();
+-  else
+-    exit(1);
 +  exit(1);
  }
  
  void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
-@@ -138,9 +133,15 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
+@@ -141,9 +133,15 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
    // an OOM to stderr and abort.
    const char *OOMMessage = "LLVM ERROR: out of memory\n";
    const char *Newline = "\n";
diff --git a/upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch b/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch
similarity index 75%
rename from upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch
rename to upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch
index 96088d2..d04e93b 100644
--- a/upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch
+++ b/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch
@@ -1,7 +1,7 @@
-From f58b9bad86f61c35cc530ff113ccbb13415261c8 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Mon, 9 May 2022 00:04:30 -0400
-Subject: [PATCH 24/28] Use SmallVector for UTF conversion
+Subject: [PATCH 23/31] Use SmallVector for UTF conversion
 
 ---
  llvm/include/llvm/Support/ConvertUTF.h    |  6 +++---
@@ -10,10 +10,10 @@
  3 files changed, 17 insertions(+), 17 deletions(-)
 
 diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h
-index b085c8a17..c82947006 100644
+index 72321022beb373945f7935ed72944fd68eb7d02f..5c8b966ce296699a0315d72cdfdcdb5af3d1d0b0 100644
 --- a/llvm/include/llvm/Support/ConvertUTF.h
 +++ b/llvm/include/llvm/Support/ConvertUTF.h
-@@ -213,7 +213,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result);
+@@ -233,7 +233,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result);
  * Converts a std::wstring to a UTF-8 encoded std::string.
  * \return true on success.
  */
@@ -22,7 +22,7 @@
  
  
  /**
-@@ -268,7 +268,7 @@ bool hasUTF16ByteOrderMark(span<const char> SrcBytes);
+@@ -288,7 +288,7 @@ bool hasUTF16ByteOrderMark(span<const char> SrcBytes);
   * \param [out] Out Converted UTF-8 is stored here on success.
   * \returns true on success
   */
@@ -31,7 +31,7 @@
  
  /**
  * Converts a UTF16 string into a UTF8 std::string.
-@@ -277,7 +277,7 @@ bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out);
+@@ -297,7 +297,7 @@ bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out);
  * \param [out] Out Converted UTF-8 is stored here on success.
  * \returns true on success
  */
@@ -39,13 +39,13 @@
 +bool convertUTF16ToUTF8String(span<const UTF16> Src, SmallVectorImpl<char> &Out);
  
  /**
-  * Converts a UTF-8 string into a UTF-16 string with native endianness.
+  * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
 diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp
-index cff30f16c..d3689d92a 100644
+index 34054140489e4d536ace4650207c783d669d850e..0b62315e3461ff60a8313e73b4142b1f83e36ca7 100644
 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp
 +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp
-@@ -84,7 +84,7 @@ bool hasUTF16ByteOrderMark(span<const char> S) {
-            (S[0] == '\xfe' && S[1] == '\xff')));
+@@ -82,7 +82,7 @@ bool hasUTF16ByteOrderMark(span<const char> S) {
+                             (S[0] == '\xfe' && S[1] == '\xff')));
  }
  
 -bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out) {
@@ -53,16 +53,16 @@
    assert(Out.empty());
  
    // Error out on an uneven byte count.
-@@ -135,7 +135,7 @@ bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out) {
+@@ -133,7 +133,7 @@ bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out) {
    return true;
  }
  
--bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out)
-+bool convertUTF16ToUTF8String(span<const UTF16> Src, SmallVectorImpl<char> &Out)
- {
+-bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out) {
++bool convertUTF16ToUTF8String(span<const UTF16> Src, SmallVectorImpl<char> &Out) {
    return convertUTF16ToUTF8String(
        span<const char>(reinterpret_cast<const char *>(Src.data()),
-@@ -213,7 +213,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result) {
+                            Src.size() * sizeof(UTF16)),
+@@ -269,7 +269,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result) {
    return ConvertUTF8toWide(std::string_view(Source), Result);
  }
  
@@ -72,10 +72,10 @@
      const UTF8 *Start = reinterpret_cast<const UTF8 *>(Source.data());
      const UTF8 *End =
 diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp
-index 2fee8ad5c..7d7650b1c 100644
+index 77e70a46d3621ecfaed923d87256184addfda721..eb17a06c4369c9486c57b61f519a7429d9ef3d80 100644
 --- a/llvm/unittests/Support/ConvertUTFTest.cpp
 +++ b/llvm/unittests/Support/ConvertUTFTest.cpp
-@@ -19,22 +19,22 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
+@@ -19,11 +19,11 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
    // Src is the look of disapproval.
    alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
    span<const char> Ref(Src, sizeof(Src) - 1);
@@ -88,7 +88,8 @@
 +  EXPECT_EQ(Expected, std::string{Result});
  }
  
- TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
+ TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+@@ -42,11 +42,11 @@ TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
    // Src is the look of disapproval.
    alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
    span<const char> Ref(Src, sizeof(Src) - 1);
@@ -101,8 +102,8 @@
 +  EXPECT_EQ(Expected, std::string{Result});
  }
  
- TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
-@@ -51,16 +51,16 @@ TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
+ TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+@@ -75,17 +75,17 @@ TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
  }
  
  TEST(ConvertUTFTest, OddLengthInput) {
@@ -115,14 +116,15 @@
  TEST(ConvertUTFTest, Empty) {
 -  std::string Result;
 +  SmallString<20> Result;
-   bool Success = convertUTF16ToUTF8String(span<const char>(), Result);
+   bool Success =
+       convertUTF16ToUTF8String(span<const char>(), Result);
    EXPECT_TRUE(Success);
 -  EXPECT_TRUE(Result.empty());
 +  EXPECT_TRUE(std::string{Result}.empty());
  }
  
  TEST(ConvertUTFTest, HasUTF16BOM) {
-@@ -83,11 +83,11 @@ TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
+@@ -108,11 +108,11 @@ TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
    // Src is the look of disapproval.
    alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
    span<const UTF16> SrcRef((const UTF16 *)Src, 4);
@@ -136,7 +138,7 @@
  }
  
  TEST(ConvertUTFTest, ConvertUTF8toWide) {
-@@ -107,11 +107,11 @@ TEST(ConvertUTFTest, ConvertUTF8toWide) {
+@@ -132,11 +132,11 @@ TEST(ConvertUTFTest, ConvertUTF8toWide) {
  TEST(ConvertUTFTest, convertWideToUTF8) {
    // Src is the look of disapproval.
    static const wchar_t Src[] = L"\x0ca0_\x0ca0";
diff --git a/upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch
similarity index 78%
rename from upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch
rename to upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch
index 36a884c..f5dce6b 100644
--- a/upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch
+++ b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch
@@ -1,7 +1,7 @@
-From 35b1a8382240732065790c88a0c515701c1a2beb Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Thu, 19 May 2022 00:58:36 -0400
-Subject: [PATCH 25/28] Prefer to use static pointers in raw_ostream
+Subject: [PATCH 24/31] Prefer to use static pointers in raw_ostream
 
 See #1401
 ---
@@ -9,10 +9,10 @@
  1 file changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
-index 632b52235..a703a75ed 100644
+index f9928ac969932b6baea60a80750477d78b6a5b02..1de34976844d500970b833fca35324e2948733b7 100644
 --- a/llvm/lib/Support/raw_ostream.cpp
 +++ b/llvm/lib/Support/raw_ostream.cpp
-@@ -599,15 +599,15 @@ void raw_fd_ostream::anchor() {}
+@@ -613,15 +613,15 @@ void raw_fd_ostream::anchor() {}
  raw_fd_ostream &llvm::outs() {
    // Set buffer settings to model stdout behavior.
    std::error_code EC;
diff --git a/upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch
similarity index 79%
rename from upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch
rename to upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch
index 79e0e7d..acbded1 100644
--- a/upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch
+++ b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch
@@ -1,14 +1,14 @@
-From 34f44d312c918b3b5dd69fc689ec0b628dc712f9 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Thu, 19 May 2022 01:12:41 -0400
-Subject: [PATCH 26/28] constexpr endian byte swap
+Subject: [PATCH 25/31] constexpr endian byte swap
 
 ---
  llvm/include/llvm/Support/Endian.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
 
 diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h
-index 5e7c1e961..2e883ff05 100644
+index 5e7c1e961b9d1e0fd6bcd0c923f678a5e1596860..2e883ff05b7e287151b6031f66d3b4aefd1bf297 100644
 --- a/llvm/include/llvm/Support/Endian.h
 +++ b/llvm/include/llvm/Support/Endian.h
 @@ -55,7 +55,9 @@ inline value_type byte_swap(value_type value, endianness endian) {
diff --git a/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch b/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch
similarity index 91%
rename from upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch
rename to upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch
index 9f192a1..efa9e6c 100644
--- a/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch
+++ b/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch
@@ -1,17 +1,17 @@
-From 8f51777a3117a7b010a4cfb2ded1f5d226466f34 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Tyler Veness <calcmogul@gmail.com>
 Date: Wed, 10 Aug 2022 17:07:52 -0700
-Subject: [PATCH 27/28] Copy type traits from STLExtras.h into PointerUnion.h
+Subject: [PATCH 26/31] Copy type traits from STLExtras.h into PointerUnion.h
 
 ---
  llvm/include/llvm/ADT/PointerUnion.h | 46 ++++++++++++++++++++++++++++
  1 file changed, 46 insertions(+)
 
 diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
-index 1d4cc747c..7d090da59 100644
+index 8ac68dbc0a791b8ac0e0ca865e69024cb642aa70..273ba02934bd405ea4f1b911ebb58f7080837ff0 100644
 --- a/llvm/include/llvm/ADT/PointerUnion.h
 +++ b/llvm/include/llvm/ADT/PointerUnion.h
-@@ -22,9 +22,55 @@
+@@ -23,9 +23,55 @@
  #include <cassert>
  #include <cstddef>
  #include <cstdint>
diff --git a/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch b/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch
similarity index 74%
rename from upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch
rename to upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch
index 5c847e1..977dff3 100644
--- a/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch
+++ b/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch
@@ -1,17 +1,17 @@
-From 498e56e09e8f264978831519ff9c8afa701bf208 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Tyler Veness <calcmogul@gmail.com>
 Date: Wed, 10 Aug 2022 22:35:00 -0700
-Subject: [PATCH 28/28] Remove StringMap test for llvm::sort()
+Subject: [PATCH 27/31] Remove StringMap test for llvm::sort()
 
 ---
  llvm/unittests/ADT/StringMapTest.cpp | 14 --------------
  1 file changed, 14 deletions(-)
 
 diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
-index de6daf3da..ca41631cc 100644
+index 6b6cf564909f329c220eb225f3b7af6c35301029..0d83669a580408e925ec6308410ebe7c01b48b12 100644
 --- a/llvm/unittests/ADT/StringMapTest.cpp
 +++ b/llvm/unittests/ADT/StringMapTest.cpp
-@@ -308,20 +308,6 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
+@@ -322,20 +322,6 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
    EXPECT_EQ(0, try1.first->second.copy);
  }
  
diff --git a/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch b/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch
new file mode 100644
index 0000000..2492883
--- /dev/null
+++ b/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch
@@ -0,0 +1,22 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Leander Schulten <Leander.Schulten@rwth-aachen.de>
+Date: Mon, 10 Jul 2023 00:53:43 +0200
+Subject: [PATCH 28/31] Unused variable in release mode
+
+---
+ llvm/include/llvm/ADT/DenseMap.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
+index 108193f04486425f3b7f039cd9d2004be6facafb..e9bd3bfa4a6fe0fa26ff20069bbadc816c8baa65 100644
+--- a/llvm/include/llvm/ADT/DenseMap.h
++++ b/llvm/include/llvm/ADT/DenseMap.h
+@@ -124,7 +124,7 @@ public:
+       for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P)
+         P->getFirst() = EmptyKey;
+     } else {
+-      unsigned NumEntries = getNumEntries();
++      [[maybe_unused]] unsigned NumEntries = getNumEntries();
+       for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P) {
+         if (!KeyInfoT::isEqual(P->getFirst(), EmptyKey)) {
+           if (!KeyInfoT::isEqual(P->getFirst(), TombstoneKey)) {
diff --git a/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch
new file mode 100644
index 0000000..fad61d3
--- /dev/null
+++ b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch
@@ -0,0 +1,509 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Tue, 11 Jul 2023 22:56:09 -0700
+Subject: [PATCH 29/31] Use C++20 <bit> header
+
+---
+ llvm/include/llvm/ADT/DenseMap.h       |   3 +-
+ llvm/include/llvm/ADT/Hashing.h        |  35 +--
+ llvm/include/llvm/ADT/bit.h            | 287 -------------------------
+ llvm/include/llvm/Support/MathExtras.h |  21 +-
+ 4 files changed, 31 insertions(+), 315 deletions(-)
+
+diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
+index e9bd3bfa4a6fe0fa26ff20069bbadc816c8baa65..93b50c9e53af4ea3af5fd0329a8a03bdce659e9d 100644
+--- a/llvm/include/llvm/ADT/DenseMap.h
++++ b/llvm/include/llvm/ADT/DenseMap.h
+@@ -23,6 +23,7 @@
+ #include "llvm/Support/ReverseIteration.h"
+ #include "llvm/Support/type_traits.h"
+ #include <algorithm>
++#include <bit>
+ #include <cassert>
+ #include <cstddef>
+ #include <cstring>
+@@ -933,7 +934,7 @@ class SmallDenseMap
+ public:
+   explicit SmallDenseMap(unsigned NumInitBuckets = 0) {
+     if (NumInitBuckets > InlineBuckets)
+-      NumInitBuckets = llvm::bit_ceil(NumInitBuckets);
++      NumInitBuckets = std::bit_ceil(NumInitBuckets);
+     init(NumInitBuckets);
+   }
+ 
+diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
+index 781bdb7416392e3f60a1ac3a38fbcf5324b5395f..28934add722f518ae1e9cb9c4a23d2212a47cbdf 100644
+--- a/llvm/include/llvm/ADT/Hashing.h
++++ b/llvm/include/llvm/ADT/Hashing.h
+@@ -49,6 +49,7 @@
+ #include "llvm/Support/SwapByteOrder.h"
+ #include "llvm/Support/type_traits.h"
+ #include <algorithm>
++#include <bit>
+ #include <cassert>
+ #include <cstring>
+ #include <optional>
+@@ -224,30 +225,30 @@ inline uint64_t hash_17to32_bytes(const char *s, size_t len, uint64_t seed) {
+   uint64_t b = fetch64(s + 8);
+   uint64_t c = fetch64(s + len - 8) * k2;
+   uint64_t d = fetch64(s + len - 16) * k0;
+-  return hash_16_bytes(llvm::rotr<uint64_t>(a - b, 43) +
+-                           llvm::rotr<uint64_t>(c ^ seed, 30) + d,
+-                       a + llvm::rotr<uint64_t>(b ^ k3, 20) - c + len + seed);
++  return hash_16_bytes(std::rotr<uint64_t>(a - b, 43) +
++                           std::rotr<uint64_t>(c ^ seed, 30) + d,
++                       a + std::rotr<uint64_t>(b ^ k3, 20) - c + len + seed);
+ }
+ 
+ inline uint64_t hash_33to64_bytes(const char *s, size_t len, uint64_t seed) {
+   uint64_t z = fetch64(s + 24);
+   uint64_t a = fetch64(s) + (len + fetch64(s + len - 16)) * k0;
+-  uint64_t b = llvm::rotr<uint64_t>(a + z, 52);
+-  uint64_t c = llvm::rotr<uint64_t>(a, 37);
++  uint64_t b = std::rotr<uint64_t>(a + z, 52);
++  uint64_t c = std::rotr<uint64_t>(a, 37);
+   a += fetch64(s + 8);
+-  c += llvm::rotr<uint64_t>(a, 7);
++  c += std::rotr<uint64_t>(a, 7);
+   a += fetch64(s + 16);
+   uint64_t vf = a + z;
+-  uint64_t vs = b + llvm::rotr<uint64_t>(a, 31) + c;
++  uint64_t vs = b + std::rotr<uint64_t>(a, 31) + c;
+   a = fetch64(s + 16) + fetch64(s + len - 32);
+   z = fetch64(s + len - 8);
+-  b = llvm::rotr<uint64_t>(a + z, 52);
+-  c = llvm::rotr<uint64_t>(a, 37);
++  b = std::rotr<uint64_t>(a + z, 52);
++  c = std::rotr<uint64_t>(a, 37);
+   a += fetch64(s + len - 24);
+-  c += llvm::rotr<uint64_t>(a, 7);
++  c += std::rotr<uint64_t>(a, 7);
+   a += fetch64(s + len - 16);
+   uint64_t wf = a + z;
+-  uint64_t ws = b + llvm::rotr<uint64_t>(a, 31) + c;
++  uint64_t ws = b + std::rotr<uint64_t>(a, 31) + c;
+   uint64_t r = shift_mix((vf + ws) * k2 + (wf + vs) * k0);
+   return shift_mix((seed ^ (r * k0)) + vs) * k2;
+ }
+@@ -280,7 +281,7 @@ struct hash_state {
+     hash_state state = {0,
+                         seed,
+                         hash_16_bytes(seed, k1),
+-                        llvm::rotr<uint64_t>(seed ^ k1, 49),
++                        std::rotr<uint64_t>(seed ^ k1, 49),
+                         seed * k1,
+                         shift_mix(seed),
+                         0};
+@@ -294,10 +295,10 @@ struct hash_state {
+   static void mix_32_bytes(const char *s, uint64_t &a, uint64_t &b) {
+     a += fetch64(s);
+     uint64_t c = fetch64(s + 24);
+-    b = llvm::rotr<uint64_t>(b + a + c, 21);
++    b = std::rotr<uint64_t>(b + a + c, 21);
+     uint64_t d = a;
+     a += fetch64(s + 8) + fetch64(s + 16);
+-    b += llvm::rotr<uint64_t>(a, 44) + d;
++    b += std::rotr<uint64_t>(a, 44) + d;
+     a += c;
+   }
+ 
+@@ -305,11 +306,11 @@ struct hash_state {
+   /// We mix all 64 bytes even when the chunk length is smaller, but we
+   /// record the actual length.
+   void mix(const char *s) {
+-    h0 = llvm::rotr<uint64_t>(h0 + h1 + h3 + fetch64(s + 8), 37) * k1;
+-    h1 = llvm::rotr<uint64_t>(h1 + h4 + fetch64(s + 48), 42) * k1;
++    h0 = std::rotr<uint64_t>(h0 + h1 + h3 + fetch64(s + 8), 37) * k1;
++    h1 = std::rotr<uint64_t>(h1 + h4 + fetch64(s + 48), 42) * k1;
+     h0 ^= h6;
+     h1 += h3 + fetch64(s + 40);
+-    h2 = llvm::rotr<uint64_t>(h2 + h5, 33) * k1;
++    h2 = std::rotr<uint64_t>(h2 + h5, 33) * k1;
+     h3 = h4 * k1;
+     h4 = h0 + h5;
+     mix_32_bytes(s, h3, h4);
+diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
+index 2840c5f608d3ea896e1867dd4710685da9572f2d..0a4a3634820efbc0a8ca675e3ad7c98469260d0b 100644
+--- a/llvm/include/llvm/ADT/bit.h
++++ b/llvm/include/llvm/ADT/bit.h
+@@ -27,18 +27,6 @@
+ #include <cstdlib>  // for _byteswap_{ushort,ulong,uint64}
+ #endif
+ 
+-#ifdef _MSC_VER
+-// Declare these intrinsics manually rather including intrin.h. It's very
+-// expensive, and bit.h is popular via MathExtras.h.
+-// #include <intrin.h>
+-extern "C" {
+-unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);
+-unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+-unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask);
+-unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
+-}
+-#endif
+-
+ namespace llvm {
+ 
+ // This implementation of bit_cast is different from the C++20 one in two ways:
+@@ -106,281 +94,6 @@ template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
+   }
+ }
+ 
+-template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>>
+-[[nodiscard]] constexpr inline bool has_single_bit(T Value) noexcept {
+-  return (Value != 0) && ((Value & (Value - 1)) == 0);
+-}
+-
+-namespace detail {
+-template <typename T, std::size_t SizeOfT> struct TrailingZerosCounter {
+-  static unsigned count(T Val) {
+-    if (!Val)
+-      return std::numeric_limits<T>::digits;
+-    if (Val & 0x1)
+-      return 0;
+-
+-    // Bisection method.
+-    unsigned ZeroBits = 0;
+-    T Shift = std::numeric_limits<T>::digits >> 1;
+-    T Mask = std::numeric_limits<T>::max() >> Shift;
+-    while (Shift) {
+-      if ((Val & Mask) == 0) {
+-        Val >>= Shift;
+-        ZeroBits |= Shift;
+-      }
+-      Shift >>= 1;
+-      Mask >>= Shift;
+-    }
+-    return ZeroBits;
+-  }
+-};
+-
+-#if defined(__GNUC__) || defined(_MSC_VER)
+-template <typename T> struct TrailingZerosCounter<T, 4> {
+-  static unsigned count(T Val) {
+-    if (Val == 0)
+-      return 32;
+-
+-#if __has_builtin(__builtin_ctz) || defined(__GNUC__)
+-    return __builtin_ctz(Val);
+-#elif defined(_MSC_VER)
+-    unsigned long Index;
+-    _BitScanForward(&Index, Val);
+-    return Index;
+-#endif
+-  }
+-};
+-
+-#if !defined(_MSC_VER) || defined(_M_X64)
+-template <typename T> struct TrailingZerosCounter<T, 8> {
+-  static unsigned count(T Val) {
+-    if (Val == 0)
+-      return 64;
+-
+-#if __has_builtin(__builtin_ctzll) || defined(__GNUC__)
+-    return __builtin_ctzll(Val);
+-#elif defined(_MSC_VER)
+-    unsigned long Index;
+-    _BitScanForward64(&Index, Val);
+-    return Index;
+-#endif
+-  }
+-};
+-#endif
+-#endif
+-} // namespace detail
+-
+-/// Count number of 0's from the least significant bit to the most
+-///   stopping at the first 1.
+-///
+-/// Only unsigned integral types are allowed.
+-///
+-/// Returns std::numeric_limits<T>::digits on an input of 0.
+-template <typename T> [[nodiscard]] int countr_zero(T Val) {
+-  static_assert(std::is_unsigned_v<T>,
+-                "Only unsigned integral types are allowed.");
+-  return llvm::detail::TrailingZerosCounter<T, sizeof(T)>::count(Val);
+-}
+-
+-namespace detail {
+-template <typename T, std::size_t SizeOfT> struct LeadingZerosCounter {
+-  static unsigned count(T Val) {
+-    if (!Val)
+-      return std::numeric_limits<T>::digits;
+-
+-    // Bisection method.
+-    unsigned ZeroBits = 0;
+-    for (T Shift = std::numeric_limits<T>::digits >> 1; Shift; Shift >>= 1) {
+-      T Tmp = Val >> Shift;
+-      if (Tmp)
+-        Val = Tmp;
+-      else
+-        ZeroBits |= Shift;
+-    }
+-    return ZeroBits;
+-  }
+-};
+-
+-#if defined(__GNUC__) || defined(_MSC_VER)
+-template <typename T> struct LeadingZerosCounter<T, 4> {
+-  static unsigned count(T Val) {
+-    if (Val == 0)
+-      return 32;
+-
+-#if __has_builtin(__builtin_clz) || defined(__GNUC__)
+-    return __builtin_clz(Val);
+-#elif defined(_MSC_VER)
+-    unsigned long Index;
+-    _BitScanReverse(&Index, Val);
+-    return Index ^ 31;
+-#endif
+-  }
+-};
+-
+-#if !defined(_MSC_VER) || defined(_M_X64)
+-template <typename T> struct LeadingZerosCounter<T, 8> {
+-  static unsigned count(T Val) {
+-    if (Val == 0)
+-      return 64;
+-
+-#if __has_builtin(__builtin_clzll) || defined(__GNUC__)
+-    return __builtin_clzll(Val);
+-#elif defined(_MSC_VER)
+-    unsigned long Index;
+-    _BitScanReverse64(&Index, Val);
+-    return Index ^ 63;
+-#endif
+-  }
+-};
+-#endif
+-#endif
+-} // namespace detail
+-
+-/// Count number of 0's from the most significant bit to the least
+-///   stopping at the first 1.
+-///
+-/// Only unsigned integral types are allowed.
+-///
+-/// Returns std::numeric_limits<T>::digits on an input of 0.
+-template <typename T> [[nodiscard]] int countl_zero(T Val) {
+-  static_assert(std::is_unsigned_v<T>,
+-                "Only unsigned integral types are allowed.");
+-  return llvm::detail::LeadingZerosCounter<T, sizeof(T)>::count(Val);
+-}
+-
+-/// Count the number of ones from the most significant bit to the first
+-/// zero bit.
+-///
+-/// Ex. countl_one(0xFF0FFF00) == 8.
+-/// Only unsigned integral types are allowed.
+-///
+-/// Returns std::numeric_limits<T>::digits on an input of all ones.
+-template <typename T> [[nodiscard]] int countl_one(T Value) {
+-  static_assert(std::is_unsigned_v<T>,
+-                "Only unsigned integral types are allowed.");
+-  return llvm::countl_zero<T>(~Value);
+-}
+-
+-/// Count the number of ones from the least significant bit to the first
+-/// zero bit.
+-///
+-/// Ex. countr_one(0x00FF00FF) == 8.
+-/// Only unsigned integral types are allowed.
+-///
+-/// Returns std::numeric_limits<T>::digits on an input of all ones.
+-template <typename T> [[nodiscard]] int countr_one(T Value) {
+-  static_assert(std::is_unsigned_v<T>,
+-                "Only unsigned integral types are allowed.");
+-  return llvm::countr_zero<T>(~Value);
+-}
+-
+-/// Returns the number of bits needed to represent Value if Value is nonzero.
+-/// Returns 0 otherwise.
+-///
+-/// Ex. bit_width(5) == 3.
+-template <typename T> [[nodiscard]] int bit_width(T Value) {
+-  static_assert(std::is_unsigned_v<T>,
+-                "Only unsigned integral types are allowed.");
+-  return std::numeric_limits<T>::digits - llvm::countl_zero(Value);
+-}
+-
+-/// Returns the largest integral power of two no greater than Value if Value is
+-/// nonzero.  Returns 0 otherwise.
+-///
+-/// Ex. bit_floor(5) == 4.
+-template <typename T> [[nodiscard]] T bit_floor(T Value) {
+-  static_assert(std::is_unsigned_v<T>,
+-                "Only unsigned integral types are allowed.");
+-  if (!Value)
+-    return 0;
+-  return T(1) << (llvm::bit_width(Value) - 1);
+-}
+-
+-/// 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]] T bit_ceil(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<T>(Value - 1u);
+-}
+-
+-namespace detail {
+-template <typename T, std::size_t SizeOfT> struct PopulationCounter {
+-  static int count(T Value) {
+-    // Generic version, forward to 32 bits.
+-    static_assert(SizeOfT <= 4, "Not implemented!");
+-#if defined(__GNUC__)
+-    return (int)__builtin_popcount(Value);
+-#else
+-    uint32_t v = Value;
+-    v = v - ((v >> 1) & 0x55555555);
+-    v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
+-    return int(((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24);
+-#endif
+-  }
+-};
+-
+-template <typename T> struct PopulationCounter<T, 8> {
+-  static int count(T Value) {
+-#if defined(__GNUC__)
+-    return (int)__builtin_popcountll(Value);
+-#else
+-    uint64_t v = Value;
+-    v = v - ((v >> 1) & 0x5555555555555555ULL);
+-    v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
+-    v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
+-    return int((uint64_t)(v * 0x0101010101010101ULL) >> 56);
+-#endif
+-  }
+-};
+-} // namespace detail
+-
+-/// Count the number of set bits in a value.
+-/// Ex. popcount(0xF000F000) = 8
+-/// Returns 0 if the word is zero.
+-template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>>
+-[[nodiscard]] inline int popcount(T Value) noexcept {
+-  return detail::PopulationCounter<T, sizeof(T)>::count(Value);
+-}
+-
+-// 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);
+-
+-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;
+-
+-  R = R % N;
+-  if (!R)
+-    return V;
+-
+-  if (R < 0)
+-    return llvm::rotr(V, -R);
+-
+-  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;
+-
+-  R = R % N;
+-  if (!R)
+-    return V;
+-
+-  if (R < 0)
+-    return llvm::rotl(V, -R);
+-
+-  return (V >> R) | (V << (N - R));
+-}
+-
+ } // namespace llvm
+ 
+ #endif
+diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
+index b82d9883c41008dcbbd933709c6e854ad74c5b58..5f034b694989d8ef24e0b249abd12a5c20146b97 100644
+--- a/llvm/include/llvm/Support/MathExtras.h
++++ b/llvm/include/llvm/Support/MathExtras.h
+@@ -15,6 +15,7 @@
+ 
+ #include "llvm/ADT/bit.h"
+ #include "llvm/Support/Compiler.h"
++#include <bit>
+ #include <cassert>
+ #include <climits>
+ #include <cstdint>
+@@ -235,12 +236,12 @@ constexpr inline bool isShiftedMask_64(uint64_t Value) {
+ /// Return true if the argument is a power of two > 0.
+ /// Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
+ constexpr inline bool isPowerOf2_32(uint32_t Value) {
+-  return llvm::has_single_bit(Value);
++  return std::has_single_bit(Value);
+ }
+ 
+ /// Return true if the argument is a power of two > 0 (64 bit edition.)
+ constexpr inline bool isPowerOf2_64(uint64_t Value) {
+-  return llvm::has_single_bit(Value);
++  return std::has_single_bit(Value);
+ }
+ 
+ /// Return true if the argument contains a non-empty sequence of ones with the
+@@ -252,8 +253,8 @@ inline bool isShiftedMask_32(uint32_t Value, unsigned &MaskIdx,
+                              unsigned &MaskLen) {
+   if (!isShiftedMask_32(Value))
+     return false;
+-  MaskIdx = llvm::countr_zero(Value);
+-  MaskLen = llvm::popcount(Value);
++  MaskIdx = std::countr_zero(Value);
++  MaskLen = std::popcount(Value);
+   return true;
+ }
+ 
+@@ -265,8 +266,8 @@ inline bool isShiftedMask_64(uint64_t Value, unsigned &MaskIdx,
+                              unsigned &MaskLen) {
+   if (!isShiftedMask_64(Value))
+     return false;
+-  MaskIdx = llvm::countr_zero(Value);
+-  MaskLen = llvm::popcount(Value);
++  MaskIdx = std::countr_zero(Value);
++  MaskLen = std::popcount(Value);
+   return true;
+ }
+ 
+@@ -284,26 +285,26 @@ template <> constexpr inline 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) {
+-  return static_cast<unsigned>(31 - llvm::countl_zero(Value));
++  return static_cast<unsigned>(31 - std::countl_zero(Value));
+ }
+ 
+ /// Return the floor log base 2 of the specified value, -1 if the value is zero.
+ /// (64 bit edition.)
+ inline unsigned Log2_64(uint64_t Value) {
+-  return static_cast<unsigned>(63 - llvm::countl_zero(Value));
++  return static_cast<unsigned>(63 - std::countl_zero(Value));
+ }
+ 
+ /// Return the ceil log base 2 of the specified value, 32 if the value is zero.
+ /// (32 bit edition).
+ /// Ex. Log2_32_Ceil(32) == 5, Log2_32_Ceil(1) == 0, Log2_32_Ceil(6) == 3
+ inline unsigned Log2_32_Ceil(uint32_t Value) {
+-  return static_cast<unsigned>(32 - llvm::countl_zero(Value - 1));
++  return static_cast<unsigned>(32 - std::countl_zero(Value - 1));
+ }
+ 
+ /// Return the ceil log base 2 of the specified value, 64 if the value is zero.
+ /// (64 bit edition.)
+ inline unsigned Log2_64_Ceil(uint64_t Value) {
+-  return static_cast<unsigned>(64 - llvm::countl_zero(Value - 1));
++  return static_cast<unsigned>(64 - std::countl_zero(Value - 1));
+ }
+ 
+ /// A and B are either alignments or offsets. Return the minimum alignment that
diff --git a/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch b/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch
new file mode 100644
index 0000000..8ee47b8
--- /dev/null
+++ b/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch
@@ -0,0 +1,26 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Sun, 30 Jul 2023 14:17:37 -0700
+Subject: [PATCH 30/31] Remove DenseMap GTest printer test
+
+LLVM modifies internal GTest headers to support it, which we can't do.
+---
+ llvm/unittests/ADT/DenseMapTest.cpp | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
+index 1f232d3046292c0da940ba4bef7d50604556e4c2..8d90d5afea79c619590cc32539e5124d02b1349c 100644
+--- a/llvm/unittests/ADT/DenseMapTest.cpp
++++ b/llvm/unittests/ADT/DenseMapTest.cpp
+@@ -737,11 +737,4 @@ TEST(DenseMapCustomTest, VariantSupport) {
+   EXPECT_FALSE(DenseMapInfo<variant>::isEqual(Keys[2], Keys[2]));
+ }
+ 
+-// Test that gTest prints map entries as pairs instead of opaque objects.
+-// See third-party/unittest/googletest/internal/custom/gtest-printers.h
+-TEST(DenseMapCustomTest, PairPrinting) {
+-  DenseMap<int, std::string_view> Map = {{1, "one"}, {2, "two"}};
+-  EXPECT_EQ(R"({ (1, "one"), (2, "two") })", ::testing::PrintToString(Map));
+-}
+-
+ } // namespace
diff --git a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch
new file mode 100644
index 0000000..e074f27
--- /dev/null
+++ b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Veness <calcmogul@gmail.com>
+Date: Fri, 15 Sep 2023 18:26:50 -0700
+Subject: [PATCH 31/31] Replace deprecated std::aligned_storage_t
+
+---
+ 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 1daeae915eb506b32a2d1296d2f0fe4e6dab606e..2e60e34d69914bd9b2197fc0a0e75a8e025674b2 100644
+--- a/llvm/include/llvm/ADT/FunctionExtras.h
++++ b/llvm/include/llvm/ADT/FunctionExtras.h
+@@ -37,6 +37,7 @@
+ #include "llvm/ADT/STLForwardCompat.h"
+ #include "llvm/Support/MemAlloc.h"
+ #include "llvm/Support/type_traits.h"
++#include <cstddef>
+ #include <cstring>
+ #include <memory>
+ #include <type_traits>
+@@ -167,8 +168,7 @@ protected:
+     // 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 *)>
+-        InlineStorage;
++    alignas(void*) mutable std::byte InlineStorage[InlineStorageSize];
+   } StorageUnion;
+ 
+   // A compressed pointer to either our dispatching callback or our table of
diff --git a/upstream_utils/llvm_patches/0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch b/upstream_utils/llvm_patches/0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch
new file mode 100644
index 0000000..52956f9
--- /dev/null
+++ b/upstream_utils/llvm_patches/0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch
@@ -0,0 +1,26 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Benjamin Hall <bhallctre@gmail.com>
+Date: Mon, 23 Oct 2023 21:36:40 -0400
+Subject: [PATCH 32/32] Fix compilation of MathExtras.h on Windows with /sdl
+
+See https://github.com/llvm/llvm-project/pull/68978
+---
+ llvm/include/llvm/Support/MathExtras.h | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
+index 5f034b694989d8ef24e0b249abd12a5c20146b97..03db6e4d92cb3b62ac3d8b3cbd97783817c6326b 100644
+--- a/llvm/include/llvm/Support/MathExtras.h
++++ b/llvm/include/llvm/Support/MathExtras.h
+@@ -356,7 +356,10 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) {
+ inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) {
+   assert(Align != 0 && (Align & (Align - 1)) == 0 &&
+          "Align must be a power of 2");
+-  return (Value + Align - 1) & -Align;
++  // Replace unary minus to avoid compilation error on Windows:
++  // "unary minus operator applied to unsigned type, result still unsigned"
++  uint64_t negAlign = (~Align) + 1;
++  return (Value + Align - 1) & negAlign;
+ }
+ 
+ /// If non-zero \p Skew is specified, the return value will be a minimal integer
diff --git a/upstream_utils/llvm_patches/0033-raw_ostream-Add-SetNumBytesInBuffer.patch b/upstream_utils/llvm_patches/0033-raw_ostream-Add-SetNumBytesInBuffer.patch
new file mode 100644
index 0000000..a36cfc6
--- /dev/null
+++ b/upstream_utils/llvm_patches/0033-raw_ostream-Add-SetNumBytesInBuffer.patch
@@ -0,0 +1,25 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sun, 29 Oct 2023 23:00:08 -0700
+Subject: [PATCH 33/33] raw_ostream: Add SetNumBytesInBuffer
+
+---
+ llvm/include/llvm/Support/raw_ostream.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
+index 9a9a1f688313a5784a58a70f2cb4cc0d6ec70e79..39f98e4e7696e28587779e90a03995463767b02d 100644
+--- a/llvm/include/llvm/Support/raw_ostream.h
++++ b/llvm/include/llvm/Support/raw_ostream.h
+@@ -356,6 +356,11 @@ protected:
+     SetBufferAndMode(BufferStart, Size, BufferKind::ExternalBuffer);
+   }
+ 
++  /// Force-set the number of bytes in the raw_ostream buffer.
++  void SetNumBytesInBuffer(size_t Size) {
++    OutBufCur = OutBufStart + Size;
++  }
++
+   /// Return an efficient buffer size for the underlying output mechanism.
+   virtual size_t preferred_buffer_size() const;
+ 
diff --git a/upstream_utils/mpack_patches/0001-Don-t-emit-inline-defs.patch b/upstream_utils/mpack_patches/0001-Don-t-emit-inline-defs.patch
index a899a5e..0937d13 100644
--- a/upstream_utils/mpack_patches/0001-Don-t-emit-inline-defs.patch
+++ b/upstream_utils/mpack_patches/0001-Don-t-emit-inline-defs.patch
@@ -1,14 +1,14 @@
-From 05864e768ca1458c1e24f433d091306a7d47562b Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sat, 29 Oct 2022 12:09:03 -0400
-Subject: [PATCH 1/3] Don't emit inline defs
+Subject: [PATCH 1/4] Don't emit inline defs
 
 ---
  src/mpack/mpack-platform.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/mpack/mpack-platform.c b/src/mpack/mpack-platform.c
-index 6599e1f..d4a2fa3 100644
+index 6599e1fd444c381b9b72b20601c22488d7266b1f..d4a2fa3198f39fc964baeed4d15f6fd89affc24c 100644
 --- a/src/mpack/mpack-platform.c
 +++ b/src/mpack/mpack-platform.c
 @@ -24,7 +24,7 @@
diff --git a/upstream_utils/mpack_patches/0002-Update-amalgamation-script.patch b/upstream_utils/mpack_patches/0002-Update-amalgamation-script.patch
index eabf154..68f6258 100644
--- a/upstream_utils/mpack_patches/0002-Update-amalgamation-script.patch
+++ b/upstream_utils/mpack_patches/0002-Update-amalgamation-script.patch
@@ -1,14 +1,14 @@
-From d4d045c843d4b4de747d800e570c32cff3759a80 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sat, 29 Oct 2022 12:16:36 -0400
-Subject: [PATCH 2/3] Update amalgamation script
+Subject: [PATCH 2/4] Update amalgamation script
 
 ---
  tools/amalgamate.sh | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/tools/amalgamate.sh b/tools/amalgamate.sh
-index 2e24e27..4dfe999 100755
+index 2e24e278e54bbc52967bfe1f8970f4f8d4b238d5..4dfe999ee49ee67fd394e948b0bb3133d6acdbdc 100755
 --- a/tools/amalgamate.sh
 +++ b/tools/amalgamate.sh
 @@ -74,8 +74,8 @@ echo -e "#endif\n" >> $HEADER
diff --git a/upstream_utils/mpack_patches/0003-Use-namespace-for-C.patch b/upstream_utils/mpack_patches/0003-Use-namespace-for-C.patch
index 4adb7f8..74f2050 100644
--- a/upstream_utils/mpack_patches/0003-Use-namespace-for-C.patch
+++ b/upstream_utils/mpack_patches/0003-Use-namespace-for-C.patch
@@ -1,7 +1,7 @@
-From 37854ea8a4a4b387940719c40bd32792f1e6e027 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: PJ Reiniger <pj.reiniger@gmail.com>
 Date: Sat, 29 Oct 2022 12:22:50 -0400
-Subject: [PATCH 3/3] Use namespace for C++
+Subject: [PATCH 3/4] Use namespace for C++
 
 ---
  src/mpack/mpack-common.c   | 2 ++
@@ -15,7 +15,7 @@
  8 files changed, 15 insertions(+), 2 deletions(-)
 
 diff --git a/src/mpack/mpack-common.c b/src/mpack/mpack-common.c
-index 2c133a3..dc7207f 100644
+index 2c133a3303f7a2a10ac7d11a9eb3ee5a04a8335c..e5b4ab0007df2c4108791534b1aa4f9da4f1742a 100644
 --- a/src/mpack/mpack-common.c
 +++ b/src/mpack/mpack-common.c
 @@ -24,6 +24,7 @@
@@ -33,7 +33,7 @@
 +}  // namespace mpack
  MPACK_SILENCE_WARNINGS_END
 diff --git a/src/mpack/mpack-expect.c b/src/mpack/mpack-expect.c
-index 81576d1..6232a67 100644
+index 81576d1e0e7b942e93a27a6dd5a75a751dba2384..44f00ffc5387b5646d700b174283dec12f2c4962 100644
 --- a/src/mpack/mpack-expect.c
 +++ b/src/mpack/mpack-expect.c
 @@ -24,6 +24,7 @@
@@ -51,7 +51,7 @@
 +}  // namespace mpack
  MPACK_SILENCE_WARNINGS_END
 diff --git a/src/mpack/mpack-node.c b/src/mpack/mpack-node.c
-index 3d4b0f4..aba9897 100644
+index 3d4b0f4e69f9e026ad48dec30ac091a024ef30cf..016531360ef27a2003489c1cb4c9aa2f1a7d0865 100644
 --- a/src/mpack/mpack-node.c
 +++ b/src/mpack/mpack-node.c
 @@ -24,6 +24,7 @@
@@ -69,7 +69,7 @@
 +}  // namespace mpack
  MPACK_SILENCE_WARNINGS_END
 diff --git a/src/mpack/mpack-platform.c b/src/mpack/mpack-platform.c
-index d4a2fa3..75d2de3 100644
+index d4a2fa3198f39fc964baeed4d15f6fd89affc24c..aadeee0f9de0833a5eabe3a7efc41a9ddf5cee70 100644
 --- a/src/mpack/mpack-platform.c
 +++ b/src/mpack/mpack-platform.c
 @@ -30,6 +30,7 @@
@@ -87,7 +87,7 @@
 +}  // namespace mpack
  MPACK_SILENCE_WARNINGS_END
 diff --git a/src/mpack/mpack-platform.h b/src/mpack/mpack-platform.h
-index 79604c9..27a2f9e 100644
+index 79604c90828ebbeae52eb3d6c13afeec6b861fa9..27a2f9eeb10cc8c6aa274a5e1b0c96bead6a37fb 100644
 --- a/src/mpack/mpack-platform.h
 +++ b/src/mpack/mpack-platform.h
 @@ -1043,7 +1043,7 @@ void mpack_assert_fail(const char* message);
@@ -100,7 +100,7 @@
  #else
      #define MPACK_EXTERN_C_BEGIN /*nothing*/
 diff --git a/src/mpack/mpack-reader.c b/src/mpack/mpack-reader.c
-index c6d2223..a135879 100644
+index c6d2223ef8208f4b918b8890ca81915cb2494bb0..e3cbe7a7086f0fcd0a1ce5e5004ce410fb0e457a 100644
 --- a/src/mpack/mpack-reader.c
 +++ b/src/mpack/mpack-reader.c
 @@ -24,6 +24,7 @@
@@ -118,7 +118,7 @@
 +}  // namespace mpack
  MPACK_SILENCE_WARNINGS_END
 diff --git a/src/mpack/mpack-writer.c b/src/mpack/mpack-writer.c
-index 4d052b1..9630d9e 100644
+index 4d052b14d83851a45a4899b96904ed661664008c..272f861979103495627887b0d3edfad117bff748 100644
 --- a/src/mpack/mpack-writer.c
 +++ b/src/mpack/mpack-writer.c
 @@ -24,6 +24,7 @@
@@ -136,7 +136,7 @@
 +}  // namespace mpack
  MPACK_SILENCE_WARNINGS_END
 diff --git a/src/mpack/mpack-writer.h b/src/mpack/mpack-writer.h
-index c239ee6..abeee1a 100644
+index c239ee6441e753cba46f2ab5a6136eead9c30fb4..abeee1a6eb960b0ce61203ae75eb7c7488186860 100644
 --- a/src/mpack/mpack-writer.h
 +++ b/src/mpack/mpack-writer.h
 @@ -1168,6 +1168,7 @@ MPACK_EXTERN_C_END
diff --git a/upstream_utils/mpack_patches/0004-Group-doxygen-into-MPack-module.patch b/upstream_utils/mpack_patches/0004-Group-doxygen-into-MPack-module.patch
new file mode 100644
index 0000000..a296623
--- /dev/null
+++ b/upstream_utils/mpack_patches/0004-Group-doxygen-into-MPack-module.patch
@@ -0,0 +1,133 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Ryan Blue <ryanzblue@gmail.com>
+Date: Thu, 8 Jun 2023 19:28:50 -0400
+Subject: [PATCH 4/4] Group doxygen into MPack module
+
+---
+ src/mpack/mpack-common.h   | 3 ++-
+ src/mpack/mpack-expect.h   | 3 ++-
+ src/mpack/mpack-node.h     | 3 ++-
+ src/mpack/mpack-platform.h | 3 ++-
+ src/mpack/mpack-reader.h   | 3 ++-
+ src/mpack/mpack-writer.h   | 3 ++-
+ src/mpack/mpack.h          | 6 ++++++
+ tools/amalgamate.sh        | 5 +++++
+ 8 files changed, 23 insertions(+), 6 deletions(-)
+
+diff --git a/src/mpack/mpack-common.h b/src/mpack/mpack-common.h
+index 1c6b8d472f9591575973db8f7573ce98c5a6169d..14f7dd05c0f9cdc3689bb357f8aac9c8d0671f45 100644
+--- a/src/mpack/mpack-common.h
++++ b/src/mpack/mpack-common.h
+@@ -40,7 +40,8 @@ MPACK_EXTERN_C_BEGIN
+ 
+ 
+ /**
+- * @defgroup common Tags and Common Elements
++ * @defgroup mpack_common Tags and Common Elements
++ * @ingroup mpack
+  *
+  * Contains types, constants and functions shared by both the encoding
+  * and decoding portions of MPack.
+diff --git a/src/mpack/mpack-expect.h b/src/mpack/mpack-expect.h
+index 02a1abc0cbe0250636d4a82c21517fba36484608..e62536e46bcab4fdf6bca1d3ea74ee5d9e8e7bd8 100644
+--- a/src/mpack/mpack-expect.h
++++ b/src/mpack/mpack-expect.h
+@@ -40,7 +40,8 @@ MPACK_EXTERN_C_BEGIN
+ #endif
+ 
+ /**
+- * @defgroup expect Expect API
++ * @defgroup mpack_expect Expect API
++ * @ingroup mpack
+  *
+  * The MPack Expect API allows you to easily read MessagePack data when you
+  * expect it to follow a predefined schema.
+diff --git a/src/mpack/mpack-node.h b/src/mpack/mpack-node.h
+index 52142c4f9965c690e4227a6f89354e1e65b9b6a4..4c1289c834398a20f0c25f86e17e57a31832d623 100644
+--- a/src/mpack/mpack-node.h
++++ b/src/mpack/mpack-node.h
+@@ -36,7 +36,8 @@ MPACK_EXTERN_C_BEGIN
+ #if MPACK_NODE
+ 
+ /**
+- * @defgroup node Node API
++ * @defgroup mpack_node Node API
++ * @ingroup mpack
+  *
+  * The MPack Node API allows you to parse a chunk of MessagePack into a
+  * dynamically typed data structure, providing random access to the parsed
+diff --git a/src/mpack/mpack-platform.h b/src/mpack/mpack-platform.h
+index 27a2f9eeb10cc8c6aa274a5e1b0c96bead6a37fb..3a100564c11d12494cd0f607645c8cfa5dd86dec 100644
+--- a/src/mpack/mpack-platform.h
++++ b/src/mpack/mpack-platform.h
+@@ -40,7 +40,8 @@
+ 
+ 
+ /**
+- * @defgroup config Configuration Options
++ * @defgroup mpack_config Configuration Options
++ * @ingroup mpack
+  *
+  * Defines the MPack configuration options.
+  *
+diff --git a/src/mpack/mpack-reader.h b/src/mpack/mpack-reader.h
+index 092e2ba2c36f8709b912d24b4d12974e81c82678..f981683512a60c0c2b5363b7f27cbd874c1b44f8 100644
+--- a/src/mpack/mpack-reader.h
++++ b/src/mpack/mpack-reader.h
+@@ -44,7 +44,8 @@ struct mpack_track_t;
+ #define MPACK_READER_SMALL_FRACTION_DENOMINATOR 32
+ 
+ /**
+- * @defgroup reader Reader API
++ * @defgroup mpack_reader Reader API
++ * @ingroup mpack
+  *
+  * The MPack Reader API contains functions for imperatively reading dynamically
+  * typed data from a MessagePack stream.
+diff --git a/src/mpack/mpack-writer.h b/src/mpack/mpack-writer.h
+index abeee1a6eb960b0ce61203ae75eb7c7488186860..03fdb7592b0bcaeeeaaf2f8c64c0fb30ba5e1292 100644
+--- a/src/mpack/mpack-writer.h
++++ b/src/mpack/mpack-writer.h
+@@ -40,7 +40,8 @@ struct mpack_track_t;
+ #endif
+ 
+ /**
+- * @defgroup writer Write API
++ * @defgroup mpack_writer Write API
++ * @ingroup mpack
+  *
+  * The MPack Write API encodes structured data of a fixed (hardcoded) schema to MessagePack.
+  *
+diff --git a/src/mpack/mpack.h b/src/mpack/mpack.h
+index 129a276115d85e09d717504df3736a7614fbd2ea..9739205efd0406a1bd05c728556c8f36368b1528 100644
+--- a/src/mpack/mpack.h
++++ b/src/mpack/mpack.h
+@@ -29,6 +29,12 @@
+ #ifndef MPACK_H
+ #define MPACK_H 1
+ 
++/**
++ * @defgroup mpack MPack
++ * MPack is a C implementation of an encoder and decoder for the MessagePack
++ * serialization format.
++ */
++
+ #include "mpack-common.h"
+ #include "mpack-writer.h"
+ #include "mpack-reader.h"
+diff --git a/tools/amalgamate.sh b/tools/amalgamate.sh
+index 4dfe999ee49ee67fd394e948b0bb3133d6acdbdc..ebff08200198406940720efe093df909a31caf65 100755
+--- a/tools/amalgamate.sh
++++ b/tools/amalgamate.sh
+@@ -66,6 +66,11 @@ echo -e "#define MPACK_AMALGAMATED 1\n" >> $HEADER
+ echo -e "#if defined(MPACK_HAS_CONFIG) && MPACK_HAS_CONFIG" >> $HEADER
+ echo -e "#include \"mpack-config.h\"" >> $HEADER
+ echo -e "#endif\n" >> $HEADER
++echo -e "/**" >> $HEADER
++echo -e " * @defgroup mpack MPack" >> $HEADER
++echo -e " * MPack is a C implementation of an encoder and decoder for the MessagePack" >> $HEADER
++echo -e " * serialization format." >> $HEADER
++echo -e " */" >> $HEADER
+ for f in $HEADERS; do
+     echo -e "\n/* $f.h */" >> $HEADER
+     sed -e 's@^#include ".*@/* & */@' -e '0,/^ \*\/$/d' src/$f >> $HEADER
diff --git a/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch b/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch
new file mode 100644
index 0000000..e916c0f
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch
@@ -0,0 +1,325 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 14:13:07 -0700
+Subject: [PATCH 01/11] Fix sign-compare warnings
+
+---
+ src/google/protobuf/compiler/importer.cc                  | 2 +-
+ src/google/protobuf/compiler/parser.cc                    | 4 ++--
+ src/google/protobuf/io/io_win32.cc                        | 2 +-
+ src/google/protobuf/stubs/stringprintf.cc                 | 4 ++--
+ src/google/protobuf/stubs/strutil.cc                      | 2 +-
+ src/google/protobuf/stubs/substitute.cc                   | 2 +-
+ src/google/protobuf/util/field_mask_util.cc               | 2 +-
+ src/google/protobuf/util/internal/datapiece.cc            | 7 +++++++
+ .../protobuf/util/internal/default_value_objectwriter.cc  | 4 ++--
+ .../protobuf/util/internal/default_value_objectwriter.h   | 2 +-
+ src/google/protobuf/util/internal/json_escaping.cc        | 6 +++---
+ src/google/protobuf/util/internal/json_objectwriter.h     | 2 +-
+ src/google/protobuf/util/internal/json_stream_parser.cc   | 8 ++++----
+ src/google/protobuf/util/internal/proto_writer.cc         | 2 +-
+ .../protobuf/util/internal/protostream_objectwriter.cc    | 2 +-
+ src/google/protobuf/util/internal/utility.cc              | 2 +-
+ src/google/protobuf/util/json_util.cc                     | 2 +-
+ 17 files changed, 31 insertions(+), 24 deletions(-)
+
+diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc
+index f1e26f8bdd1d3619acd8827f9a2a0e6b2acdd124..678e87eb03cc3959a1890327cd1e918cb1896fa3 100644
+--- a/src/google/protobuf/compiler/importer.cc
++++ b/src/google/protobuf/compiler/importer.cc
+@@ -398,7 +398,7 @@ DiskSourceTree::DiskFileToVirtualFile(const std::string& disk_file,
+   int mapping_index = -1;
+   std::string canonical_disk_file = CanonicalizePath(disk_file);
+ 
+-  for (int i = 0; i < mappings_.size(); i++) {
++  for (size_t i = 0; i < mappings_.size(); i++) {
+     // Apply the mapping in reverse.
+     if (ApplyMapping(canonical_disk_file, mappings_[i].disk_path,
+                      mappings_[i].virtual_path, virtual_file)) {
+diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc
+index 5bd37d147bc449444f875f89367a208a32a9146e..e36a4a74359fcace20c017f241d58930660b9381 100644
+--- a/src/google/protobuf/compiler/parser.cc
++++ b/src/google/protobuf/compiler/parser.cc
+@@ -159,7 +159,7 @@ bool IsLowerUnderscore(const std::string& name) {
+ }
+ 
+ bool IsNumberFollowUnderscore(const std::string& name) {
+-  for (int i = 1; i < name.length(); i++) {
++  for (size_t i = 1; i < name.length(); i++) {
+     const char c = name[i];
+     if (IsNumber(c) && name[i - 1] == '_') {
+       return true;
+@@ -500,7 +500,7 @@ void Parser::LocationRecorder::AttachComments(
+   if (!trailing->empty()) {
+     location_->mutable_trailing_comments()->swap(*trailing);
+   }
+-  for (int i = 0; i < detached_comments->size(); ++i) {
++  for (size_t i = 0; i < detached_comments->size(); ++i) {
+     location_->add_leading_detached_comments()->swap((*detached_comments)[i]);
+   }
+   detached_comments->clear();
+diff --git a/src/google/protobuf/io/io_win32.cc b/src/google/protobuf/io/io_win32.cc
+index 4e8190880918f1ba155d75db76d6c1ee0b003247..78c07d0d771b9c227c6cd930fc91d272fd67500f 100644
+--- a/src/google/protobuf/io/io_win32.cc
++++ b/src/google/protobuf/io/io_win32.cc
+@@ -198,7 +198,7 @@ wstring normalize(wstring path) {
+   // Join all segments.
+   bool first = true;
+   std::wstringstream result;
+-  for (int i = 0; i < segments.size(); ++i) {
++  for (size_t i = 0; i < segments.size(); ++i) {
+     if (!first) {
+       result << L'\\';
+     }
+diff --git a/src/google/protobuf/stubs/stringprintf.cc b/src/google/protobuf/stubs/stringprintf.cc
+index a6ad4c0da4080f5241c26176046a3add5247e25c..8b890f47c386f0d6b0ab9fd9928fae03edd076eb 100644
+--- a/src/google/protobuf/stubs/stringprintf.cc
++++ b/src/google/protobuf/stubs/stringprintf.cc
+@@ -149,10 +149,10 @@ std::string StringPrintfVector(const char* format,
+   // or displaying random chunks of memory to users.
+ 
+   const char* cstr[kStringPrintfVectorMaxArgs];
+-  for (int i = 0; i < v.size(); ++i) {
++  for (size_t i = 0; i < v.size(); ++i) {
+     cstr[i] = v[i].c_str();
+   }
+-  for (int i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) {
++  for (size_t i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) {
+     cstr[i] = &string_printf_empty_block[0];
+   }
+ 
+diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
+index 594c8eac6a6ebff6d8bc8cc8518e3fd521f24da1..3462e91ff273dc071628f06b91698a0f166514fc 100644
+--- a/src/google/protobuf/stubs/strutil.cc
++++ b/src/google/protobuf/stubs/strutil.cc
+@@ -697,7 +697,7 @@ bool safe_parse_positive_int(std::string text, IntType *value_p) {
+   IntType value = 0;
+   const IntType vmax = std::numeric_limits<IntType>::max();
+   assert(vmax > 0);
+-  assert(vmax >= base);
++  assert(static_cast<int>(vmax) >= base);
+   const IntType vmax_over_base = vmax / base;
+   const char* start = text.data();
+   const char* end = start + text.size();
+diff --git a/src/google/protobuf/stubs/substitute.cc b/src/google/protobuf/stubs/substitute.cc
+index d301682ee3377760430839bc5d6530621333e48d..8c75b2562e43d9d4ade3ef187d38e2e81b43e2c7 100644
+--- a/src/google/protobuf/stubs/substitute.cc
++++ b/src/google/protobuf/stubs/substitute.cc
+@@ -128,7 +128,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
+     }
+   }
+ 
+-  GOOGLE_DCHECK_EQ(target - output->data(), output->size());
++  GOOGLE_DCHECK_EQ(target - output->data(), static_cast<int>(output->size()));
+ }
+ 
+ }  // namespace strings
+diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc
+index 700e59004a083c731477bcc0bb4d5c36d06f306c..9a40b851a9e51d30b286ff5d89707bf9f279d0c0 100644
+--- a/src/google/protobuf/util/field_mask_util.cc
++++ b/src/google/protobuf/util/field_mask_util.cc
+@@ -366,7 +366,7 @@ void FieldMaskTree::RemovePath(const std::string& path,
+   Node* node = &root_;
+   const Descriptor* current_descriptor = descriptor;
+   Node* new_branch_node = nullptr;
+-  for (int i = 0; i < parts.size(); ++i) {
++  for (size_t i = 0; i < parts.size(); ++i) {
+     nodes[i] = node;
+     const FieldDescriptor* field_descriptor =
+         current_descriptor->FindFieldByName(parts[i]);
+diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc
+index 3e7aa84da7181e2ab270e181b9f63deb1905542f..56f4a18fa4afc64708938fa5352937cdd17b5747 100644
+--- a/src/google/protobuf/util/internal/datapiece.cc
++++ b/src/google/protobuf/util/internal/datapiece.cc
+@@ -53,6 +53,10 @@ namespace {
+ 
+ template <typename To, typename From>
+ util::StatusOr<To> ValidateNumberConversion(To after, From before) {
++#ifdef __GNUC__
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wsign-compare"
++#endif
+   if (after == before &&
+       MathUtil::Sign<From>(before) == MathUtil::Sign<To>(after)) {
+     return after;
+@@ -62,6 +66,9 @@ util::StatusOr<To> ValidateNumberConversion(To after, From before) {
+         : std::is_same<From, double>::value ? DoubleAsString(before)
+                                             : FloatAsString(before));
+   }
++#ifdef __GNUC__
++#pragma GCC diagnostic pop
++#endif
+ }
+ 
+ // For general conversion between
+diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc
+index 7f61cdafa7c771a69364c5e9c49667535b16d957..a7d4ce78bd47e0250def474df8937927be9ef116 100644
+--- a/src/google/protobuf/util/internal/default_value_objectwriter.cc
++++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc
+@@ -312,7 +312,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
+   std::unordered_map<std::string, int> orig_children_map;
+ 
+   // Creates a map of child nodes to speed up lookup.
+-  for (int i = 0; i < children_.size(); ++i) {
++  for (size_t i = 0; i < children_.size(); ++i) {
+     InsertIfNotPresent(&orig_children_map, children_[i]->name_, i);
+   }
+ 
+@@ -389,7 +389,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
+     new_children.push_back(child.release());
+   }
+   // Adds all leftover nodes in children_ to the beginning of new_child.
+-  for (int i = 0; i < children_.size(); ++i) {
++  for (size_t i = 0; i < children_.size(); ++i) {
+     if (children_[i] == nullptr) {
+       continue;
+     }
+diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
+index a9e1673fa1e4ed35ab6890a44eed1d362265d914..1a151ab25951f8b0e1c9c724253b16524b88530a 100644
+--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
++++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
+@@ -154,7 +154,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
+          bool preserve_proto_field_names, bool use_ints_for_enums,
+          FieldScrubCallBack field_scrub_callback);
+     virtual ~Node() {
+-      for (int i = 0; i < children_.size(); ++i) {
++      for (size_t i = 0; i < children_.size(); ++i) {
+         delete children_[i];
+       }
+     }
+diff --git a/src/google/protobuf/util/internal/json_escaping.cc b/src/google/protobuf/util/internal/json_escaping.cc
+index e4fa8cf788642e4a9d9c0460c287b1c24891b9fa..c192ddca7aff3984ffcbf82e13585bdf34ad8aae 100644
+--- a/src/google/protobuf/util/internal/json_escaping.cc
++++ b/src/google/protobuf/util/internal/json_escaping.cc
+@@ -179,7 +179,7 @@ bool ReadCodePoint(StringPiece str, int index, uint32_t* cp,
+     // the last unicode code point.
+     *num_read = 0;
+   }
+-  while (*num_left > 0 && index < str.size()) {
++  while (*num_left > 0 && index < static_cast<int>(str.size())) {
+     uint32_t ch = static_cast<uint8_t>(str[index++]);
+     --(*num_left);
+     ++(*num_read);
+@@ -309,7 +309,7 @@ void JsonEscaping::Escape(strings::ByteSource* input,
+   while (input->Available() > 0) {
+     StringPiece str = input->Peek();
+     StringPiece escaped;
+-    int i = 0;
++    size_t i = 0;
+     int num_read;
+     bool ok;
+     bool cp_was_split = num_left > 0;
+@@ -349,7 +349,7 @@ void JsonEscaping::Escape(StringPiece input, strings::ByteSink* output) {
+   const char* p = input.data();
+ 
+   bool can_skip_escaping = true;
+-  for (int i = 0; i < len; i++) {
++  for (size_t i = 0; i < len; i++) {
+     char c = p[i];
+     if (c < 0x20 || c >= 0x7F || c == '"' || c == '<' || c == '>' ||
+         c == '\\') {
+diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h
+index cb7dff6e9fe79858a73b2c7501106fe8d05ccac5..92348da3b5c3f07e6146136352f976c94fe54340 100644
+--- a/src/google/protobuf/util/internal/json_objectwriter.h
++++ b/src/google/protobuf/util/internal/json_objectwriter.h
+@@ -102,7 +102,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
+     if (!indent_string.empty()) {
+       indent_char_ = indent_string[0];
+       indent_count_ = indent_string.length();
+-      for (int i = 1; i < indent_string.length(); i++) {
++      for (size_t i = 1; i < indent_string.length(); i++) {
+         if (indent_char_ != indent_string_[i]) {
+           indent_char_ = '\0';
+           indent_count_ = 0;
+diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc
+index 5c34dbccafb9f40249ba3c0b7318b2e897f203dc..e786781f6de23c8a7ea282d061df6032111f6d21 100644
+--- a/src/google/protobuf/util/internal/json_stream_parser.cc
++++ b/src/google/protobuf/util/internal/json_stream_parser.cc
+@@ -80,7 +80,7 @@ inline void ReplaceInvalidCodePoints(StringPiece str,
+                                      const std::string& replacement,
+                                      std::string* dst) {
+   while (!str.empty()) {
+-    int n_valid_bytes = internal::UTF8SpnStructurallyValid(str);
++    size_t n_valid_bytes = internal::UTF8SpnStructurallyValid(str);
+     StringPiece valid_part = str.substr(0, n_valid_bytes);
+     StrAppend(dst, valid_part);
+ 
+@@ -98,7 +98,7 @@ inline void ReplaceInvalidCodePoints(StringPiece str,
+ 
+ static bool ConsumeKey(StringPiece* input, StringPiece* key) {
+   if (input->empty() || !IsLetter((*input)[0])) return false;
+-  int len = 1;
++  size_t len = 1;
+   for (; len < input->size(); ++len) {
+     if (!IsAlphanumeric((*input)[len])) {
+       break;
+@@ -113,7 +113,7 @@ static bool ConsumeKey(StringPiece* input, StringPiece* key) {
+ static bool ConsumeKeyPermissive(StringPiece* input,
+                                  StringPiece* key) {
+   if (input->empty() || !IsLetter((*input)[0])) return false;
+-  int len = 1;
++  size_t len = 1;
+   for (; len < input->size(); ++len) {
+     if (IsKeySeparator((*input)[len])) {
+       break;
+@@ -946,7 +946,7 @@ util::Status JsonStreamParser::ParseKey() {
+ JsonStreamParser::TokenType JsonStreamParser::GetNextTokenType() {
+   SkipWhitespace();
+ 
+-  int size = p_.size();
++  size_t size = p_.size();
+   if (size == 0) {
+     // If we ran out of data, report unknown and we'll place the previous parse
+     // type onto the stack and try again when we have more data.
+diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc
+index afa5e2e474b6960b8826a40b73615d5dffd971de..11b6df13d8f4f9506e828c39d6e74bc8acceb23d 100644
+--- a/src/google/protobuf/util/internal/proto_writer.cc
++++ b/src/google/protobuf/util/internal/proto_writer.cc
+@@ -408,7 +408,7 @@ std::string ProtoWriter::ProtoElement::ToString() const {
+     if (!ow_->IsRepeated(*(now->parent_field_)) ||
+         now->parent()->parent_field_ != now->parent_field_) {
+       std::string name = now->parent_field_->name();
+-      int i = 0;
++      size_t i = 0;
+       while (i < name.size() &&
+              (ascii_isalnum(name[i]) || name[i] == '_'))
+         ++i;
+diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc
+index ecb219e06e514b1a6ba0e3e343126a75852d0a1d..ce94cfcefb417203f80142c54003efea283f6a1c 100644
+--- a/src/google/protobuf/util/internal/protostream_objectwriter.cc
++++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
+@@ -378,7 +378,7 @@ void ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) {
+ 
+   // Now we know the proto type and can interpret all data fields we gathered
+   // before the "@type" field.
+-  for (int i = 0; i < uninterpreted_events_.size(); ++i) {
++  for (size_t i = 0; i < uninterpreted_events_.size(); ++i) {
+     uninterpreted_events_[i].Replay(this);
+   }
+ }
+diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc
+index 918ee17d9b040ae1bf9d98e3f46f75770c471393..3c4ac086d594d67b334cbc1dc046c281cd59a374 100644
+--- a/src/google/protobuf/util/internal/utility.cc
++++ b/src/google/protobuf/util/internal/utility.cc
+@@ -345,7 +345,7 @@ void DeleteWellKnownTypes() { delete well_known_types_; }
+ 
+ void InitWellKnownTypes() {
+   well_known_types_ = new std::set<std::string>;
+-  for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
++  for (size_t i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
+     well_known_types_->insert(well_known_types_name_array_[i]);
+   }
+   google::protobuf::internal::OnShutdown(&DeleteWellKnownTypes);
+diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
+index c39c10d87b7d8bf6fc18cae1ce459257c45945d6..a9b1c52a73c86d3e3655ba0748f2a82c68bd40ce 100644
+--- a/src/google/protobuf/util/json_util.cc
++++ b/src/google/protobuf/util/json_util.cc
+@@ -64,7 +64,7 @@ ZeroCopyStreamByteSink::~ZeroCopyStreamByteSink() {
+ 
+ void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {
+   while (true) {
+-    if (len <= buffer_size_) {  // NOLINT
++    if (static_cast<int>(len) <= buffer_size_) {  // NOLINT
+       memcpy(buffer_, bytes, len);
+       buffer_ = static_cast<char*>(buffer_) + len;
+       buffer_size_ -= len;
diff --git a/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch b/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch
new file mode 100644
index 0000000..09ab3c5
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch
@@ -0,0 +1,22 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 14:41:39 -0700
+Subject: [PATCH 02/11] Remove redundant move
+
+---
+ src/google/protobuf/extension_set.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
+index 0e6d0521104d7f721bdbad1dd593233b035c5b85..b5343689ef7c16442995746439bbe8928022c593 100644
+--- a/src/google/protobuf/extension_set.h
++++ b/src/google/protobuf/extension_set.h
+@@ -714,7 +714,7 @@ class PROTOBUF_EXPORT ExtensionSet {
+   static KeyValueFunctor ForEach(Iterator begin, Iterator end,
+                                  KeyValueFunctor func) {
+     for (Iterator it = begin; it != end; ++it) func(it->first, it->second);
+-    return std::move(func);
++    return func;
+   }
+ 
+   // Applies a functor to the <int, Extension&> pairs in sorted order.
diff --git a/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch b/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch
new file mode 100644
index 0000000..40ee920
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch
@@ -0,0 +1,168 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 15:00:20 -0700
+Subject: [PATCH 03/11] Fix maybe-uninitialized warnings
+
+---
+ src/google/protobuf/arena.cc                     |  6 +++---
+ src/google/protobuf/arena_impl.h                 |  4 ++--
+ src/google/protobuf/extension_set_inl.h          |  2 +-
+ .../protobuf/generated_message_tctable_lite.cc   | 16 ++++++++--------
+ src/google/protobuf/io/coded_stream.cc           |  2 +-
+ 5 files changed, 15 insertions(+), 15 deletions(-)
+
+diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
+index 6ba508a5f0f3436d52ccc326cc932ceed3cd79fa..194404213ee5f6ad05b1e01f2bff23859d60dc56 100644
+--- a/src/google/protobuf/arena.cc
++++ b/src/google/protobuf/arena.cc
+@@ -411,7 +411,7 @@ uint64_t ThreadSafeArena::Reset() {
+ std::pair<void*, SerialArena::CleanupNode*>
+ ThreadSafeArena::AllocateAlignedWithCleanup(size_t n,
+                                             const std::type_info* type) {
+-  SerialArena* arena;
++  SerialArena* arena = nullptr;
+   if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
+                             GetSerialArenaFast(&arena))) {
+     return arena->AllocateAlignedWithCleanup(n, alloc_policy_.get());
+@@ -421,7 +421,7 @@ ThreadSafeArena::AllocateAlignedWithCleanup(size_t n,
+ }
+ 
+ void ThreadSafeArena::AddCleanup(void* elem, void (*cleanup)(void*)) {
+-  SerialArena* arena;
++  SerialArena* arena = nullptr;
+   if (PROTOBUF_PREDICT_FALSE(!GetSerialArenaFast(&arena))) {
+     arena = GetSerialArenaFallback(&thread_cache());
+   }
+@@ -433,7 +433,7 @@ void* ThreadSafeArena::AllocateAlignedFallback(size_t n,
+                                                const std::type_info* type) {
+   if (alloc_policy_.should_record_allocs()) {
+     alloc_policy_.RecordAlloc(type, n);
+-    SerialArena* arena;
++    SerialArena* arena = nullptr;
+     if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+       return arena->AllocateAligned(n, alloc_policy_.get());
+     }
+diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h
+index 76727688b558354be18f0c6576db1d4619348ef4..8af70c48f13feece7cf8580e71845ec267ddaddb 100644
+--- a/src/google/protobuf/arena_impl.h
++++ b/src/google/protobuf/arena_impl.h
+@@ -482,7 +482,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
+ 
+   template <AllocationClient alloc_client = AllocationClient::kDefault>
+   void* AllocateAligned(size_t n, const std::type_info* type) {
+-    SerialArena* arena;
++    SerialArena* arena = nullptr;
+     if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
+                               GetSerialArenaFast(&arena))) {
+       return arena->AllocateAligned<alloc_client>(n, AllocPolicy());
+@@ -492,7 +492,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
+   }
+ 
+   void ReturnArrayMemory(void* p, size_t size) {
+-    SerialArena* arena;
++    SerialArena* arena = nullptr;
+     if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+       arena->ReturnArrayMemory(p, size);
+     }
+diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h
+index e4e711721d4d8690e1e87fc8e31df1b5836d4fd7..50c04cd41feccf6cb5fda2740d6d4adb874645d7 100644
+--- a/src/google/protobuf/extension_set_inl.h
++++ b/src/google/protobuf/extension_set_inl.h
+@@ -206,7 +206,7 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
+     const char* ptr, const Msg* extendee, internal::InternalMetadata* metadata,
+     internal::ParseContext* ctx) {
+   std::string payload;
+-  uint32_t type_id;
++  uint32_t type_id = 0;
+   enum class State { kNoTag, kHasType, kHasPayload, kDone };
+   State state = State::kNoTag;
+ 
+diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc
+index 9993811dca3229edc766061c4a8d54933bcb0eba..2268b2be4d4c60c545765469549d73c6a468dac8 100644
+--- a/src/google/protobuf/generated_message_tctable_lite.cc
++++ b/src/google/protobuf/generated_message_tctable_lite.cc
+@@ -770,7 +770,7 @@ PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint(
+   };
+   volatile Spill spill = {data.data, msg, table, hasbits};
+ 
+-  uint64_t tmp;
++  uint64_t tmp = 0;
+   PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0);
+   ptr = ParseVarint(ptr, &tmp);
+ 
+@@ -845,7 +845,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedVarint(
+   auto expected_tag = UnalignedLoad<TagType>(ptr);
+   do {
+     ptr += sizeof(TagType);
+-    uint64_t tmp;
++    uint64_t tmp = 0;
+     ptr = ParseVarint(ptr, &tmp);
+     if (ptr == nullptr) {
+       return Error(PROTOBUF_TC_PARAM_PASS);
+@@ -1001,7 +1001,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularEnum(
+   }
+   const char* ptr2 = ptr;  // Save for unknown enum case
+   ptr += sizeof(TagType);  // Consume tag
+-  uint64_t tmp;
++  uint64_t tmp = 0;
+   ptr = ParseVarint(ptr, &tmp);
+   if (ptr == nullptr) {
+     return Error(PROTOBUF_TC_PARAM_PASS);
+@@ -1052,7 +1052,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedEnum(
+   do {
+     const char* ptr2 = ptr;  // save for unknown enum case
+     ptr += sizeof(TagType);
+-    uint64_t tmp;
++    uint64_t tmp = 0;
+     ptr = ParseVarint(ptr, &tmp);
+     if (ptr == nullptr) {
+       return Error(PROTOBUF_TC_PARAM_PASS);
+@@ -1477,7 +1477,7 @@ const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) {
+ 
+   // Parse the value:
+   const char* ptr2 = ptr;  // save for unknown enum case
+-  uint64_t tmp;
++  uint64_t tmp = 0;
+   ptr = ParseVarint(ptr, &tmp);
+   if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+ 
+@@ -1542,7 +1542,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
+     const char* ptr2 = ptr;
+     uint32_t next_tag;
+     do {
+-      uint64_t tmp;
++      uint64_t tmp = 0;
+       ptr = ParseVarint(ptr2, &tmp);
+       if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+       field.Add(is_zigzag ? WireFormatLite::ZigZagDecode64(tmp) : tmp);
+@@ -1554,7 +1554,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
+     const char* ptr2 = ptr;
+     uint32_t next_tag;
+     do {
+-      uint64_t tmp;
++      uint64_t tmp = 0;
+       ptr = ParseVarint(ptr2, &tmp);
+       if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+       if (is_validated_enum) {
+@@ -1575,7 +1575,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
+     const char* ptr2 = ptr;
+     uint32_t next_tag;
+     do {
+-      uint64_t tmp;
++      uint64_t tmp = 0;
+       ptr = ParseVarint(ptr2, &tmp);
+       if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
+       field.Add(static_cast<bool>(tmp));
+diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
+index 487e1b8a379b86bfa3097d68a64ee0a727d36cab..53997901f333292f71ac52e7f9c876bd918f7bf6 100644
+--- a/src/google/protobuf/io/coded_stream.cc
++++ b/src/google/protobuf/io/coded_stream.cc
+@@ -462,7 +462,7 @@ int64_t CodedInputStream::ReadVarint32Fallback(uint32_t first_byte_or_zero) {
+       (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {
+     GOOGLE_DCHECK_NE(first_byte_or_zero, 0)
+         << "Caller should provide us with *buffer_ when buffer is non-empty";
+-    uint32_t temp;
++    uint32_t temp = 0;
+     ::std::pair<bool, const uint8_t*> p =
+         ReadVarint32FromArray(first_byte_or_zero, buffer_, &temp);
+     if (!p.first) return -1;
diff --git a/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch b/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch
new file mode 100644
index 0000000..90fe162
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch
@@ -0,0 +1,38 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 15:03:38 -0700
+Subject: [PATCH 04/11] Fix coded_stream WriteRaw
+
+---
+ src/google/protobuf/implicit_weak_message.h | 2 +-
+ src/google/protobuf/io/coded_stream.h       | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h
+index b894ab4809090011f381828857d1674a6b7bff9b..c358c14c06f773d87f5089c75566a5a6fcba13e6 100644
+--- a/src/google/protobuf/implicit_weak_message.h
++++ b/src/google/protobuf/implicit_weak_message.h
+@@ -100,7 +100,7 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
+     if (data_ == nullptr) {
+       return target;
+     }
+-    return stream->WriteRaw(data_->data(), static_cast<int>(data_->size()),
++    return stream->WriteRaw(data_->data(), data_->size(),
+                             target);
+   }
+ 
+diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
+index c8fc994f916d047c0a7b176e53c9e946ebd752de..6c0dd4ab4099d1d748957af8bfc5f8c59c2aa3d6 100644
+--- a/src/google/protobuf/io/coded_stream.h
++++ b/src/google/protobuf/io/coded_stream.h
+@@ -677,8 +677,8 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
+     return ptr;
+   }
+ 
+-  uint8_t* WriteRaw(const void* data, int size, uint8_t* ptr) {
+-    if (PROTOBUF_PREDICT_FALSE(end_ - ptr < size)) {
++  uint8_t* WriteRaw(const void* data, size_t size, uint8_t* ptr) {
++    if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast<int>(size))) {
+       return WriteRawFallback(data, size, ptr);
+     }
+     std::memcpy(ptr, data, size);
diff --git a/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch b/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch
new file mode 100644
index 0000000..85d12a0
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch
@@ -0,0 +1,36 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 15:13:45 -0700
+Subject: [PATCH 05/11] Suppress enum-enum conversion warning
+
+---
+ src/google/protobuf/generated_message_tctable_impl.h | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h
+index 21fa5332d39b24e0bdb6432f27183df743d512c6..ce3d9110e28706ca18dcf0f2c94feba75f447dc7 100644
+--- a/src/google/protobuf/generated_message_tctable_impl.h
++++ b/src/google/protobuf/generated_message_tctable_impl.h
+@@ -180,6 +180,12 @@ static_assert(kFmtShift + kFmtBits == 12, "number of bits changed");
+ // This assertion should not change unless the storage width changes:
+ static_assert(kFmtShift + kFmtBits <= 16, "too many bits");
+ 
++#ifdef __GNUC__
++#pragma GCC diagnostic push
++#if __GNUC__ >= 12 || (__GNUC__ == 11 && __GNUC_MINOR >= 1)
++#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
++#endif
++#endif
+ // Convenience aliases (16 bits, with format):
+ enum FieldType : uint16_t {
+   // Numeric types:
+@@ -232,6 +238,9 @@ enum FieldType : uint16_t {
+   // Map types:
+   kMap             = kFkMap,
+ };
++#ifdef __GNUC__
++#pragma GCC diagnostic pop
++#endif
+ 
+ // clang-format on
+ }  // namespace field_layout
diff --git a/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch b/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch
new file mode 100644
index 0000000..d255d80
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 15:16:46 -0700
+Subject: [PATCH 06/11] Fix noreturn function returning
+
+---
+ src/google/protobuf/generated_message_tctable_impl.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h
+index ce3d9110e28706ca18dcf0f2c94feba75f447dc7..a8f8bdc192081763b0ad8c685384ae68d901736c 100644
+--- a/src/google/protobuf/generated_message_tctable_impl.h
++++ b/src/google/protobuf/generated_message_tctable_impl.h
+@@ -262,6 +262,9 @@ template <size_t align>
+ #endif
+ void AlignFail(uintptr_t address) {
+   GOOGLE_LOG(FATAL) << "Unaligned (" << align << ") access at " << address;
++#ifdef __GNUC__
++  __builtin_unreachable();
++#endif
+ }
+ 
+ extern template void AlignFail<4>(uintptr_t);
diff --git a/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch b/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch
new file mode 100644
index 0000000..aa67e21
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Sat, 10 Jun 2023 15:59:45 -0700
+Subject: [PATCH 07/11] Work around GCC 12 restrict warning compiler bug
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329
+---
+ src/google/protobuf/io/tokenizer.cc | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc
+index f9e07763e7362bd37267619336db841d0ae9df25..30d62ac9647b897c2e7c8ad43cd27ff0e08922a2 100644
+--- a/src/google/protobuf/io/tokenizer.cc
++++ b/src/google/protobuf/io/tokenizer.cc
+@@ -585,7 +585,14 @@ Tokenizer::NextCommentStatus Tokenizer::TryConsumeCommentStart() {
+     } else {
+       // Oops, it was just a slash.  Return it.
+       current_.type = TYPE_SYMBOL;
++#if defined(__GNUC__) && !defined(__clang__)
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wrestrict"
++#endif
+       current_.text = "/";
++#if defined(__GNUC__) && !defined(__clang__)
++#pragma GCC diagnostic pop
++#endif
+       current_.line = line_;
+       current_.column = column_ - 1;
+       current_.end_column = column_;
diff --git a/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch b/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch
new file mode 100644
index 0000000..b0c485b
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch
@@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Tue, 13 Jun 2023 23:56:15 -0700
+Subject: [PATCH 08/11] Disable MSVC switch warning
+
+---
+ src/google/protobuf/generated_message_reflection.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
+index 2a807e066bb748f214e008971309ef15473344b5..599dde80b671085d87ff1812929cafe8d2aecf75 100644
+--- a/src/google/protobuf/generated_message_reflection.cc
++++ b/src/google/protobuf/generated_message_reflection.cc
+@@ -75,6 +75,10 @@ using google::protobuf::internal::RepeatedPtrFieldBase;
+ using google::protobuf::internal::StringSpaceUsedExcludingSelfLong;
+ using google::protobuf::internal::WrappedMutex;
+ 
++#ifdef _MSC_VER
++#pragma warning(disable : 4065)
++#endif
++
+ namespace google {
+ namespace protobuf {
+ 
diff --git a/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch b/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch
new file mode 100644
index 0000000..b3aa64e
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch
@@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Tue, 13 Jun 2023 23:58:50 -0700
+Subject: [PATCH 09/11] Disable unused function warning
+
+---
+ src/google/protobuf/generated_message_tctable_lite.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc
+index 2268b2be4d4c60c545765469549d73c6a468dac8..23557a614752a9f0c93d8bd56724f3bc0f962185 100644
+--- a/src/google/protobuf/generated_message_tctable_lite.cc
++++ b/src/google/protobuf/generated_message_tctable_lite.cc
+@@ -43,6 +43,10 @@
+ #include <google/protobuf/port_def.inc>
+ // clang-format on
+ 
++#ifdef __GNUC__
++#pragma GCC diagnostic ignored "-Wunused-function"
++#endif
++
+ namespace google {
+ namespace protobuf {
+ namespace internal {
diff --git a/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch b/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch
new file mode 100644
index 0000000..1555d19
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch
@@ -0,0 +1,95 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Wed, 14 Jun 2023 00:02:26 -0700
+Subject: [PATCH 10/11] Disable pedantic warning
+
+---
+ src/google/protobuf/descriptor.h                    | 8 ++++++++
+ src/google/protobuf/generated_message_reflection.cc | 2 ++
+ src/google/protobuf/parse_context.h                 | 8 ++++++++
+ src/google/protobuf/stubs/common.cc                 | 4 ++--
+ 4 files changed, 20 insertions(+), 2 deletions(-)
+
+diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
+index 6e536e5705f8df4f7c13638d50c114cbfb92fb4a..bee3e32b9f1d5ba47b83d1e388716a3c3b6e82c6 100644
+--- a/src/google/protobuf/descriptor.h
++++ b/src/google/protobuf/descriptor.h
+@@ -80,6 +80,10 @@
+ #define PROTOBUF_EXPORT
+ #endif
+ 
++#ifdef __GNUC__
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wpedantic"
++#endif
+ 
+ namespace google {
+ namespace protobuf {
+@@ -2434,6 +2438,10 @@ inline FileDescriptor::Syntax FileDescriptor::syntax() const {
+ }  // namespace protobuf
+ }  // namespace google
+ 
++#ifdef __GNUC__
++#pragma GCC diagnostic pop
++#endif
++
+ #undef PROTOBUF_INTERNAL_CHECK_CLASS_SIZE
+ #include <google/protobuf/port_undef.inc>
+ 
+diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
+index 599dde80b671085d87ff1812929cafe8d2aecf75..aaed21920908b329e22c2e0d92f69397996a9f93 100644
+--- a/src/google/protobuf/generated_message_reflection.cc
++++ b/src/google/protobuf/generated_message_reflection.cc
+@@ -77,6 +77,8 @@ using google::protobuf::internal::WrappedMutex;
+ 
+ #ifdef _MSC_VER
+ #pragma warning(disable : 4065)
++#elif defined(__GNUC__)
++#pragma GCC diagnostic ignored "-Wpedantic"
+ #endif
+ 
+ namespace google {
+diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h
+index 7aea50cdc385f0ed01b3989e12276494bf574939..97daae09cbff11fd3b4b99cee935aeb542c42eb4 100644
+--- a/src/google/protobuf/parse_context.h
++++ b/src/google/protobuf/parse_context.h
+@@ -52,6 +52,10 @@
+ // Must be included last.
+ #include <google/protobuf/port_def.inc>
+ 
++#ifdef __GNUC__
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wpedantic"
++#endif
+ 
+ namespace google {
+ namespace protobuf {
+@@ -1020,6 +1024,10 @@ PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownFieldParse(
+ }  // namespace protobuf
+ }  // namespace google
+ 
++#ifdef __GNUC__
++#pragma GCC diagnostic pop
++#endif
++
+ #include <google/protobuf/port_undef.inc>
+ 
+ #endif  // GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
+diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
+index e0a807ffbbc94d07176e20db230204384170607b..1423021b846966eb02d36c10df488f8aa0082a64 100644
+--- a/src/google/protobuf/stubs/common.cc
++++ b/src/google/protobuf/stubs/common.cc
+@@ -277,11 +277,11 @@ LogHandler* SetLogHandler(LogHandler* new_func) {
+ 
+ LogSilencer::LogSilencer() {
+   ++internal::log_silencer_count_;
+-};
++}
+ 
+ LogSilencer::~LogSilencer() {
+   --internal::log_silencer_count_;
+-};
++}
+ 
+ // ===================================================================
+ // emulates google3/base/callback.cc
diff --git a/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch b/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch
new file mode 100644
index 0000000..27e81af
--- /dev/null
+++ b/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch
@@ -0,0 +1,35 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Johnson <johnson.peter@gmail.com>
+Date: Mon, 9 Oct 2023 19:28:08 -0700
+Subject: [PATCH 11/11] Avoid use of sprintf
+
+---
+ src/google/protobuf/stubs/strutil.cc | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
+index 3462e91ff273dc071628f06b91698a0f166514fc..e063d0d3039c87d55a6df0dbfe50f365184fe292 100644
+--- a/src/google/protobuf/stubs/strutil.cc
++++ b/src/google/protobuf/stubs/strutil.cc
+@@ -503,10 +503,18 @@ int CEscapeInternal(const char* src, int src_len, char* dest,
+              (last_hex_escape && isxdigit(*src)))) {
+           if (dest_len - used < 4) // need space for 4 letter escape
+             return -1;
+-          sprintf(dest + used, (use_hex ? "\\x%02x" : "\\%03o"),
+-                  static_cast<uint8_t>(*src));
++          dest[used++] = '\\';
++          if (use_hex) {
++            constexpr char hexdigits[] = "0123456789abcdef";
++            dest[used++] = 'x';
++            dest[used++] = hexdigits[(static_cast<uint8_t>(*src) >> 4) & 0xf];
++            dest[used++] = hexdigits[static_cast<uint8_t>(*src) & 0xf];
++          } else {
++            dest[used++] = '0' + ((static_cast<uint8_t>(*src) >> 6) & 0x3);
++            dest[used++] = '0' + ((static_cast<uint8_t>(*src) >> 3) & 0x7);
++            dest[used++] = '0' + (static_cast<uint8_t>(*src) & 0x7);
++          }
+           is_hex_escape = use_hex;
+-          used += 4;
+         } else {
+           dest[used++] = *src; break;
+         }
diff --git a/upstream_utils/stack_walker_patches/0001-Add-advapi-pragma.patch b/upstream_utils/stack_walker_patches/0001-Add-advapi-pragma.patch
new file mode 100644
index 0000000..d85bd5e
--- /dev/null
+++ b/upstream_utils/stack_walker_patches/0001-Add-advapi-pragma.patch
@@ -0,0 +1,21 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Thad House <thadhouse1@gmail.com>
+Date: Sat, 22 Jul 2023 13:03:13 -0700
+Subject: [PATCH] Add advapi pragma
+
+---
+ Main/StackWalker/StackWalker.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Main/StackWalker/StackWalker.cpp b/Main/StackWalker/StackWalker.cpp
+index 89545f8612d0d099d48fcf4184a2f2a30cf8577f..b2bcbaa447c5db1a3bcc155fb317ebc8a8050e79 100644
+--- a/Main/StackWalker/StackWalker.cpp
++++ b/Main/StackWalker/StackWalker.cpp
+@@ -91,6 +91,7 @@
+ #include <new>
+
+ #pragma comment(lib, "version.lib") // for "VerQueryValue"
++#pragma comment(lib, "Advapi32.lib") // for "GetUserName"
+
+ #pragma warning(disable : 4826)
+ #if _MSC_VER >= 1900
diff --git a/upstream_utils/stack_walker_patches/0001-Apply-PR-35.patch b/upstream_utils/stack_walker_patches/0001-Apply-PR-35.patch
deleted file mode 100644
index 8fe466e..0000000
--- a/upstream_utils/stack_walker_patches/0001-Apply-PR-35.patch
+++ /dev/null
@@ -1,1353 +0,0 @@
-From 6e2f70b7bb7c59fe99b7469bf3e3a257876403dc Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Sun, 22 May 2022 23:58:57 -0400
-Subject: [PATCH 1/3] Apply PR #35
-
----
- .gitignore                              |   9 +
- Main/StackWalker/StackWalker.cpp        | 642 ++++++++++--------------
- Main/StackWalker/StackWalker.h          |  40 +-
- Main/StackWalker/StackWalker_VC2017.sln |  16 +-
- Main/StackWalker/main.cpp               |   2 +-
- 5 files changed, 306 insertions(+), 403 deletions(-)
- create mode 100644 .gitignore
-
-diff --git a/.gitignore b/.gitignore
-new file mode 100644
-index 0000000..5d102c5
---- /dev/null
-+++ b/.gitignore
-@@ -0,0 +1,9 @@
-+################################################################################
-+# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
-+################################################################################
-+
-+*.suo
-+*.db
-+*.sqlite
-+/Main/StackWalker/_ReSharper.Caches/*
-+/.vs/*
-diff --git a/Main/StackWalker/StackWalker.cpp b/Main/StackWalker/StackWalker.cpp
-index 7008ac6..48c7c57 100644
---- a/Main/StackWalker/StackWalker.cpp
-+++ b/Main/StackWalker/StackWalker.cpp
-@@ -1,4 +1,4 @@
--/**********************************************************************
-+/**********************************************************************
-  *
-  * StackWalker.cpp
-  * https://github.com/JochenKalmbach/StackWalker
-@@ -87,162 +87,36 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <tchar.h>
--#include <windows.h>
- #pragma comment(lib, "version.lib") // for "VerQueryValue"
- #pragma warning(disable : 4826)
- 
-+#ifdef UNICODE
-+  #define DBGHELP_TRANSLATE_TCHAR
- 
--// If VC7 and later, then use the shipped 'dbghelp.h'-file
-+#endif
- #pragma pack(push, 8)
--#if _MSC_VER >= 1300
- #include <dbghelp.h>
--#else
--// inline the important dbghelp.h-declarations...
--typedef enum
--{
--  SymNone = 0,
--  SymCoff,
--  SymCv,
--  SymPdb,
--  SymExport,
--  SymDeferred,
--  SymSym,
--  SymDia,
--  SymVirtual,
--  NumSymTypes
--} SYM_TYPE;
--typedef struct _IMAGEHLP_LINE64
--{
--  DWORD   SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
--  PVOID   Key;          // internal
--  DWORD   LineNumber;   // line number in file
--  PCHAR   FileName;     // full filename
--  DWORD64 Address;      // first instruction of line
--} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
--typedef struct _IMAGEHLP_MODULE64
--{
--  DWORD    SizeOfStruct;         // set to sizeof(IMAGEHLP_MODULE64)
--  DWORD64  BaseOfImage;          // base load address of module
--  DWORD    ImageSize;            // virtual size of the loaded module
--  DWORD    TimeDateStamp;        // date/time stamp from pe header
--  DWORD    CheckSum;             // checksum from the pe header
--  DWORD    NumSyms;              // number of symbols in the symbol table
--  SYM_TYPE SymType;              // type of symbols loaded
--  CHAR     ModuleName[32];       // module name
--  CHAR     ImageName[256];       // image name
--  CHAR     LoadedImageName[256]; // symbol file name
--} IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
--typedef struct _IMAGEHLP_SYMBOL64
--{
--  DWORD   SizeOfStruct;  // set to sizeof(IMAGEHLP_SYMBOL64)
--  DWORD64 Address;       // virtual address including dll base address
--  DWORD   Size;          // estimated size of symbol, can be zero
--  DWORD   Flags;         // info about the symbols, see the SYMF defines
--  DWORD   MaxNameLength; // maximum size of symbol name in 'Name'
--  CHAR    Name[1];       // symbol name (null terminated string)
--} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
--typedef enum
--{
--  AddrMode1616,
--  AddrMode1632,
--  AddrModeReal,
--  AddrModeFlat
--} ADDRESS_MODE;
--typedef struct _tagADDRESS64
--{
--  DWORD64      Offset;
--  WORD         Segment;
--  ADDRESS_MODE Mode;
--} ADDRESS64, *LPADDRESS64;
--typedef struct _KDHELP64
--{
--  DWORD64 Thread;
--  DWORD   ThCallbackStack;
--  DWORD   ThCallbackBStore;
--  DWORD   NextCallback;
--  DWORD   FramePointer;
--  DWORD64 KiCallUserMode;
--  DWORD64 KeUserCallbackDispatcher;
--  DWORD64 SystemRangeStart;
--  DWORD64 Reserved[8];
--} KDHELP64, *PKDHELP64;
--typedef struct _tagSTACKFRAME64
--{
--  ADDRESS64 AddrPC;         // program counter
--  ADDRESS64 AddrReturn;     // return address
--  ADDRESS64 AddrFrame;      // frame pointer
--  ADDRESS64 AddrStack;      // stack pointer
--  ADDRESS64 AddrBStore;     // backing store pointer
--  PVOID     FuncTableEntry; // pointer to pdata/fpo or NULL
--  DWORD64   Params[4];      // possible arguments to the function
--  BOOL      Far;            // WOW far call
--  BOOL      Virtual;        // is this a virtual frame?
--  DWORD64   Reserved[3];
--  KDHELP64  KdHelp;
--} STACKFRAME64, *LPSTACKFRAME64;
--typedef BOOL(__stdcall* PREAD_PROCESS_MEMORY_ROUTINE64)(HANDLE  hProcess,
--                                                        DWORD64 qwBaseAddress,
--                                                        PVOID   lpBuffer,
--                                                        DWORD   nSize,
--                                                        LPDWORD lpNumberOfBytesRead);
--typedef PVOID(__stdcall* PFUNCTION_TABLE_ACCESS_ROUTINE64)(HANDLE hProcess, DWORD64 AddrBase);
--typedef DWORD64(__stdcall* PGET_MODULE_BASE_ROUTINE64)(HANDLE hProcess, DWORD64 Address);
--typedef DWORD64(__stdcall* PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE      hProcess,
--                                                         HANDLE      hThread,
--                                                         LPADDRESS64 lpaddr);
--
--// clang-format off
--#define SYMOPT_CASE_INSENSITIVE         0x00000001
--#define SYMOPT_UNDNAME                  0x00000002
--#define SYMOPT_DEFERRED_LOADS           0x00000004
--#define SYMOPT_NO_CPP                   0x00000008
--#define SYMOPT_LOAD_LINES               0x00000010
--#define SYMOPT_OMAP_FIND_NEAREST        0x00000020
--#define SYMOPT_LOAD_ANYTHING            0x00000040
--#define SYMOPT_IGNORE_CVREC             0x00000080
--#define SYMOPT_NO_UNQUALIFIED_LOADS     0x00000100
--#define SYMOPT_FAIL_CRITICAL_ERRORS     0x00000200
--#define SYMOPT_EXACT_SYMBOLS            0x00000400
--#define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS   0x00000800
--#define SYMOPT_IGNORE_NT_SYMPATH        0x00001000
--#define SYMOPT_INCLUDE_32BIT_MODULES    0x00002000
--#define SYMOPT_PUBLICS_ONLY             0x00004000
--#define SYMOPT_NO_PUBLICS               0x00008000
--#define SYMOPT_AUTO_PUBLICS             0x00010000
--#define SYMOPT_NO_IMAGE_SEARCH          0x00020000
--#define SYMOPT_SECURE                   0x00040000
--#define SYMOPT_DEBUG                    0x80000000
--#define UNDNAME_COMPLETE                 (0x0000) // Enable full undecoration
--#define UNDNAME_NAME_ONLY                (0x1000) // Crack only the name for primary declaration;
--// clang-format on
--
--#endif // _MSC_VER < 1300
- #pragma pack(pop)
- 
--// Some missing defines (for VC5/6):
--#ifndef INVALID_FILE_ATTRIBUTES
--#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
--#endif
- 
--// secure-CRT_functions are only available starting with VC8
--#if _MSC_VER < 1400
--#define strcpy_s(dst, len, src) strcpy(dst, src)
--#define strncpy_s(dst, len, src, maxLen) strncpy(dst, len, src)
--#define strcat_s(dst, len, src) strcat(dst, src)
--#define _snprintf_s _snprintf
--#define _tcscat_s _tcscat
--#endif
--
--static void MyStrCpy(char* szDest, size_t nMaxDestSize, const char* szSrc)
-+static void MyStrCpy(TCHAR* szDest, size_t nMaxDestSize, const TCHAR* szSrc)
- {
-   if (nMaxDestSize <= 0)
-     return;
--  strncpy_s(szDest, nMaxDestSize, szSrc, _TRUNCATE);
-+  _tcsncpy_s(szDest, nMaxDestSize, szSrc, _TRUNCATE);
-   // INFO: _TRUNCATE will ensure that it is null-terminated;
-   // but with older compilers (<1400) it uses "strncpy" and this does not!)
-   szDest[nMaxDestSize - 1] = 0;
- } // MyStrCpy
- 
-+#ifdef _UNICODE
-+  typedef SYMBOL_INFOW   tSymbolInfo;
-+  typedef IMAGEHLP_LINEW64  tImageHelperLine;
-+#else
-+  typedef SYMBOL_INFO   tSymbolInfo;
-+  typedef IMAGEHLP_LINE64  tImageHelperLine;
-+#endif
-+
- // Normally it should be enough to use 'CONTEXT_FULL' (better would be 'CONTEXT_ALL')
- #define USED_CONTEXT_FLAGS CONTEXT_FULL
- 
-@@ -253,26 +127,26 @@ public:
-   {
-     m_parent = parent;
-     m_hDbhHelp = NULL;
--    pSC = NULL;
-+    symCleanup = NULL;
-     m_hProcess = hProcess;
-     m_szSymPath = NULL;
--    pSFTA = NULL;
--    pSGLFA = NULL;
--    pSGMB = NULL;
--    pSGMI = NULL;
--    pSGO = NULL;
--    pSGSFA = NULL;
--    pSI = NULL;
--    pSLM = NULL;
--    pSSO = NULL;
--    pSW = NULL;
--    pUDSN = NULL;
--    pSGSP = NULL;
-+    symFunctionTableAccess64 = NULL;
-+    symGetLineFromAddr64 = NULL;
-+    symGetModuleBase64 = NULL;
-+    symGetModuleInfo64 = NULL;
-+    symGetOptions = NULL;
-+    symFromAddr = NULL;
-+    symInitialize = NULL;
-+    symLoadModuleEx = NULL;
-+    symSetOptions = NULL;
-+    stackWalk64 = NULL;
-+    unDecorateSymbolName = NULL;
-+    symGetSearchPath = NULL;
-   }
-   ~StackWalkerInternal()
-   {
--    if (pSC != NULL)
--      pSC(m_hProcess); // SymCleanup
-+    if (symCleanup != NULL)
-+      symCleanup(m_hProcess); // SymCleanup
-     if (m_hDbhHelp != NULL)
-       FreeLibrary(m_hDbhHelp);
-     m_hDbhHelp = NULL;
-@@ -281,7 +155,7 @@ public:
-       free(m_szSymPath);
-     m_szSymPath = NULL;
-   }
--  BOOL Init(LPCSTR szSymPath)
-+  BOOL Init(LPCTSTR szSymPath)
-   {
-     if (m_parent == NULL)
-       return FALSE;
-@@ -354,54 +228,72 @@ public:
-       m_hDbhHelp = LoadLibrary(_T("dbghelp.dll"));
-     if (m_hDbhHelp == NULL)
-       return FALSE;
--    pSI = (tSI)GetProcAddress(m_hDbhHelp, "SymInitialize");
--    pSC = (tSC)GetProcAddress(m_hDbhHelp, "SymCleanup");
--
--    pSW = (tSW)GetProcAddress(m_hDbhHelp, "StackWalk64");
--    pSGO = (tSGO)GetProcAddress(m_hDbhHelp, "SymGetOptions");
--    pSSO = (tSSO)GetProcAddress(m_hDbhHelp, "SymSetOptions");
--
--    pSFTA = (tSFTA)GetProcAddress(m_hDbhHelp, "SymFunctionTableAccess64");
--    pSGLFA = (tSGLFA)GetProcAddress(m_hDbhHelp, "SymGetLineFromAddr64");
--    pSGMB = (tSGMB)GetProcAddress(m_hDbhHelp, "SymGetModuleBase64");
--    pSGMI = (tSGMI)GetProcAddress(m_hDbhHelp, "SymGetModuleInfo64");
--    pSGSFA = (tSGSFA)GetProcAddress(m_hDbhHelp, "SymGetSymFromAddr64");
--    pUDSN = (tUDSN)GetProcAddress(m_hDbhHelp, "UnDecorateSymbolName");
--    pSLM = (tSLM)GetProcAddress(m_hDbhHelp, "SymLoadModule64");
--    pSGSP = (tSGSP)GetProcAddress(m_hDbhHelp, "SymGetSearchPath");
--
--    if (pSC == NULL || pSFTA == NULL || pSGMB == NULL || pSGMI == NULL || pSGO == NULL ||
--        pSGSFA == NULL || pSI == NULL || pSSO == NULL || pSW == NULL || pUDSN == NULL ||
--        pSLM == NULL)
-+
-+#ifdef _UNICODE
-+    static const char strSymInitialize[] = "SymInitializeW";
-+    static const char strUnDecorateSymbolName[] = "UnDecorateSymbolNameW";
-+    static const char strSymGetSearchPath[] = "SymGetSearchPathW";
-+    static const char strSymLoadModuleEx[] = "SymLoadModuleExW";
-+    static const char strSymGetLineFromAddr64[] = "SymGetLineFromAddrW64";
-+    static const char strSymGetModuleInfo64[] = "SymGetModuleInfoW64";
-+    static const char strSymFromAddr[] = "SymFromAddrW";
-+#else
-+    static const char strSymInitialize[] = "SymInitialize";
-+    static const char strUnDecorateSymbolName[] = "UnDecorateSymbolName";
-+    static const char strSymGetSearchPath[] = "SymGetSearchPath";
-+    static const char strSymLoadModuleEx[] = "SymLoadModuleEx";
-+    static const char strSymGetLineFromAddr64[] = "SymGetLineFromAddr64";
-+    static const char strSymGetModuleInfo64[] = "SymGetModuleInfo64";
-+    static const char strSymFromAddr[] = "SymFromAddr";
-+#endif
-+    symInitialize = (tSI)GetProcAddress(m_hDbhHelp, strSymInitialize);
-+    symCleanup = (tSC)GetProcAddress(m_hDbhHelp, "SymCleanup");
-+
-+    stackWalk64 = (tSW)GetProcAddress(m_hDbhHelp, "StackWalk64");
-+    symGetOptions = (tSGO)GetProcAddress(m_hDbhHelp, "SymGetOptions");
-+    symSetOptions = (tSSO)GetProcAddress(m_hDbhHelp, "SymSetOptions");
-+
-+    symFunctionTableAccess64 = (tSFTA)GetProcAddress(m_hDbhHelp, "SymFunctionTableAccess64");
-+    symGetLineFromAddr64 = (tSGLFA)GetProcAddress(m_hDbhHelp, strSymGetLineFromAddr64);
-+    symGetModuleBase64 = (tSGMB)GetProcAddress(m_hDbhHelp, "SymGetModuleBase64");
-+    symGetModuleInfo64 = (tSGMI)GetProcAddress(m_hDbhHelp, strSymGetModuleInfo64);
-+    symFromAddr = (tSFA)GetProcAddress(m_hDbhHelp, strSymFromAddr);
-+    unDecorateSymbolName = (tUDSN)GetProcAddress(m_hDbhHelp, strUnDecorateSymbolName);
-+    symLoadModuleEx = (tSLM)GetProcAddress(m_hDbhHelp, strSymLoadModuleEx);
-+    symGetSearchPath = (tSGSP)GetProcAddress(m_hDbhHelp, strSymGetSearchPath);
-+
-+    if (symCleanup == NULL || symFunctionTableAccess64 == NULL || symGetModuleBase64 == NULL || symGetModuleInfo64 == NULL || symGetOptions == NULL ||
-+        symFromAddr == NULL || symInitialize == NULL || symSetOptions == NULL || stackWalk64 == NULL || unDecorateSymbolName == NULL ||
-+        symLoadModuleEx == NULL)
-     {
-       FreeLibrary(m_hDbhHelp);
-       m_hDbhHelp = NULL;
--      pSC = NULL;
-+      symCleanup = NULL;
-       return FALSE;
-     }
- 
-     // SymInitialize
-     if (szSymPath != NULL)
--      m_szSymPath = _strdup(szSymPath);
--    if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE)
--      this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0);
-+      m_szSymPath = _tcsdup(szSymPath);
-+    if (this->symInitialize(m_hProcess, m_szSymPath, FALSE) == FALSE)
-+      this->m_parent->OnDbgHelpErr(_T("SymInitialize"), GetLastError(), 0);
- 
--    DWORD symOptions = this->pSGO(); // SymGetOptions
-+    DWORD symOptions = this->symGetOptions(); // SymGetOptions
-     symOptions |= SYMOPT_LOAD_LINES;
-     symOptions |= SYMOPT_FAIL_CRITICAL_ERRORS;
-     //symOptions |= SYMOPT_NO_PROMPTS;
-     // SymSetOptions
--    symOptions = this->pSSO(symOptions);
-+    symOptions = this->symSetOptions(symOptions);
- 
--    char buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0};
--    if (this->pSGSP != NULL)
-+    TCHAR buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0};
-+    if (this->symGetSearchPath != NULL)
-     {
--      if (this->pSGSP(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE)
--        this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0);
-+      if (this->symGetSearchPath(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE)
-+        this->m_parent->OnDbgHelpErr(_T("SymGetSearchPath"), GetLastError(), 0);
-     }
--    char  szUserName[1024] = {0};
-+    TCHAR  szUserName[1024] = {0};
-     DWORD dwSize = 1024;
--    GetUserNameA(szUserName, &dwSize);
-+    GetUserName(szUserName, &dwSize);
-     this->m_parent->OnSymInit(buf, symOptions, szUserName);
- 
-     return TRUE;
-@@ -411,7 +303,7 @@ public:
- 
-   HMODULE m_hDbhHelp;
-   HANDLE  m_hProcess;
--  LPSTR   m_szSymPath;
-+  LPTSTR   m_szSymPath;
- 
- #pragma pack(push, 8)
-   typedef struct IMAGEHLP_MODULE64_V3
-@@ -423,13 +315,13 @@ public:
-     DWORD    CheckSum;             // checksum from the pe header
-     DWORD    NumSyms;              // number of symbols in the symbol table
-     SYM_TYPE SymType;              // type of symbols loaded
--    CHAR     ModuleName[32];       // module name
--    CHAR     ImageName[256];       // image name
--    CHAR     LoadedImageName[256]; // symbol file name
-+    TCHAR     ModuleName[32];       // module name
-+    TCHAR     ImageName[256];       // image name
-+    TCHAR     LoadedImageName[256]; // symbol file name
-     // new elements: 07-Jun-2002
--    CHAR  LoadedPdbName[256];   // pdb file name
-+    TCHAR  LoadedPdbName[256];   // pdb file name
-     DWORD CVSig;                // Signature of the CV record in the debug directories
--    CHAR  CVData[MAX_PATH * 3]; // Contents of the CV record
-+    TCHAR  CVData[MAX_PATH * 3]; // Contents of the CV record
-     DWORD PdbSig;               // Signature of PDB
-     GUID  PdbSig70;             // Signature of PDB (VC 7 and up)
-     DWORD PdbAge;               // DBI age of pdb
-@@ -460,56 +352,59 @@ public:
- 
-   // SymCleanup()
-   typedef BOOL(__stdcall* tSC)(IN HANDLE hProcess);
--  tSC pSC;
-+  tSC symCleanup;
- 
-   // SymFunctionTableAccess64()
-   typedef PVOID(__stdcall* tSFTA)(HANDLE hProcess, DWORD64 AddrBase);
--  tSFTA pSFTA;
-+  tSFTA symFunctionTableAccess64;
- 
-   // SymGetLineFromAddr64()
-   typedef BOOL(__stdcall* tSGLFA)(IN HANDLE hProcess,
-                                   IN DWORD64 dwAddr,
-                                   OUT PDWORD pdwDisplacement,
--                                  OUT PIMAGEHLP_LINE64 Line);
--  tSGLFA pSGLFA;
-+                                  OUT tImageHelperLine* Line);
-+  tSGLFA symGetLineFromAddr64;
- 
-   // SymGetModuleBase64()
-   typedef DWORD64(__stdcall* tSGMB)(IN HANDLE hProcess, IN DWORD64 dwAddr);
--  tSGMB pSGMB;
-+  tSGMB symGetModuleBase64;
- 
-   // SymGetModuleInfo64()
-   typedef BOOL(__stdcall* tSGMI)(IN HANDLE hProcess,
-                                  IN DWORD64 dwAddr,
-                                  OUT IMAGEHLP_MODULE64_V3* ModuleInfo);
--  tSGMI pSGMI;
-+  tSGMI symGetModuleInfo64;
- 
-   // SymGetOptions()
-   typedef DWORD(__stdcall* tSGO)(VOID);
--  tSGO pSGO;
-+  tSGO symGetOptions;
-+
- 
-   // SymGetSymFromAddr64()
--  typedef BOOL(__stdcall* tSGSFA)(IN HANDLE hProcess,
--                                  IN DWORD64 dwAddr,
-+  typedef BOOL(__stdcall* tSFA)(IN HANDLE hProcess,
-+                                  IN DWORD64 Address,
-                                   OUT PDWORD64 pdwDisplacement,
--                                  OUT PIMAGEHLP_SYMBOL64 Symbol);
--  tSGSFA pSGSFA;
-+                                  OUT tSymbolInfo* Symbol);
-+  tSFA symFromAddr;
- 
-   // SymInitialize()
--  typedef BOOL(__stdcall* tSI)(IN HANDLE hProcess, IN PSTR UserSearchPath, IN BOOL fInvadeProcess);
--  tSI pSI;
-+  typedef BOOL(__stdcall* tSI)(IN HANDLE hProcess, IN PTSTR UserSearchPath, IN BOOL fInvadeProcess);
-+  tSI symInitialize;
- 
-   // SymLoadModule64()
-   typedef DWORD64(__stdcall* tSLM)(IN HANDLE hProcess,
-                                    IN HANDLE hFile,
--                                   IN PSTR ImageName,
--                                   IN PSTR ModuleName,
-+                                   IN PTSTR ImageName,
-+                                   IN PTSTR ModuleName,
-                                    IN DWORD64 BaseOfDll,
--                                   IN DWORD SizeOfDll);
--  tSLM pSLM;
-+                                   IN DWORD SizeOfDll,
-+                                   IN PMODLOAD_DATA Data,
-+                                   IN DWORD         Flags);
-+  tSLM symLoadModuleEx;
- 
-   // SymSetOptions()
-   typedef DWORD(__stdcall* tSSO)(IN DWORD SymOptions);
--  tSSO pSSO;
-+  tSSO symSetOptions;
- 
-   // StackWalk64()
-   typedef BOOL(__stdcall* tSW)(DWORD                            MachineType,
-@@ -521,17 +416,17 @@ public:
-                                PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
-                                PGET_MODULE_BASE_ROUTINE64       GetModuleBaseRoutine,
-                                PTRANSLATE_ADDRESS_ROUTINE64     TranslateAddress);
--  tSW pSW;
-+  tSW stackWalk64;
- 
-   // UnDecorateSymbolName()
--  typedef DWORD(__stdcall WINAPI* tUDSN)(PCSTR DecoratedName,
--                                         PSTR  UnDecoratedName,
-+  typedef DWORD(__stdcall WINAPI* tUDSN)(PCTSTR DecoratedName,
-+                                         PTSTR  UnDecoratedName,
-                                          DWORD UndecoratedLength,
-                                          DWORD Flags);
--  tUDSN pUDSN;
-+  tUDSN unDecorateSymbolName;
- 
--  typedef BOOL(__stdcall WINAPI* tSGSP)(HANDLE hProcess, PSTR SearchPath, DWORD SearchPathLength);
--  tSGSP pSGSP;
-+  typedef BOOL(__stdcall WINAPI* tSGSP)(HANDLE hProcess, PTSTR SearchPath, DWORD SearchPathLength);
-+  tSGSP symGetSearchPath;
- 
- private:
- // **************************************** ToolHelp32 ************************
-@@ -548,8 +443,8 @@ private:
-     BYTE*   modBaseAddr;   // Base address of module in th32ProcessID's context
-     DWORD   modBaseSize;   // Size in bytes of module starting at modBaseAddr
-     HMODULE hModule;       // The hModule of this module in th32ProcessID's context
--    char    szModule[MAX_MODULE_NAME32 + 1];
--    char    szExePath[MAX_PATH];
-+    TCHAR   szModule[MAX_MODULE_NAME32 + 1];
-+    TCHAR   szExePath[MAX_PATH];
-   } MODULEENTRY32;
-   typedef MODULEENTRY32* PMODULEENTRY32;
-   typedef MODULEENTRY32* LPMODULEENTRY32;
-@@ -567,25 +462,31 @@ private:
-     // try both dlls...
-     const TCHAR* dllname[] = {_T("kernel32.dll"), _T("tlhelp32.dll")};
-     HINSTANCE    hToolhelp = NULL;
--    tCT32S       pCT32S = NULL;
--    tM32F        pM32F = NULL;
--    tM32N        pM32N = NULL;
-+    tCT32S       createToolhelp32Snapshot = NULL;
-+    tM32F        module32First = NULL;
-+    tM32N        module32Next = NULL;
- 
-     HANDLE        hSnap;
--    MODULEENTRY32 me;
--    me.dwSize = sizeof(me);
-+    MODULEENTRY32 moduleEntry32;
-+    moduleEntry32.dwSize = sizeof(moduleEntry32);
-     BOOL   keepGoing;
--    size_t i;
- 
--    for (i = 0; i < (sizeof(dllname) / sizeof(dllname[0])); i++)
-+#ifdef _UNICODE
-+    static const char strModule32First[] = "Module32FirstW";
-+    static const char strModule32Next[] = "Module32NextW";
-+ #else
-+    static const char strModule32First[] = "Module32First";
-+    static const char strModule32Next[] = "Module32Next";
-+#endif
-+    for (size_t i = 0; i < (sizeof(dllname) / sizeof(dllname[0])); i++)
-     {
-       hToolhelp = LoadLibrary(dllname[i]);
-       if (hToolhelp == NULL)
-         continue;
--      pCT32S = (tCT32S)GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot");
--      pM32F = (tM32F)GetProcAddress(hToolhelp, "Module32First");
--      pM32N = (tM32N)GetProcAddress(hToolhelp, "Module32Next");
--      if ((pCT32S != NULL) && (pM32F != NULL) && (pM32N != NULL))
-+      createToolhelp32Snapshot = (tCT32S)GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot");
-+      module32First = (tM32F)GetProcAddress(hToolhelp, strModule32First);  
-+      module32Next = (tM32N)GetProcAddress(hToolhelp, strModule32Next); 
-+      if ((createToolhelp32Snapshot != NULL) && (module32First != NULL) && (module32Next != NULL))
-         break; // found the functions!
-       FreeLibrary(hToolhelp);
-       hToolhelp = NULL;
-@@ -594,21 +495,21 @@ private:
-     if (hToolhelp == NULL)
-       return FALSE;
- 
--    hSnap = pCT32S(TH32CS_SNAPMODULE, pid);
-+    hSnap = createToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
-     if (hSnap == (HANDLE)-1)
-     {
-       FreeLibrary(hToolhelp);
-       return FALSE;
-     }
- 
--    keepGoing = !!pM32F(hSnap, &me);
-+    keepGoing = !!module32First(hSnap, &moduleEntry32);
-     int cnt = 0;
-     while (keepGoing)
-     {
--      this->LoadModule(hProcess, me.szExePath, me.szModule, (DWORD64)me.modBaseAddr,
--                       me.modBaseSize);
-+      this->LoadModule(hProcess, moduleEntry32.szExePath, moduleEntry32.szModule, (DWORD64)moduleEntry32.modBaseAddr,
-+                       moduleEntry32.modBaseSize);
-       cnt++;
--      keepGoing = !!pM32N(hSnap, &me);
-+      keepGoing = !!module32Next(hSnap, &moduleEntry32);
-     }
-     CloseHandle(hSnap);
-     FreeLibrary(hToolhelp);
-@@ -631,39 +532,41 @@ private:
-     typedef BOOL(__stdcall * tEPM)(HANDLE hProcess, HMODULE * lphModule, DWORD cb,
-                                    LPDWORD lpcbNeeded);
-     // GetModuleFileNameEx()
--    typedef DWORD(__stdcall * tGMFNE)(HANDLE hProcess, HMODULE hModule, LPSTR lpFilename,
-+    typedef DWORD(__stdcall * tGMFNE)(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename,
-                                       DWORD nSize);
-     // GetModuleBaseName()
--    typedef DWORD(__stdcall * tGMBN)(HANDLE hProcess, HMODULE hModule, LPSTR lpFilename,
-+    typedef DWORD(__stdcall * tGMBN)(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename,
-                                      DWORD nSize);
-     // GetModuleInformation()
-     typedef BOOL(__stdcall * tGMI)(HANDLE hProcess, HMODULE hModule, LPMODULEINFO pmi, DWORD nSize);
- 
--    HINSTANCE hPsapi;
--    tEPM      pEPM;
--    tGMFNE    pGMFNE;
--    tGMBN     pGMBN;
--    tGMI      pGMI;
--
--    DWORD i;
--    //ModuleEntry e;
-+      //ModuleEntry e;
-     DWORD        cbNeeded;
-     MODULEINFO   mi;
-     HMODULE*     hMods = 0;
--    char*        tt = NULL;
--    char*        tt2 = NULL;
-+    TCHAR*        tt = NULL;
-+    TCHAR*        tt2 = NULL;
-     const SIZE_T TTBUFLEN = 8096;
-     int          cnt = 0;
- 
--    hPsapi = LoadLibrary(_T("psapi.dll"));
-+    HINSTANCE hPsapi = LoadLibrary(_T("psapi.dll"));
-     if (hPsapi == NULL)
-       return FALSE;
- 
--    pEPM = (tEPM)GetProcAddress(hPsapi, "EnumProcessModules");
--    pGMFNE = (tGMFNE)GetProcAddress(hPsapi, "GetModuleFileNameExA");
--    pGMBN = (tGMFNE)GetProcAddress(hPsapi, "GetModuleBaseNameA");
--    pGMI = (tGMI)GetProcAddress(hPsapi, "GetModuleInformation");
--    if ((pEPM == NULL) || (pGMFNE == NULL) || (pGMBN == NULL) || (pGMI == NULL))
-+#ifdef _UNICODE
-+    static const char strGetModuleFileName[] = "GetModuleFileNameExW";
-+    static const char strGetModuleBaseName[] = "GetModuleBaseNameW";
-+#else
-+    static const char strGetModuleFileName[] = "GetModulefileNameExA";
-+    static const char strGetModuleBaseName[] = "GetModuleBaseNameA";
-+#endif
-+
-+    tEPM   enumProcessModules = (tEPM)GetProcAddress(hPsapi, "EnumProcessModules");
-+    tGMFNE getModuleFileNameEx = (tGMFNE)GetProcAddress(hPsapi, strGetModuleFileName);
-+    tGMBN  getModuleBaseName = (tGMFNE)GetProcAddress(hPsapi, strGetModuleBaseName);
-+    tGMI   getModuleInformation = (tGMI)GetProcAddress(hPsapi, "GetModuleInformation");
-+    if ((enumProcessModules == NULL) || (getModuleFileNameEx == NULL) ||
-+        (getModuleBaseName == NULL) || (getModuleInformation == NULL))
-     {
-       // we couldn't find all functions
-       FreeLibrary(hPsapi);
-@@ -671,12 +574,12 @@ private:
-     }
- 
-     hMods = (HMODULE*)malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof(HMODULE)));
--    tt = (char*)malloc(sizeof(char) * TTBUFLEN);
--    tt2 = (char*)malloc(sizeof(char) * TTBUFLEN);
-+    tt = (TCHAR*)malloc(sizeof(TCHAR) * TTBUFLEN);
-+    tt2 = (TCHAR*)malloc(sizeof(TCHAR) * TTBUFLEN);
-     if ((hMods == NULL) || (tt == NULL) || (tt2 == NULL))
-       goto cleanup;
- 
--    if (!pEPM(hProcess, hMods, TTBUFLEN, &cbNeeded))
-+    if (!enumProcessModules(hProcess, hMods, TTBUFLEN, &cbNeeded))
-     {
-       //_ftprintf(fLogFile, _T("%lu: EPM failed, GetLastError = %lu\n"), g_dwShowCount, gle );
-       goto cleanup;
-@@ -688,20 +591,20 @@ private:
-       goto cleanup;
-     }
- 
--    for (i = 0; i < cbNeeded / sizeof(hMods[0]); i++)
-+    for (DWORD i = 0; i < cbNeeded / sizeof(hMods[0]); i++)
-     {
-       // base address, size
--      pGMI(hProcess, hMods[i], &mi, sizeof(mi));
-+      getModuleInformation(hProcess, hMods[i], &mi, sizeof(mi));
-       // image file name
-       tt[0] = 0;
--      pGMFNE(hProcess, hMods[i], tt, TTBUFLEN);
-+      getModuleFileNameEx(hProcess, hMods[i], tt, TTBUFLEN);
-       // module name
-       tt2[0] = 0;
--      pGMBN(hProcess, hMods[i], tt2, TTBUFLEN);
-+      getModuleBaseName(hProcess, hMods[i], tt2, TTBUFLEN);
- 
-       DWORD dwRes = this->LoadModule(hProcess, tt, tt2, (DWORD64)mi.lpBaseOfDll, mi.SizeOfImage);
-       if (dwRes != ERROR_SUCCESS)
--        this->m_parent->OnDbgHelpErr("LoadModule", dwRes, 0);
-+        this->m_parent->OnDbgHelpErr(_T("LoadModule"), dwRes, 0);
-       cnt++;
-     }
- 
-@@ -718,16 +621,16 @@ private:
-     return cnt != 0;
-   } // GetModuleListPSAPI
- 
--  DWORD LoadModule(HANDLE hProcess, LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size)
-+  DWORD LoadModule(HANDLE hProcess, LPCTSTR img, LPCTSTR mod, DWORD64 baseAddr, DWORD size)
-   {
--    CHAR* szImg = _strdup(img);
--    CHAR* szMod = _strdup(mod);
-+    TCHAR* szImg = _tcsdup(img);
-+    TCHAR* szMod = _tcsdup(mod);
-     DWORD result = ERROR_SUCCESS;
-     if ((szImg == NULL) || (szMod == NULL))
-       result = ERROR_NOT_ENOUGH_MEMORY;
-     else
-     {
--      if (pSLM(hProcess, 0, szImg, szMod, baseAddr, size) == 0)
-+      if (symLoadModuleEx(hProcess, 0, szImg, szMod, baseAddr, size, 0, 0) == 0)
-         result = GetLastError();
-     }
-     ULONGLONG fileVersion = 0;
-@@ -738,13 +641,13 @@ private:
-       {
-         VS_FIXEDFILEINFO* fInfo = NULL;
-         DWORD             dwHandle;
--        DWORD             dwSize = GetFileVersionInfoSizeA(szImg, &dwHandle);
-+        DWORD             dwSize = GetFileVersionInfoSize(szImg, &dwHandle);
-         if (dwSize > 0)
-         {
-           LPVOID vData = malloc(dwSize);
-           if (vData != NULL)
-           {
--            if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0)
-+            if (GetFileVersionInfo(szImg, dwHandle, dwSize, vData) != 0)
-             {
-               UINT  len;
-               TCHAR szSubBlock[] = _T("\\");
-@@ -763,41 +666,41 @@ private:
- 
-       // Retrieve some additional-infos about the module
-       IMAGEHLP_MODULE64_V3 Module;
--      const char*          szSymType = "-unknown-";
-+      const TCHAR*          szSymType = _T("-unknown-");
-       if (this->GetModuleInfo(hProcess, baseAddr, &Module) != FALSE)
-       {
-         switch (Module.SymType)
-         {
-           case SymNone:
--            szSymType = "-nosymbols-";
-+            szSymType = _T("-nosymbols-");
-             break;
-           case SymCoff: // 1
--            szSymType = "COFF";
-+            szSymType = _T("COFF");
-             break;
-           case SymCv: // 2
--            szSymType = "CV";
-+            szSymType = _T("CV");
-             break;
-           case SymPdb: // 3
--            szSymType = "PDB";
-+            szSymType = _T("PDB");
-             break;
-           case SymExport: // 4
--            szSymType = "-exported-";
-+            szSymType = _T("-exported-");
-             break;
-           case SymDeferred: // 5
--            szSymType = "-deferred-";
-+            szSymType = _T("-deferred-");
-             break;
-           case SymSym: // 6
--            szSymType = "SYM";
-+            szSymType = _T("SYM");
-             break;
-           case 7: // SymDia:
--            szSymType = "DIA";
-+            szSymType = _T("DIA");
-             break;
-           case 8: //SymVirtual:
--            szSymType = "Virtual";
-+            szSymType = _T("Virtual");
-             break;
-         }
-       }
--      LPCSTR pdbName = Module.LoadedImageName;
-+      LPCTSTR pdbName = Module.LoadedImageName;
-       if (Module.LoadedPdbName[0] != 0)
-         pdbName = Module.LoadedPdbName;
-       this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, pdbName,
-@@ -823,7 +726,7 @@ public:
-   BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V3* pModuleInfo)
-   {
-     memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3));
--    if (this->pSGMI == NULL)
-+    if (this->symGetModuleInfo64 == NULL)
-     {
-       SetLastError(ERROR_DLL_INIT_FAILED);
-       return FALSE;
-@@ -841,7 +744,7 @@ public:
-     static bool s_useV3Version = true;
-     if (s_useV3Version)
-     {
--      if (this->pSGMI(hProcess, baseAddr, (IMAGEHLP_MODULE64_V3*)pData) != FALSE)
-+      if (this->symGetModuleInfo64(hProcess, baseAddr, (IMAGEHLP_MODULE64_V3*)pData) != FALSE)
-       {
-         // only copy as much memory as is reserved...
-         memcpy(pModuleInfo, pData, sizeof(IMAGEHLP_MODULE64_V3));
-@@ -855,7 +758,7 @@ public:
-     // could not retrieve the bigger structure, try with the smaller one (as defined in VC7.1)...
-     pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2);
-     memcpy(pData, pModuleInfo, sizeof(IMAGEHLP_MODULE64_V2));
--    if (this->pSGMI(hProcess, baseAddr, (IMAGEHLP_MODULE64_V3*)pData) != FALSE)
-+    if (this->symGetModuleInfo64(hProcess, baseAddr, (IMAGEHLP_MODULE64_V3*)pData) != FALSE)
-     {
-       // only copy as much memory as is reserved...
-       memcpy(pModuleInfo, pData, sizeof(IMAGEHLP_MODULE64_V2));
-@@ -880,7 +783,7 @@ StackWalker::StackWalker(DWORD dwProcessId, HANDLE hProcess)
-   this->m_szSymPath = NULL;
-   this->m_MaxRecursionCount = 1000;
- }
--StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess)
-+StackWalker::StackWalker(int options, LPCTSTR szSymPath, DWORD dwProcessId, HANDLE hProcess)
- {
-   this->m_options = options;
-   this->m_modulesLoaded = FALSE;
-@@ -889,7 +792,7 @@ StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDL
-   this->m_dwProcessId = dwProcessId;
-   if (szSymPath != NULL)
-   {
--    this->m_szSymPath = _strdup(szSymPath);
-+    this->m_szSymPath = _tcsdup(szSymPath);
-     this->m_options |= SymBuildPath;
-   }
-   else
-@@ -918,11 +821,11 @@ BOOL StackWalker::LoadModules()
-     return TRUE;
- 
-   // Build the sym-path:
--  char* szSymPath = NULL;
-+  TCHAR* szSymPath = NULL;
-   if ((this->m_options & SymBuildPath) != 0)
-   {
-     const size_t nSymPathLen = 4096;
--    szSymPath = (char*)malloc(nSymPathLen);
-+    szSymPath = (TCHAR*)malloc(nSymPathLen * sizeof(TCHAR));
-     if (szSymPath == NULL)
-     {
-       SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-@@ -932,27 +835,27 @@ BOOL StackWalker::LoadModules()
-     // Now first add the (optional) provided sympath:
-     if (this->m_szSymPath != NULL)
-     {
--      strcat_s(szSymPath, nSymPathLen, this->m_szSymPath);
--      strcat_s(szSymPath, nSymPathLen, ";");
-+      _tcscat_s(szSymPath, nSymPathLen, this->m_szSymPath);
-+      _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-     }
- 
--    strcat_s(szSymPath, nSymPathLen, ".;");
-+    _tcscat_s(szSymPath, nSymPathLen, _T(".;"));
- 
-     const size_t nTempLen = 1024;
--    char         szTemp[nTempLen];
-+    TCHAR         szTemp[nTempLen];
-     // Now add the current directory:
--    if (GetCurrentDirectoryA(nTempLen, szTemp) > 0)
-+    if (GetCurrentDirectory(nTempLen, szTemp) > 0)
-     {
-       szTemp[nTempLen - 1] = 0;
--      strcat_s(szSymPath, nSymPathLen, szTemp);
--      strcat_s(szSymPath, nSymPathLen, ";");
-+      _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+      _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-     }
- 
-     // Now add the path for the main-module:
--    if (GetModuleFileNameA(NULL, szTemp, nTempLen) > 0)
-+    if (GetModuleFileName(NULL, szTemp, nTempLen) > 0)
-     {
-       szTemp[nTempLen - 1] = 0;
--      for (char* p = (szTemp + strlen(szTemp) - 1); p >= szTemp; --p)
-+      for (TCHAR* p = (szTemp + _tcslen(szTemp) - 1); p >= szTemp; --p)
-       {
-         // locate the rightmost path separator
-         if ((*p == '\\') || (*p == '/') || (*p == ':'))
-@@ -961,48 +864,48 @@ BOOL StackWalker::LoadModules()
-           break;
-         }
-       } // for (search for path separator...)
--      if (strlen(szTemp) > 0)
-+      if (_tcslen(szTemp) > 0)
-       {
--        strcat_s(szSymPath, nSymPathLen, szTemp);
--        strcat_s(szSymPath, nSymPathLen, ";");
-+        _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+        _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-       }
-     }
--    if (GetEnvironmentVariableA("_NT_SYMBOL_PATH", szTemp, nTempLen) > 0)
-+    if (GetEnvironmentVariable(_T("_NT_SYMBOL_PATH"), szTemp, nTempLen) > 0)
-     {
-       szTemp[nTempLen - 1] = 0;
--      strcat_s(szSymPath, nSymPathLen, szTemp);
--      strcat_s(szSymPath, nSymPathLen, ";");
-+      _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+      _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-     }
--    if (GetEnvironmentVariableA("_NT_ALTERNATE_SYMBOL_PATH", szTemp, nTempLen) > 0)
-+    if (GetEnvironmentVariable(_T("_NT_ALTERNATE_SYMBOL_PATH"), szTemp, nTempLen) > 0)
-     {
-       szTemp[nTempLen - 1] = 0;
--      strcat_s(szSymPath, nSymPathLen, szTemp);
--      strcat_s(szSymPath, nSymPathLen, ";");
-+      _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+      _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-     }
--    if (GetEnvironmentVariableA("SYSTEMROOT", szTemp, nTempLen) > 0)
-+    if (GetEnvironmentVariable(_T("SYSTEMROOT"), szTemp, nTempLen) > 0)
-     {
-       szTemp[nTempLen - 1] = 0;
--      strcat_s(szSymPath, nSymPathLen, szTemp);
--      strcat_s(szSymPath, nSymPathLen, ";");
-+      _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+      _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-       // also add the "system32"-directory:
--      strcat_s(szTemp, nTempLen, "\\system32");
--      strcat_s(szSymPath, nSymPathLen, szTemp);
--      strcat_s(szSymPath, nSymPathLen, ";");
-+      _tcscat_s(szTemp, nTempLen, _T("\\system32"));
-+      _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+      _tcscat_s(szSymPath, nSymPathLen, _T(";"));
-     }
- 
-     if ((this->m_options & SymUseSymSrv) != 0)
-     {
--      if (GetEnvironmentVariableA("SYSTEMDRIVE", szTemp, nTempLen) > 0)
-+      if (GetEnvironmentVariable(_T("SYSTEMDRIVE"), szTemp, nTempLen) > 0)
-       {
-         szTemp[nTempLen - 1] = 0;
--        strcat_s(szSymPath, nSymPathLen, "SRV*");
--        strcat_s(szSymPath, nSymPathLen, szTemp);
--        strcat_s(szSymPath, nSymPathLen, "\\websymbols");
--        strcat_s(szSymPath, nSymPathLen, "*http://msdl.microsoft.com/download/symbols;");
-+        _tcscat_s(szSymPath, nSymPathLen, _T("SRV*"));
-+        _tcscat_s(szSymPath, nSymPathLen, szTemp);
-+        _tcscat_s(szSymPath, nSymPathLen, _T("\\websymbols"));
-+        _tcscat_s(szSymPath, nSymPathLen, _T("*http://msdl.microsoft.com/download/symbols;"));
-       }
-       else
--        strcat_s(szSymPath, nSymPathLen,
--                 "SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols;");
-+        _tcscat_s(szSymPath, nSymPathLen,
-+                 _T("SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols;"));
-     }
-   } // if SymBuildPath
- 
-@@ -1013,7 +916,7 @@ BOOL StackWalker::LoadModules()
-   szSymPath = NULL;
-   if (bRet == FALSE)
-   {
--    this->OnDbgHelpErr("Error while initializing dbghelp.dll", 0, 0);
-+    this->OnDbgHelpErr(_T("Error while initializing dbghelp.dll"), 0, 0);
-     SetLastError(ERROR_DLL_INIT_FAILED);
-     return FALSE;
-   }
-@@ -1038,9 +941,10 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
- {
-   CONTEXT                                   c;
-   CallstackEntry                            csEntry;
--  IMAGEHLP_SYMBOL64*                        pSym = NULL;
-+
-+  tSymbolInfo* pSym = NULL;
-   StackWalkerInternal::IMAGEHLP_MODULE64_V3 Module;
--  IMAGEHLP_LINE64                           Line;
-+  tImageHelperLine                           Line;
-   int                                       frameNum;
-   bool                                      bLastEntryCalled = true;
-   int                                       curRecursionCount = 0;
-@@ -1125,12 +1029,12 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
- #error "Platform not supported!"
- #endif
- 
--  pSym = (IMAGEHLP_SYMBOL64*)malloc(sizeof(IMAGEHLP_SYMBOL64) + STACKWALK_MAX_NAMELEN);
-+  pSym = (tSymbolInfo*)malloc(sizeof(tSymbolInfo) + STACKWALK_MAX_NAMELEN*sizeof(TCHAR));
-   if (!pSym)
-     goto cleanup; // not enough memory...
--  memset(pSym, 0, sizeof(IMAGEHLP_SYMBOL64) + STACKWALK_MAX_NAMELEN);
--  pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
--  pSym->MaxNameLength = STACKWALK_MAX_NAMELEN;
-+  memset(pSym, 0, sizeof(tSymbolInfo) + STACKWALK_MAX_NAMELEN*sizeof(TCHAR));
-+  pSym->SizeOfStruct = sizeof(tSymbolInfo);
-+  pSym->MaxNameLen = STACKWALK_MAX_NAMELEN;
- 
-   memset(&Line, 0, sizeof(Line));
-   Line.SizeOfStruct = sizeof(Line);
-@@ -1145,11 +1049,11 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
-     // assume that either you are done, or that the stack is so hosed that the next
-     // deeper frame could not be found.
-     // CONTEXT need not to be supplied if imageTyp is IMAGE_FILE_MACHINE_I386!
--    if (!this->m_sw->pSW(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem,
--                         this->m_sw->pSFTA, this->m_sw->pSGMB, NULL))
-+    if (!this->m_sw->stackWalk64(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem,
-+                         this->m_sw->symFunctionTableAccess64, this->m_sw->symGetModuleBase64, NULL))
-     {
-       // INFO: "StackWalk64" does not set "GetLastError"...
--      this->OnDbgHelpErr("StackWalk64", 0, s.AddrPC.Offset);
-+      this->OnDbgHelpErr(_T("StackWalk64"), 0, s.AddrPC.Offset);
-       break;
-     }
- 
-@@ -1167,7 +1071,7 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
-     {
-       if ((this->m_MaxRecursionCount > 0) && (curRecursionCount > m_MaxRecursionCount))
-       {
--        this->OnDbgHelpErr("StackWalk64-Endless-Callstack!", 0, s.AddrPC.Offset);
-+        this->OnDbgHelpErr(_T("StackWalk64-Endless-Callstack!"), 0, s.AddrPC.Offset);
-         break;
-       }
-       curRecursionCount++;
-@@ -1178,23 +1082,23 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
-     {
-       // we seem to have a valid PC
-       // show procedure info (SymGetSymFromAddr64())
--      if (this->m_sw->pSGSFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromSmybol),
-+      if (this->m_sw->symFromAddr(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromSmybol),
-                              pSym) != FALSE)
-       {
-         MyStrCpy(csEntry.name, STACKWALK_MAX_NAMELEN, pSym->Name);
-         // UnDecorateSymbolName()
--        this->m_sw->pUDSN(pSym->Name, csEntry.undName, STACKWALK_MAX_NAMELEN, UNDNAME_NAME_ONLY);
--        this->m_sw->pUDSN(pSym->Name, csEntry.undFullName, STACKWALK_MAX_NAMELEN, UNDNAME_COMPLETE);
-+        DWORD res = this->m_sw->unDecorateSymbolName(pSym->Name, csEntry.undName, STACKWALK_MAX_NAMELEN, UNDNAME_NAME_ONLY);
-+        res = this->m_sw->unDecorateSymbolName(pSym->Name, csEntry.undFullName, STACKWALK_MAX_NAMELEN, UNDNAME_COMPLETE);
-       }
-       else
-       {
--        this->OnDbgHelpErr("SymGetSymFromAddr64", GetLastError(), s.AddrPC.Offset);
-+        this->OnDbgHelpErr(_T("SymGetSymFromAddr64"), GetLastError(), s.AddrPC.Offset);
-       }
- 
-       // show line number info, NT5.0-method (SymGetLineFromAddr64())
--      if (this->m_sw->pSGLFA != NULL)
-+      if (this->m_sw->symGetLineFromAddr64 != NULL)
-       { // yes, we have SymGetLineFromAddr64()
--        if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine),
-+        if (this->m_sw->symGetLineFromAddr64(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine),
-                                &Line) != FALSE)
-         {
-           csEntry.lineNumber = Line.LineNumber;
-@@ -1202,7 +1106,7 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
-         }
-         else
-         {
--          this->OnDbgHelpErr("SymGetLineFromAddr64", GetLastError(), s.AddrPC.Offset);
-+          this->OnDbgHelpErr(_T("SymGetLineFromAddr64"), GetLastError(), s.AddrPC.Offset);
-         }
-       } // yes, we have SymGetLineFromAddr64()
- 
-@@ -1252,7 +1156,7 @@ BOOL StackWalker::ShowCallstack(HANDLE                    hThread,
-       } // got module info OK
-       else
-       {
--        this->OnDbgHelpErr("SymGetModuleInfo64", GetLastError(), s.AddrPC.Offset);
-+        this->OnDbgHelpErr(_T("SymGetModuleInfo64"), GetLastError(), s.AddrPC.Offset);
-       }
-     } // we seem to have a valid PC
- 
-@@ -1298,20 +1202,20 @@ BOOL StackWalker::ShowObject(LPVOID pObject)
-   }
- 
-   // SymGetSymFromAddr64() is required
--  if (this->m_sw->pSGSFA == NULL)
-+  if (this->m_sw->symFromAddr == NULL)
-     return FALSE;
- 
-   // Show object info (SymGetSymFromAddr64())
-   DWORD64            dwAddress = DWORD64(pObject);
-   DWORD64            dwDisplacement = 0;
--  IMAGEHLP_SYMBOL64* pSym =
--      (IMAGEHLP_SYMBOL64*)malloc(sizeof(IMAGEHLP_SYMBOL64) + STACKWALK_MAX_NAMELEN);
--  memset(pSym, 0, sizeof(IMAGEHLP_SYMBOL64) + STACKWALK_MAX_NAMELEN);
--  pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
--  pSym->MaxNameLength = STACKWALK_MAX_NAMELEN;
--  if (this->m_sw->pSGSFA(this->m_hProcess, dwAddress, &dwDisplacement, pSym) == FALSE)
-+  tSymbolInfo* pSym =
-+      (tSymbolInfo*)malloc(sizeof(tSymbolInfo) + STACKWALK_MAX_NAMELEN*sizeof(TCHAR));
-+  memset(pSym, 0, sizeof(tSymbolInfo) + STACKWALK_MAX_NAMELEN*sizeof(TCHAR));
-+  pSym->SizeOfStruct = sizeof(tSymbolInfo);
-+  pSym->MaxNameLen = STACKWALK_MAX_NAMELEN;
-+  if (this->m_sw->symFromAddr(this->m_hProcess, dwAddress, &dwDisplacement, pSym) == FALSE)
-   {
--    this->OnDbgHelpErr("SymGetSymFromAddr64", GetLastError(), dwAddress);
-+    this->OnDbgHelpErr(_T("SymGetSymFromAddr64"), GetLastError(), dwAddress);
-     return FALSE;
-   }
-   // Object name output
-@@ -1342,22 +1246,22 @@ BOOL __stdcall StackWalker::myReadProcMem(HANDLE  hProcess,
-   }
- }
- 
--void StackWalker::OnLoadModule(LPCSTR    img,
--                               LPCSTR    mod,
-+void StackWalker::OnLoadModule(LPCTSTR    img,
-+                               LPCTSTR    mod,
-                                DWORD64   baseAddr,
-                                DWORD     size,
-                                DWORD     result,
--                               LPCSTR    symType,
--                               LPCSTR    pdbName,
-+                               LPCTSTR    symType,
-+                               LPCTSTR    pdbName,
-                                ULONGLONG fileVersion)
- {
--  CHAR   buffer[STACKWALK_MAX_NAMELEN];
-+  TCHAR   buffer[STACKWALK_MAX_NAMELEN];
-   size_t maxLen = STACKWALK_MAX_NAMELEN;
- #if _MSC_VER >= 1400
-   maxLen = _TRUNCATE;
- #endif
-   if (fileVersion == 0)
--    _snprintf_s(buffer, maxLen, "%s:%s (%p), size: %d (result: %d), SymType: '%s', PDB: '%s'\n",
-+    _sntprintf_s(buffer, maxLen, _T("%s:%s (%p), size: %d (result: %d), SymType: '%s', PDB: '%s'\n"),
-                 img, mod, (LPVOID)baseAddr, size, result, symType, pdbName);
-   else
-   {
-@@ -1365,9 +1269,9 @@ void StackWalker::OnLoadModule(LPCSTR    img,
-     DWORD v3 = (DWORD)((fileVersion >> 16) & 0xFFFF);
-     DWORD v2 = (DWORD)((fileVersion >> 32) & 0xFFFF);
-     DWORD v1 = (DWORD)((fileVersion >> 48) & 0xFFFF);
--    _snprintf_s(
-+    _sntprintf_s(
-         buffer, maxLen,
--        "%s:%s (%p), size: %d (result: %d), SymType: '%s', PDB: '%s', fileVersion: %d.%d.%d.%d\n",
-+        _T("%s:%s (%p), size: %d (result: %d), SymType: '%s', PDB: '%s', fileVersion: %d.%d.%d.%d\n"),
-         img, mod, (LPVOID)baseAddr, size, result, symType, pdbName, v1, v2, v3, v4);
-   }
-   buffer[STACKWALK_MAX_NAMELEN - 1] = 0; // be sure it is NULL terminated
-@@ -1376,7 +1280,7 @@ void StackWalker::OnLoadModule(LPCSTR    img,
- 
- void StackWalker::OnCallstackEntry(CallstackEntryType eType, CallstackEntry& entry)
- {
--  CHAR   buffer[STACKWALK_MAX_NAMELEN];
-+  TCHAR   buffer[STACKWALK_MAX_NAMELEN];
-   size_t maxLen = STACKWALK_MAX_NAMELEN;
- #if _MSC_VER >= 1400
-   maxLen = _TRUNCATE;
-@@ -1384,48 +1288,48 @@ void StackWalker::OnCallstackEntry(CallstackEntryType eType, CallstackEntry& ent
-   if ((eType != lastEntry) && (entry.offset != 0))
-   {
-     if (entry.name[0] == 0)
--      MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, "(function-name not available)");
-+      MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, _T("(function-name not available)"));
-     if (entry.undName[0] != 0)
-       MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, entry.undName);
-     if (entry.undFullName[0] != 0)
-       MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, entry.undFullName);
-     if (entry.lineFileName[0] == 0)
-     {
--      MyStrCpy(entry.lineFileName, STACKWALK_MAX_NAMELEN, "(filename not available)");
-+      MyStrCpy(entry.lineFileName, STACKWALK_MAX_NAMELEN, _T("(filename not available)"));
-       if (entry.moduleName[0] == 0)
--        MyStrCpy(entry.moduleName, STACKWALK_MAX_NAMELEN, "(module-name not available)");
--      _snprintf_s(buffer, maxLen, "%p (%s): %s: %s\n", (LPVOID)entry.offset, entry.moduleName,
-+        MyStrCpy(entry.moduleName, STACKWALK_MAX_NAMELEN, _T("(module-name not available)"));
-+      _sntprintf_s(buffer, maxLen, _T("%p (%s): %s: %s\n"), (LPVOID)entry.offset, entry.moduleName,
-                   entry.lineFileName, entry.name);
-     }
-     else
--      _snprintf_s(buffer, maxLen, "%s (%d): %s\n", entry.lineFileName, entry.lineNumber,
-+      _sntprintf_s(buffer, maxLen, _T("%s (%d): %s\n"), entry.lineFileName, entry.lineNumber,
-                   entry.name);
-     buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
-     OnOutput(buffer);
-   }
- }
- 
--void StackWalker::OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr)
-+void StackWalker::OnDbgHelpErr(LPCTSTR szFuncName, DWORD gle, DWORD64 addr)
- {
--  CHAR   buffer[STACKWALK_MAX_NAMELEN];
-+  TCHAR   buffer[STACKWALK_MAX_NAMELEN];
-   size_t maxLen = STACKWALK_MAX_NAMELEN;
- #if _MSC_VER >= 1400
-   maxLen = _TRUNCATE;
- #endif
--  _snprintf_s(buffer, maxLen, "ERROR: %s, GetLastError: %d (Address: %p)\n", szFuncName, gle,
-+  _sntprintf_s(buffer, maxLen, _T("ERROR: %s, GetLastError: %d (Address: %p)\n"), szFuncName, gle,
-               (LPVOID)addr);
-   buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
-   OnOutput(buffer);
- }
- 
--void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName)
-+void StackWalker::OnSymInit(LPCTSTR szSearchPath, DWORD symOptions, LPCTSTR szUserName)
- {
--  CHAR   buffer[STACKWALK_MAX_NAMELEN];
-+  TCHAR   buffer[STACKWALK_MAX_NAMELEN];
-   size_t maxLen = STACKWALK_MAX_NAMELEN;
- #if _MSC_VER >= 1400
-   maxLen = _TRUNCATE;
- #endif
--  _snprintf_s(buffer, maxLen, "SymInit: Symbol-SearchPath: '%s', symOptions: %d, UserName: '%s'\n",
-+  _sntprintf_s(buffer, maxLen, _T("SymInit: Symbol-SearchPath: '%s', symOptions: %d, UserName: '%s'\n"),
-               szSearchPath, symOptions, szUserName);
-   buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
-   OnOutput(buffer);
-@@ -1442,16 +1346,16 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
-     OnOutput(buffer);
-   }
- #else
--  OSVERSIONINFOEXA ver;
--  ZeroMemory(&ver, sizeof(OSVERSIONINFOEXA));
-+  OSVERSIONINFOEX ver;
-+  ZeroMemory(&ver, sizeof(OSVERSIONINFOEX));
-   ver.dwOSVersionInfoSize = sizeof(ver);
- #if _MSC_VER >= 1900
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
--  if (GetVersionExA((OSVERSIONINFOA*)&ver) != FALSE)
-+  if (GetVersionEx((OSVERSIONINFO*)&ver) != FALSE)
-   {
--    _snprintf_s(buffer, maxLen, "OS-Version: %d.%d.%d (%s) 0x%x-0x%x\n", ver.dwMajorVersion,
-+    _sntprintf_s(buffer, maxLen, _T("OS-Version: %d.%d.%d (%s) 0x%x-0x%x\n"), ver.dwMajorVersion,
-                 ver.dwMinorVersion, ver.dwBuildNumber, ver.szCSDVersion, ver.wSuiteMask,
-                 ver.wProductType);
-     buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
-@@ -1463,7 +1367,7 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
- #endif
- }
- 
--void StackWalker::OnOutput(LPCSTR buffer)
-+void StackWalker::OnOutput(LPCTSTR buffer)
- {
--  OutputDebugStringA(buffer);
-+  OutputDebugString(buffer);
- }
-diff --git a/Main/StackWalker/StackWalker.h b/Main/StackWalker/StackWalker.h
-index 0a004d9..03efcec 100644
---- a/Main/StackWalker/StackWalker.h
-+++ b/Main/StackWalker/StackWalker.h
-@@ -47,16 +47,6 @@
- #pragma warning(disable : 4091)
- #endif
- 
--// special defines for VC5/6 (if no actual PSDK is installed):
--#if _MSC_VER < 1300
--typedef unsigned __int64 DWORD64, *PDWORD64;
--#if defined(_WIN64)
--typedef unsigned __int64 SIZE_T, *PSIZE_T;
--#else
--typedef unsigned long SIZE_T, *PSIZE_T;
--#endif
--#endif // _MSC_VER < 1300
--
- class StackWalkerInternal; // forward
- class StackWalker
- {
-@@ -96,7 +86,7 @@ public:
-   } StackWalkOptions;
- 
-   StackWalker(int    options = OptionsAll, // 'int' is by design, to combine the enum-flags
--              LPCSTR szSymPath = NULL,
-+              LPCTSTR szSymPath = NULL,
-               DWORD  dwProcessId = GetCurrentProcessId(),
-               HANDLE hProcess = GetCurrentProcess());
-   StackWalker(DWORD dwProcessId, HANDLE hProcess);
-@@ -137,18 +127,18 @@ protected:
-   typedef struct CallstackEntry
-   {
-     DWORD64 offset; // if 0, we have no valid entry
--    CHAR    name[STACKWALK_MAX_NAMELEN];
--    CHAR    undName[STACKWALK_MAX_NAMELEN];
--    CHAR    undFullName[STACKWALK_MAX_NAMELEN];
-+    TCHAR    name[STACKWALK_MAX_NAMELEN];
-+    TCHAR    undName[STACKWALK_MAX_NAMELEN];
-+    TCHAR    undFullName[STACKWALK_MAX_NAMELEN];
-     DWORD64 offsetFromSmybol;
-     DWORD   offsetFromLine;
-     DWORD   lineNumber;
--    CHAR    lineFileName[STACKWALK_MAX_NAMELEN];
-+    TCHAR    lineFileName[STACKWALK_MAX_NAMELEN];
-     DWORD   symType;
-     LPCSTR  symTypeString;
--    CHAR    moduleName[STACKWALK_MAX_NAMELEN];
-+    TCHAR    moduleName[STACKWALK_MAX_NAMELEN];
-     DWORD64 baseOfImage;
--    CHAR    loadedImageName[STACKWALK_MAX_NAMELEN];
-+    TCHAR    loadedImageName[STACKWALK_MAX_NAMELEN];
-   } CallstackEntry;
- 
-   typedef enum CallstackEntryType
-@@ -158,24 +148,24 @@ protected:
-     lastEntry
-   } CallstackEntryType;
- 
--  virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
--  virtual void OnLoadModule(LPCSTR    img,
--                            LPCSTR    mod,
-+  virtual void OnSymInit(LPCTSTR szSearchPath, DWORD symOptions, LPCTSTR szUserName);
-+  virtual void OnLoadModule(LPCTSTR    img,
-+                            LPCTSTR    mod,
-                             DWORD64   baseAddr,
-                             DWORD     size,
-                             DWORD     result,
--                            LPCSTR    symType,
--                            LPCSTR    pdbName,
-+                            LPCTSTR    symType,
-+                            LPCTSTR    pdbName,
-                             ULONGLONG fileVersion);
-   virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry& entry);
--  virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
--  virtual void OnOutput(LPCSTR szText);
-+  virtual void OnDbgHelpErr(LPCTSTR szFuncName, DWORD gle, DWORD64 addr);
-+  virtual void OnOutput(LPCTSTR szText);
- 
-   StackWalkerInternal* m_sw;
-   HANDLE               m_hProcess;
-   DWORD                m_dwProcessId;
-   BOOL                 m_modulesLoaded;
--  LPSTR                m_szSymPath;
-+  LPTSTR               m_szSymPath;
- 
-   int m_options;
-   int m_MaxRecursionCount;
-diff --git a/Main/StackWalker/StackWalker_VC2017.sln b/Main/StackWalker/StackWalker_VC2017.sln
-index 790d550..2209e23 100644
---- a/Main/StackWalker/StackWalker_VC2017.sln
-+++ b/Main/StackWalker/StackWalker_VC2017.sln
-@@ -16,18 +16,18 @@ Global
- 		Release_VC2017-UNICODE|x64 = Release_VC2017-UNICODE|x64
- 	EndGlobalSection
- 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|Win32.ActiveCfg = Debug_VC2017-UNICODE|Win32
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|Win32.Build.0 = Debug_VC2017-UNICODE|Win32
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|x64.ActiveCfg = Debug_VC2017-UNICODE|x64
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|x64.Build.0 = Debug_VC2017-UNICODE|x64
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|Win32.ActiveCfg = Debug_VC2017|Win32
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|Win32.Build.0 = Debug_VC2017|Win32
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|x64.ActiveCfg = Debug_VC2017|x64
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017|x64.Build.0 = Debug_VC2017|x64
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|Win32.ActiveCfg = Debug_VC2017-UNICODE|Win32
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|Win32.Build.0 = Debug_VC2017-UNICODE|Win32
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|x64.ActiveCfg = Debug_VC2017-UNICODE|x64
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Debug_VC2017-UNICODE|x64.Build.0 = Debug_VC2017-UNICODE|x64
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|Win32.ActiveCfg = Release_VC2017-UNICODE|Win32
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|Win32.Build.0 = Release_VC2017-UNICODE|Win32
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|x64.ActiveCfg = Release_VC2017-UNICODE|x64
--		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|x64.Build.0 = Release_VC2017-UNICODE|x64
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|Win32.ActiveCfg = Release_VC2017|Win32
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|Win32.Build.0 = Release_VC2017|Win32
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|x64.ActiveCfg = Release_VC2017|x64
-+		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017|x64.Build.0 = Release_VC2017|x64
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|Win32.ActiveCfg = Release_VC2017-UNICODE|Win32
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|Win32.Build.0 = Release_VC2017-UNICODE|Win32
- 		{89B2BD42-B130-4811-9043-71A8EBC40DE5}.Release_VC2017-UNICODE|x64.ActiveCfg = Release_VC2017-UNICODE|x64
-diff --git a/Main/StackWalker/main.cpp b/Main/StackWalker/main.cpp
-index 220c97b..496021e 100644
---- a/Main/StackWalker/main.cpp
-+++ b/Main/StackWalker/main.cpp
-@@ -33,7 +33,7 @@ void (*pGlobalFuncPtr)() = 0;
- class StackWalkerToConsole : public StackWalker
- {
- protected:
--  virtual void OnOutput(LPCSTR szText) { printf("%s", szText); }
-+  virtual void OnOutput(LPCTSTR szText) { _tprintf(_T("%s"), szText); }
- };
- 
- void Func5()
diff --git a/upstream_utils/stack_walker_patches/0002-Remove-_M_IX86-checks.patch b/upstream_utils/stack_walker_patches/0002-Remove-_M_IX86-checks.patch
deleted file mode 100644
index 14d7bae..0000000
--- a/upstream_utils/stack_walker_patches/0002-Remove-_M_IX86-checks.patch
+++ /dev/null
@@ -1,79 +0,0 @@
-From 238eda525de70b57bade634447c967f4f92bc96d Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Mon, 23 May 2022 00:06:45 -0400
-Subject: [PATCH 2/3] Remove _M_IX86 checks
-
----
- Main/StackWalker/StackWalker.h | 52 ----------------------------------
- 1 file changed, 52 deletions(-)
-
-diff --git a/Main/StackWalker/StackWalker.h b/Main/StackWalker/StackWalker.h
-index 03efcec..89be951 100644
---- a/Main/StackWalker/StackWalker.h
-+++ b/Main/StackWalker/StackWalker.h
-@@ -179,57 +179,6 @@ protected:
-   friend StackWalkerInternal;
- }; // class StackWalker
- 
--// The "ugly" assembler-implementation is needed for systems before XP
--// If you have a new PSDK and you only compile for XP and later, then you can use
--// the "RtlCaptureContext"
--// Currently there is no define which determines the PSDK-Version...
--// So we just use the compiler-version (and assumes that the PSDK is
--// the one which was installed by the VS-IDE)
--
--// INFO: If you want, you can use the RtlCaptureContext if you only target XP and later...
--//       But I currently use it in x64/IA64 environments...
--//#if defined(_M_IX86) && (_WIN32_WINNT <= 0x0500) && (_MSC_VER < 1400)
--
--#if defined(_M_IX86)
--#ifdef CURRENT_THREAD_VIA_EXCEPTION
--// TODO: The following is not a "good" implementation,
--// because the callstack is only valid in the "__except" block...
--#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags)               \
--  do                                                                            \
--  {                                                                             \
--    memset(&c, 0, sizeof(CONTEXT));                                             \
--    EXCEPTION_POINTERS* pExp = NULL;                                            \
--    __try                                                                       \
--    {                                                                           \
--      throw 0;                                                                  \
--    }                                                                           \
--    __except (((pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER   \
--                                                  : EXCEPTION_EXECUTE_HANDLER)) \
--    {                                                                           \
--    }                                                                           \
--    if (pExp != NULL)                                                           \
--      memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT));                         \
--    c.ContextFlags = contextFlags;                                              \
--  } while (0);
--#else
--// clang-format off
--// The following should be enough for walking the callstack...
--#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
--  do                                                              \
--  {                                                               \
--    memset(&c, 0, sizeof(CONTEXT));                               \
--    c.ContextFlags = contextFlags;                                \
--    __asm    call x                                               \
--    __asm x: pop eax                                              \
--    __asm    mov c.Eip, eax                                       \
--    __asm    mov c.Ebp, ebp                                       \
--    __asm    mov c.Esp, esp                                       \
--  } while (0)
--// clang-format on
--#endif
--
--#else
--
- // The following is defined for x86 (XP and higher), x64 and IA64:
- #define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
-   do                                                              \
-@@ -238,7 +187,6 @@ protected:
-     c.ContextFlags = contextFlags;                                \
-     RtlCaptureContext(&c);                                        \
-   } while (0);
--#endif
- 
- #endif //defined(_MSC_VER)
- 
diff --git a/upstream_utils/stack_walker_patches/0003-Add-advapi-pragma.patch b/upstream_utils/stack_walker_patches/0003-Add-advapi-pragma.patch
deleted file mode 100644
index f48ee4e..0000000
--- a/upstream_utils/stack_walker_patches/0003-Add-advapi-pragma.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-From 61646f76602a77059c18298caa575b95b702c94c Mon Sep 17 00:00:00 2001
-From: PJ Reiniger <pj.reiniger@gmail.com>
-Date: Tue, 24 May 2022 01:24:31 -0400
-Subject: [PATCH 3/3] Add advapi pragma
-
----
- Main/StackWalker/StackWalker.cpp | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/Main/StackWalker/StackWalker.cpp b/Main/StackWalker/StackWalker.cpp
-index 48c7c57..6f0fbf2 100644
---- a/Main/StackWalker/StackWalker.cpp
-+++ b/Main/StackWalker/StackWalker.cpp
-@@ -88,6 +88,7 @@
- #include <stdlib.h>
- #include <tchar.h>
- #pragma comment(lib, "version.lib") // for "VerQueryValue"
-+#pragma comment(lib, "Advapi32.lib") // for "GetUserName"
- #pragma warning(disable : 4826)
- 
- #ifdef UNICODE
diff --git a/upstream_utils/update_drake.py b/upstream_utils/update_drake.py
deleted file mode 100755
index 1849494..0000000
--- a/upstream_utils/update_drake.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import shutil
-
-from upstream_utils import (
-    get_repo_root,
-    clone_repo,
-    comment_out_invalid_includes,
-    walk_cwd_and_copy_if,
-    git_am,
-)
-
-
-def main():
-    upstream_root = clone_repo("https://github.com/RobotLocomotion/drake", "v1.6.0")
-    wpilib_root = get_repo_root()
-    wpimath = os.path.join(wpilib_root, "wpimath")
-
-    # Apply patches to upstream Git repo
-    os.chdir(upstream_root)
-    for f in [
-        "0001-Replace-Eigen-Dense-with-Eigen-Core.patch",
-        "0002-Add-WPILIB_DLLEXPORT-to-DARE-function-declarations.patch",
-    ]:
-        git_am(os.path.join(wpilib_root, "upstream_utils/drake_patches", f))
-
-    # Delete old install
-    for d in [
-        "src/main/native/thirdparty/drake/src",
-        "src/main/native/thirdparty/drake/include",
-        "src/test/native/cpp/drake",
-        "src/test/native/include/drake",
-    ]:
-        shutil.rmtree(os.path.join(wpimath, d), ignore_errors=True)
-
-    # Copy drake source files into allwpilib
-    src_files = walk_cwd_and_copy_if(
-        lambda dp, f: f
-        in ["drake_assert_and_throw.cc", "discrete_algebraic_riccati_equation.cc"],
-        os.path.join(wpimath, "src/main/native/thirdparty/drake/src"),
-    )
-
-    # Copy drake header files into allwpilib
-    include_files = walk_cwd_and_copy_if(
-        lambda dp, f: f
-        in [
-            "drake_assert.h",
-            "drake_assertion_error.h",
-            "is_approx_equal_abstol.h",
-            "never_destroyed.h",
-            "drake_copyable.h",
-            "drake_throw.h",
-            "discrete_algebraic_riccati_equation.h",
-        ],
-        os.path.join(wpimath, "src/main/native/thirdparty/drake/include/drake"),
-    )
-
-    # Copy drake test source files into allwpilib
-    os.chdir(os.path.join(upstream_root, "math/test"))
-    test_src_files = walk_cwd_and_copy_if(
-        lambda dp, f: f == "discrete_algebraic_riccati_equation_test.cc",
-        os.path.join(wpimath, "src/test/native/cpp/drake"),
-    )
-    os.chdir(upstream_root)
-
-    # Copy drake test header files into allwpilib
-    test_include_files = walk_cwd_and_copy_if(
-        lambda dp, f: f == "eigen_matrix_compare.h",
-        os.path.join(wpimath, "src/test/native/include/drake"),
-    )
-
-    for f in src_files:
-        comment_out_invalid_includes(
-            f, [os.path.join(wpimath, "src/main/native/thirdparty/drake/include")]
-        )
-    for f in include_files:
-        comment_out_invalid_includes(
-            f, [os.path.join(wpimath, "src/main/native/thirdparty/drake/include")]
-        )
-    for f in test_src_files:
-        comment_out_invalid_includes(
-            f,
-            [
-                os.path.join(wpimath, "src/main/native/thirdparty/drake/include"),
-                os.path.join(wpimath, "src/test/native/include"),
-            ],
-        )
-    for f in test_include_files:
-        comment_out_invalid_includes(
-            f,
-            [
-                os.path.join(wpimath, "src/main/native/thirdparty/drake/include"),
-                os.path.join(wpimath, "src/test/native/include"),
-            ],
-        )
-
-
-if __name__ == "__main__":
-    main()
diff --git a/upstream_utils/update_eigen.py b/upstream_utils/update_eigen.py
index e04689a..ce4c620 100755
--- a/upstream_utils/update_eigen.py
+++ b/upstream_utils/update_eigen.py
@@ -67,14 +67,10 @@
         "SparseCore",
         "SparseLU",
         "SparseQR",
-        "StlSupport",
         "misc",
         "plugins",
     ]
-    modules_rgx = r"|".join("/" + m for m in modules)
-
-    # "Std" matches StdDeque, StdList, and StdVector headers. Other modules are excluded.
-    return bool(re.search(modules_rgx, abspath) or "Std" in f)
+    return bool(re.search(r"|".join("/" + m for m in modules), abspath))
 
 
 def unsupported_inclusions(dp, f):
@@ -105,7 +101,11 @@
 
     # Apply patches to upstream Git repo
     os.chdir(upstream_root)
-    for f in ["0001-Disable-warnings.patch"]:
+    for f in [
+        "0001-Disable-warnings.patch",
+        "0002-Intellisense-fix.patch",
+        "0003-Eigen-Sparse-fix-warnings-Wunused-but-set-variable.patch",
+    ]:
         git_am(os.path.join(wpilib_root, "upstream_utils/eigen_patches", f))
 
     # Delete old install
diff --git a/upstream_utils/update_fmt.py b/upstream_utils/update_fmt.py
index 1088c39..746e879 100755
--- a/upstream_utils/update_fmt.py
+++ b/upstream_utils/update_fmt.py
@@ -13,7 +13,7 @@
 
 
 def main():
-    upstream_root = clone_repo("https://github.com/fmtlib/fmt", "9.1.0")
+    upstream_root = clone_repo("https://github.com/fmtlib/fmt", "10.1.1")
     wpilib_root = get_repo_root()
     wpiutil = os.path.join(wpilib_root, "wpiutil")
 
@@ -21,7 +21,7 @@
     os.chdir(upstream_root)
     for f in [
         "0001-Don-t-throw-on-write-failure.patch",
-        "0002-Suppress-C-20-clang-tidy-warning-false-positive.patch",
+        "0002-Suppress-warnings-we-can-t-fix.patch",
     ]:
         git_am(os.path.join(wpilib_root, "upstream_utils/fmt_patches", f))
 
@@ -34,13 +34,13 @@
 
     # Copy fmt source files into allwpilib
     src_files = walk_cwd_and_copy_if(
-        lambda dp, f: dp.endswith("src") and f.endswith(".cc") and f != "fmt.cc",
+        lambda dp, f: dp.startswith("./src") and f.endswith(".cc") and f != "fmt.cc",
         os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib"),
     )
 
     # Copy fmt header files into allwpilib
     include_files = walk_cwd_and_copy_if(
-        lambda dp, f: dp.endswith("include/fmt"),
+        lambda dp, f: dp.startswith("./include/fmt"),
         os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib"),
     )
 
diff --git a/upstream_utils/update_gcem.py b/upstream_utils/update_gcem.py
old mode 100644
new mode 100755
index ad1cb5a..0f3fe1f
--- a/upstream_utils/update_gcem.py
+++ b/upstream_utils/update_gcem.py
@@ -13,7 +13,7 @@
 
 
 def main():
-    upstream_root = clone_repo("https://github.com/kthohr/gcem.git", "v1.16.0")
+    upstream_root = clone_repo("https://github.com/kthohr/gcem.git", "v1.17.0")
     wpilib_root = get_repo_root()
     wpimath = os.path.join(wpilib_root, "wpimath")
 
@@ -30,9 +30,7 @@
 
     # Copy gcem include files into allwpilib
     include_files = walk_cwd_and_copy_if(
-        lambda dp, f: dp.endswith("include")
-        or dp.endswith("gcem_incl")
-        or dp.endswith("quadrature"),
+        lambda dp, f: dp.startswith("./include"),
         os.path.join(wpimath, "src/main/native/thirdparty/gcem"),
     )
 
diff --git a/upstream_utils/update_json.py b/upstream_utils/update_json.py
new file mode 100755
index 0000000..1f5839c
--- /dev/null
+++ b/upstream_utils/update_json.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+
+import os
+import shutil
+
+from upstream_utils import (
+    get_repo_root,
+    clone_repo,
+    walk_if,
+    git_am,
+)
+
+
+def main():
+    upstream_root = clone_repo("https://github.com/nlohmann/json", "v3.11.2")
+    wpilib_root = get_repo_root()
+    wpiutil = os.path.join(wpilib_root, "wpiutil")
+
+    # Apply patches to upstream Git repo
+    os.chdir(upstream_root)
+    for f in [
+        "0001-Remove-version-from-namespace.patch",
+        "0002-Make-serializer-public.patch",
+        "0003-Make-dump_escaped-take-std-string_view.patch",
+        "0004-Add-llvm-stream-support.patch",
+    ]:
+        git_am(
+            os.path.join(wpilib_root, "upstream_utils/json_patches", f),
+            use_threeway=True,
+        )
+
+    # Delete old install
+    for d in [
+        "src/main/native/thirdparty/json/include",
+    ]:
+        shutil.rmtree(os.path.join(wpiutil, d), ignore_errors=True)
+
+    # Create lists of source and destination files
+    os.chdir(os.path.join(upstream_root, "include/nlohmann"))
+    files = walk_if(".", lambda dp, f: True)
+    src_include_files = [
+        os.path.join(os.path.join(upstream_root, "include/nlohmann"), f) for f in files
+    ]
+    wpiutil_json_root = os.path.join(
+        wpiutil, "src/main/native/thirdparty/json/include/wpi"
+    )
+    dest_include_files = [
+        os.path.join(wpiutil_json_root, f.replace(".hpp", ".h")) for f in files
+    ]
+
+    # Copy json header files into allwpilib
+    for i in range(len(src_include_files)):
+        dest_dir = os.path.dirname(dest_include_files[i])
+        if not os.path.exists(dest_dir):
+            os.makedirs(dest_dir)
+        shutil.copyfile(src_include_files[i], dest_include_files[i])
+
+    for include_file in dest_include_files:
+        with open(include_file) as f:
+            content = f.read()
+
+        # Rename namespace from nlohmann to wpi
+        content = content.replace("namespace nlohmann", "namespace wpi")
+        content = content.replace("nlohmann::", "wpi::")
+
+        # Fix internal includes
+        content = content.replace(".hpp>", ".h>")
+        content = content.replace("include <nlohmann/", "include <wpi/")
+
+        # Fix include guards and other #defines
+        content = content.replace("NLOHMANN_", "WPI_")
+
+        with open(include_file, "w") as f:
+            f.write(content)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/upstream_utils/update_libuv.py b/upstream_utils/update_libuv.py
index a90a6d7..179632f 100755
--- a/upstream_utils/update_libuv.py
+++ b/upstream_utils/update_libuv.py
@@ -13,22 +13,23 @@
 
 
 def main():
-    upstream_root = clone_repo("https://github.com/libuv/libuv", "v1.44.2")
+    upstream_root = clone_repo("https://github.com/libuv/libuv", "v1.46.0")
     wpilib_root = get_repo_root()
     wpinet = os.path.join(wpilib_root, "wpinet")
 
     # Apply patches to upstream Git repo
     os.chdir(upstream_root)
     for f in [
-        "0001-Fix-missing-casts.patch",
-        "0002-Fix-warnings.patch",
-        "0003-Preprocessor-cleanup.patch",
-        "0004-Cleanup-problematic-language.patch",
-        "0005-Use-roborio-time.patch",
+        "0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch",
+        "0002-Fix-missing-casts.patch",
+        "0003-Fix-warnings.patch",
+        "0004-Preprocessor-cleanup.patch",
+        "0005-Cleanup-problematic-language.patch",
         "0006-Style-comments-cleanup.patch",
-        "0007-Squelch-GCC-12.1-warnings.patch",
-        "0008-Fix-Win32-warning-suppression-pragma.patch",
-        "0009-Avoid-unused-variable-warning-on-Mac.patch",
+        "0007-Fix-Win32-warning-suppression-pragma.patch",
+        "0008-Use-C-atomics.patch",
+        "0009-Remove-static-from-array-indices.patch",
+        "0010-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch",
     ]:
         git_am(os.path.join(wpilib_root, "upstream_utils/libuv_patches", f))
 
@@ -44,7 +45,7 @@
     ]
 
     include_files = walk_cwd_and_copy_if(
-        lambda dp, f: "include" in dp and f not in include_ignorelist,
+        lambda dp, f: dp.startswith("./include") and f not in include_ignorelist,
         os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
     )
 
@@ -65,7 +66,7 @@
         "sysinfo-memory.c",
     ]
     src_files = walk_cwd_and_copy_if(
-        lambda dp, f: "src" in dp and "docs" not in dp and f not in src_ignorelist,
+        lambda dp, f: dp.startswith("./src") and f not in src_ignorelist,
         os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
     )
 
diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py
index c2ebd12..5910396 100755
--- a/upstream_utils/update_llvm.py
+++ b/upstream_utils/update_llvm.py
@@ -13,7 +13,6 @@
 
 
 def run_global_replacements(wpiutil_llvm_files):
-
     for wpi_file in wpiutil_llvm_files:
         with open(wpi_file) as f:
             content = f.read()
@@ -29,7 +28,7 @@
 
         # Fix uses of span
         content = content.replace("span", "std::span")
-        content = content.replace('include "wpi/std::span.h"', "include <span>")
+        content = content.replace("include <std::span>", "include <span>")
         if wpi_file.endswith("ConvertUTFWrapper.cpp"):
             content = content.replace(
                 "const UTF16 *Src = reinterpret_cast<const UTF16 *>(SrcBytes.begin());",
@@ -39,6 +38,14 @@
                 "const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(SrcBytes.end());",
                 "const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(&*SrcBytes.begin() + SrcBytes.size());",
             )
+            content = content.replace(
+                "const UTF32 *Src = reinterpret_cast<const UTF32 *>(SrcBytes.begin());",
+                "const UTF32 *Src = reinterpret_cast<const UTF32 *>(&*SrcBytes.begin());",
+            )
+            content = content.replace(
+                "const UTF32 *SrcEnd = reinterpret_cast<const UTF32 *>(SrcBytes.end());",
+                "const UTF32 *SrcEnd = reinterpret_cast<const UTF32 *>(&*SrcBytes.begin() + SrcBytes.size());",
+            )
 
         # Remove unused headers
         content = content.replace('#include "llvm-c/ErrorHandling.h"\n', "")
@@ -100,7 +107,6 @@
 
 
 def find_wpiutil_llvm_files(wpiutil_root, subfolder):
-
     # These files have substantial changes, not worth managing with the patching process
     ignore_list = [
         "StringExtras.h",
@@ -165,41 +171,46 @@
 
 
 def main():
-    upstream_root = clone_repo("https://github.com/llvm/llvm-project", "llvmorg-14.0.6")
+    upstream_root = clone_repo("https://github.com/llvm/llvm-project", "llvmorg-17.0.4")
     wpilib_root = get_repo_root()
     wpiutil = os.path.join(wpilib_root, "wpiutil")
 
     # Apply patches to upstream Git repo
     os.chdir(upstream_root)
     for f in [
-        "0001-Fix-spelling-language-errors.patch",
-        "0002-Remove-StringRef-ArrayRef-and-Optional.patch",
-        "0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch",
-        "0004-Change-unique_function-storage-size.patch",
-        "0005-Threading-updates.patch",
-        "0006-ifdef-guard-safety.patch",
-        "0007-Explicitly-use-std.patch",
-        "0008-Remove-format_provider.patch",
-        "0009-Add-compiler-warning-pragmas.patch",
-        "0010-Remove-unused-functions.patch",
-        "0011-Detemplatize-SmallVectorBase.patch",
-        "0012-Add-vectors-to-raw_ostream.patch",
-        "0013-Extra-collections-features.patch",
-        "0014-EpochTracker-ABI-macro.patch",
-        "0015-Delete-numbers-from-MathExtras.patch",
-        "0016-Add-lerp-and-sgn.patch",
-        "0017-Fixup-includes.patch",
-        "0018-Use-std-is_trivially_copy_constructible.patch",
-        "0019-Windows-support.patch",
-        "0020-Prefer-fmtlib.patch",
-        "0021-Prefer-wpi-s-fs.h.patch",
-        "0022-Remove-unused-functions.patch",
-        "0023-OS-specific-changes.patch",
-        "0024-Use-SmallVector-for-UTF-conversion.patch",
-        "0025-Prefer-to-use-static-pointers-in-raw_ostream.patch",
-        "0026-constexpr-endian-byte-swap.patch",
-        "0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch",
-        "0028-Remove-StringMap-test-for-llvm-sort.patch",
+        "0001-Remove-StringRef-ArrayRef-and-Optional.patch",
+        "0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch",
+        "0003-Change-unique_function-storage-size.patch",
+        "0004-Threading-updates.patch",
+        "0005-ifdef-guard-safety.patch",
+        "0006-Explicitly-use-std.patch",
+        "0007-Remove-format_provider.patch",
+        "0008-Add-compiler-warning-pragmas.patch",
+        "0009-Remove-unused-functions.patch",
+        "0010-Detemplatize-SmallVectorBase.patch",
+        "0011-Add-vectors-to-raw_ostream.patch",
+        "0012-Extra-collections-features.patch",
+        "0013-EpochTracker-ABI-macro.patch",
+        "0014-Delete-numbers-from-MathExtras.patch",
+        "0015-Add-lerp-and-sgn.patch",
+        "0016-Fixup-includes.patch",
+        "0017-Use-std-is_trivially_copy_constructible.patch",
+        "0018-Windows-support.patch",
+        "0019-Prefer-fmtlib.patch",
+        "0020-Prefer-wpi-s-fs.h.patch",
+        "0021-Remove-unused-functions.patch",
+        "0022-OS-specific-changes.patch",
+        "0023-Use-SmallVector-for-UTF-conversion.patch",
+        "0024-Prefer-to-use-static-pointers-in-raw_ostream.patch",
+        "0025-constexpr-endian-byte-swap.patch",
+        "0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch",
+        "0027-Remove-StringMap-test-for-llvm-sort.patch",
+        "0028-Unused-variable-in-release-mode.patch",
+        "0029-Use-C-20-bit-header.patch",
+        "0030-Remove-DenseMap-GTest-printer-test.patch",
+        "0031-Replace-deprecated-std-aligned_storage_t.patch",
+        "0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch",
+        "0033-raw_ostream-Add-SetNumBytesInBuffer.patch",
     ]:
         git_am(
             os.path.join(wpilib_root, "upstream_utils/llvm_patches", f),
diff --git a/upstream_utils/update_memory.py b/upstream_utils/update_memory.py
index e72717a..6645aaf 100755
--- a/upstream_utils/update_memory.py
+++ b/upstream_utils/update_memory.py
@@ -59,7 +59,7 @@
 
 
 def main():
-    upstream_root = clone_repo("https://github.com/foonathan/memory", "v0.7-2")
+    upstream_root = clone_repo("https://github.com/foonathan/memory", "v0.7-3")
     wpilib_root = get_repo_root()
     wpiutil = os.path.join(wpilib_root, "wpiutil")
 
diff --git a/upstream_utils/update_mpack.py b/upstream_utils/update_mpack.py
index 25eabfc..68315e9 100755
--- a/upstream_utils/update_mpack.py
+++ b/upstream_utils/update_mpack.py
@@ -13,7 +13,7 @@
 
 
 def main():
-    upstream_root = clone_repo("https://github.com/ludocode/mpack", "v1.1")
+    upstream_root = clone_repo("https://github.com/ludocode/mpack", "v1.1.1")
     wpilib_root = get_repo_root()
     wpiutil = os.path.join(wpilib_root, "wpiutil")
 
@@ -31,6 +31,7 @@
         "0001-Don-t-emit-inline-defs.patch",
         "0002-Update-amalgamation-script.patch",
         "0003-Use-namespace-for-C.patch",
+        "0004-Group-doxygen-into-MPack-module.patch",
     ]:
         git_am(
             os.path.join(wpilib_root, "upstream_utils/mpack_patches", f),
diff --git a/upstream_utils/update_protobuf.py b/upstream_utils/update_protobuf.py
new file mode 100755
index 0000000..fbecb9c
--- /dev/null
+++ b/upstream_utils/update_protobuf.py
@@ -0,0 +1,307 @@
+#!/usr/bin/env python3
+
+import os
+import shutil
+
+from upstream_utils import (
+    get_repo_root,
+    clone_repo,
+    comment_out_invalid_includes,
+    copy_to,
+    walk_cwd_and_copy_if,
+    walk_if,
+    git_am,
+)
+
+protobuf_lite_sources = set(
+    [
+        "google/protobuf/any_lite.cc",
+        "google/protobuf/arena.cc",
+        "google/protobuf/arenastring.cc",
+        "google/protobuf/arenaz_sampler.cc",
+        "google/protobuf/extension_set.cc",
+        "google/protobuf/generated_enum_util.cc",
+        "google/protobuf/generated_message_tctable_lite.cc",
+        "google/protobuf/generated_message_util.cc",
+        "google/protobuf/implicit_weak_message.cc",
+        "google/protobuf/inlined_string_field.cc",
+        "google/protobuf/io/coded_stream.cc",
+        "google/protobuf/io/io_win32.cc",
+        "google/protobuf/io/strtod.cc",
+        "google/protobuf/io/zero_copy_stream.cc",
+        "google/protobuf/io/zero_copy_stream_impl.cc",
+        "google/protobuf/io/zero_copy_stream_impl_lite.cc",
+        "google/protobuf/map.cc",
+        "google/protobuf/message_lite.cc",
+        "google/protobuf/parse_context.cc",
+        "google/protobuf/repeated_field.cc",
+        "google/protobuf/repeated_ptr_field.cc",
+        "google/protobuf/stubs/bytestream.cc",
+        "google/protobuf/stubs/common.cc",
+        "google/protobuf/stubs/int128.cc",
+        "google/protobuf/stubs/status.cc",
+        "google/protobuf/stubs/statusor.cc",
+        "google/protobuf/stubs/stringpiece.cc",
+        "google/protobuf/stubs/stringprintf.cc",
+        "google/protobuf/stubs/structurally_valid.cc",
+        "google/protobuf/stubs/strutil.cc",
+        "google/protobuf/stubs/time.cc",
+        "google/protobuf/wire_format_lite.cc",
+    ]
+)
+
+protobuf_lite_includes = set(
+    [
+        "google/protobuf/any.h",
+        "google/protobuf/arena.h",
+        "google/protobuf/arena_impl.h",
+        "google/protobuf/arenastring.h",
+        "google/protobuf/arenaz_sampler.h",
+        "google/protobuf/endian.h",
+        "google/protobuf/explicitly_constructed.h",
+        "google/protobuf/extension_set.h",
+        "google/protobuf/extension_set_inl.h",
+        "google/protobuf/generated_enum_util.h",
+        "google/protobuf/generated_message_tctable_decl.h",
+        "google/protobuf/generated_message_tctable_impl.h",
+        "google/protobuf/generated_message_util.h",
+        "google/protobuf/has_bits.h",
+        "google/protobuf/implicit_weak_message.h",
+        "google/protobuf/inlined_string_field.h",
+        "google/protobuf/io/coded_stream.h",
+        "google/protobuf/io/io_win32.h",
+        "google/protobuf/io/strtod.h",
+        "google/protobuf/io/zero_copy_stream.h",
+        "google/protobuf/io/zero_copy_stream_impl.h",
+        "google/protobuf/io/zero_copy_stream_impl_lite.h",
+        "google/protobuf/map.h",
+        "google/protobuf/map_entry_lite.h",
+        "google/protobuf/map_field_lite.h",
+        "google/protobuf/map_type_handler.h",
+        "google/protobuf/message_lite.h",
+        "google/protobuf/metadata_lite.h",
+        "google/protobuf/parse_context.h",
+        "google/protobuf/port.h",
+        "google/protobuf/repeated_field.h",
+        "google/protobuf/repeated_ptr_field.h",
+        "google/protobuf/stubs/bytestream.h",
+        "google/protobuf/stubs/callback.h",
+        "google/protobuf/stubs/casts.h",
+        "google/protobuf/stubs/common.h",
+        "google/protobuf/stubs/hash.h",
+        "google/protobuf/stubs/logging.h",
+        "google/protobuf/stubs/macros.h",
+        "google/protobuf/stubs/map_util.h",
+        "google/protobuf/stubs/mutex.h",
+        "google/protobuf/stubs/once.h",
+        "google/protobuf/stubs/platform_macros.h",
+        "google/protobuf/stubs/port.h",
+        "google/protobuf/stubs/status.h",
+        "google/protobuf/stubs/stl_util.h",
+        "google/protobuf/stubs/stringpiece.h",
+        "google/protobuf/stubs/strutil.h",
+        "google/protobuf/stubs/template_util.h",
+        "google/protobuf/wire_format_lite.h",
+    ]
+)
+
+protobuf_sources = set(
+    [
+        "google/protobuf/any.cc",
+        "google/protobuf/any.pb.cc",
+        "google/protobuf/api.pb.cc",
+        "google/protobuf/compiler/importer.cc",
+        "google/protobuf/compiler/parser.cc",
+        "google/protobuf/descriptor.cc",
+        "google/protobuf/descriptor.pb.cc",
+        "google/protobuf/descriptor_database.cc",
+        "google/protobuf/duration.pb.cc",
+        "google/protobuf/dynamic_message.cc",
+        "google/protobuf/empty.pb.cc",
+        "google/protobuf/extension_set_heavy.cc",
+        "google/protobuf/field_mask.pb.cc",
+        "google/protobuf/generated_message_bases.cc",
+        "google/protobuf/generated_message_reflection.cc",
+        "google/protobuf/generated_message_tctable_full.cc",
+        "google/protobuf/io/gzip_stream.cc",
+        "google/protobuf/io/printer.cc",
+        "google/protobuf/io/tokenizer.cc",
+        "google/protobuf/map_field.cc",
+        "google/protobuf/message.cc",
+        "google/protobuf/reflection_ops.cc",
+        "google/protobuf/service.cc",
+        "google/protobuf/source_context.pb.cc",
+        "google/protobuf/struct.pb.cc",
+        "google/protobuf/stubs/substitute.cc",
+        "google/protobuf/text_format.cc",
+        "google/protobuf/timestamp.pb.cc",
+        "google/protobuf/type.pb.cc",
+        "google/protobuf/unknown_field_set.cc",
+        "google/protobuf/util/delimited_message_util.cc",
+        "google/protobuf/util/field_comparator.cc",
+        "google/protobuf/util/field_mask_util.cc",
+        "google/protobuf/util/internal/datapiece.cc",
+        "google/protobuf/util/internal/default_value_objectwriter.cc",
+        "google/protobuf/util/internal/error_listener.cc",
+        "google/protobuf/util/internal/field_mask_utility.cc",
+        "google/protobuf/util/internal/json_escaping.cc",
+        "google/protobuf/util/internal/json_objectwriter.cc",
+        "google/protobuf/util/internal/json_stream_parser.cc",
+        "google/protobuf/util/internal/object_writer.cc",
+        "google/protobuf/util/internal/proto_writer.cc",
+        "google/protobuf/util/internal/protostream_objectsource.cc",
+        "google/protobuf/util/internal/protostream_objectwriter.cc",
+        "google/protobuf/util/internal/type_info.cc",
+        "google/protobuf/util/internal/utility.cc",
+        "google/protobuf/util/json_util.cc",
+        "google/protobuf/util/message_differencer.cc",
+        "google/protobuf/util/time_util.cc",
+        "google/protobuf/util/type_resolver_util.cc",
+        "google/protobuf/wire_format.cc",
+        "google/protobuf/wrappers.pb.cc",
+    ]
+)
+
+protobuf_includes = set(
+    [
+        "google/protobuf/any.pb.h",
+        "google/protobuf/api.pb.h",
+        "google/protobuf/compiler/importer.h",
+        "google/protobuf/compiler/parser.h",
+        "google/protobuf/descriptor.h",
+        "google/protobuf/descriptor.pb.h",
+        "google/protobuf/descriptor_database.h",
+        "google/protobuf/duration.pb.h",
+        "google/protobuf/dynamic_message.h",
+        "google/protobuf/empty.pb.h",
+        "google/protobuf/field_access_listener.h",
+        "google/protobuf/field_mask.pb.h",
+        "google/protobuf/generated_enum_reflection.h",
+        "google/protobuf/generated_message_bases.h",
+        "google/protobuf/generated_message_reflection.h",
+        "google/protobuf/io/gzip_stream.h",
+        "google/protobuf/io/printer.h",
+        "google/protobuf/io/tokenizer.h",
+        "google/protobuf/map_entry.h",
+        "google/protobuf/map_field.h",
+        "google/protobuf/map_field_inl.h",
+        "google/protobuf/message.h",
+        "google/protobuf/metadata.h",
+        "google/protobuf/reflection.h",
+        "google/protobuf/reflection_internal.h",
+        "google/protobuf/reflection_ops.h",
+        "google/protobuf/service.h",
+        "google/protobuf/source_context.pb.h",
+        "google/protobuf/struct.pb.h",
+        "google/protobuf/text_format.h",
+        "google/protobuf/timestamp.pb.h",
+        "google/protobuf/type.pb.h",
+        "google/protobuf/unknown_field_set.h",
+        "google/protobuf/util/delimited_message_util.h",
+        "google/protobuf/util/field_comparator.h",
+        "google/protobuf/util/field_mask_util.h",
+        "google/protobuf/util/json_util.h",
+        "google/protobuf/util/message_differencer.h",
+        "google/protobuf/util/time_util.h",
+        "google/protobuf/util/type_resolver.h",
+        "google/protobuf/util/type_resolver_util.h",
+        "google/protobuf/wire_format.h",
+        "google/protobuf/wrappers.pb.h",
+    ]
+)
+
+protobuf_internal_includes = set(
+    [
+        "google/protobuf/port_def.inc",
+        "google/protobuf/port_undef.inc",
+        "google/protobuf/stubs/int128.h",
+        "google/protobuf/stubs/mathutil.h",
+        "google/protobuf/stubs/statusor.h",
+        "google/protobuf/stubs/status_macros.h",
+        "google/protobuf/stubs/stringprintf.h",
+        "google/protobuf/stubs/substitute.h",
+        "google/protobuf/stubs/time.h",
+        "google/protobuf/util/internal/constants.h",
+        "google/protobuf/util/internal/datapiece.h",
+        "google/protobuf/util/internal/default_value_objectwriter.h",
+        "google/protobuf/util/internal/error_listener.h",
+        "google/protobuf/util/internal/field_mask_utility.h",
+        "google/protobuf/util/internal/json_escaping.h",
+        "google/protobuf/util/internal/json_objectwriter.h",
+        "google/protobuf/util/internal/json_stream_parser.h",
+        "google/protobuf/util/internal/location_tracker.h",
+        "google/protobuf/util/internal/object_location_tracker.h",
+        "google/protobuf/util/internal/object_source.h",
+        "google/protobuf/util/internal/object_writer.h",
+        "google/protobuf/util/internal/proto_writer.h",
+        "google/protobuf/util/internal/protostream_objectsource.h",
+        "google/protobuf/util/internal/protostream_objectwriter.h",
+        "google/protobuf/util/internal/structured_objectwriter.h",
+        "google/protobuf/util/internal/type_info.h",
+        "google/protobuf/util/internal/utility.h",
+    ]
+)
+
+use_src_files = protobuf_lite_sources | protobuf_sources
+use_include_files = (
+    protobuf_lite_includes | protobuf_includes | protobuf_internal_includes
+)
+
+
+def matches(dp, f, files):
+    if not dp.startswith("./src/"):
+        return False
+    p = dp[6:] + "/" + f
+    return p in files
+
+
+def main():
+    upstream_root = clone_repo(
+        "https://github.com/protocolbuffers/protobuf", "v3.21.12"
+    )
+    wpilib_root = get_repo_root()
+    wpiutil = os.path.join(wpilib_root, "wpiutil")
+
+    # Apply patches to upstream Git repo
+    os.chdir(upstream_root)
+    for f in [
+        "0001-Fix-sign-compare-warnings.patch",
+        "0002-Remove-redundant-move.patch",
+        "0003-Fix-maybe-uninitialized-warnings.patch",
+        "0004-Fix-coded_stream-WriteRaw.patch",
+        "0005-Suppress-enum-enum-conversion-warning.patch",
+        "0006-Fix-noreturn-function-returning.patch",
+        "0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch",
+        "0008-Disable-MSVC-switch-warning.patch",
+        "0009-Disable-unused-function-warning.patch",
+        "0010-Disable-pedantic-warning.patch",
+        "0011-Avoid-use-of-sprintf.patch",
+    ]:
+        git_am(os.path.join(wpilib_root, "upstream_utils/protobuf_patches", f))
+
+    # Delete old install
+    for d in [
+        "src/main/native/thirdparty/protobuf/src",
+        "src/main/native/thirdparty/protobuf/include",
+    ]:
+        shutil.rmtree(os.path.join(wpiutil, d), ignore_errors=True)
+
+    # Copy protobuf source files into allwpilib
+    src_files = walk_if(".", lambda dp, f: matches(dp, f, use_src_files))
+    src_files = [f[22:] for f in src_files]
+    os.chdir(os.path.join(upstream_root, "src/google/protobuf"))
+    copy_to(src_files, os.path.join(wpiutil, "src/main/native/thirdparty/protobuf/src"))
+
+    # Copy protobuf header files into allwpilib
+    os.chdir(upstream_root)
+    include_files = walk_if(".", lambda dp, f: matches(dp, f, use_include_files))
+    include_files = [f[6:] for f in include_files]
+    os.chdir(os.path.join(upstream_root, "src"))
+    copy_to(
+        include_files,
+        os.path.join(wpiutil, "src/main/native/thirdparty/protobuf/include"),
+    )
+
+
+if __name__ == "__main__":
+    main()
diff --git a/upstream_utils/update_stack_walker.py b/upstream_utils/update_stack_walker.py
index 95173d2..a58886e 100755
--- a/upstream_utils/update_stack_walker.py
+++ b/upstream_utils/update_stack_walker.py
@@ -38,7 +38,7 @@
 def main():
     upstream_root = clone_repo(
         "https://github.com/JochenKalmbach/StackWalker",
-        "42e7a6e056a9e7aca911a7e9e54e2e4f90bc2652",
+        "5b0df7a4db8896f6b6dc45d36e383c52577e3c6b",
         shallow=False,
     )
     wpilib_root = get_repo_root()
@@ -50,9 +50,7 @@
     # Apply patches to upstream Git repo
     os.chdir(upstream_root)
     for f in [
-        "0001-Apply-PR-35.patch",
-        "0002-Remove-_M_IX86-checks.patch",
-        "0003-Add-advapi-pragma.patch",
+        "0001-Add-advapi-pragma.patch",
     ]:
         git_am(
             os.path.join(wpilib_root, "upstream_utils/stack_walker_patches", f),
diff --git a/upstream_utils/upstream_utils.py b/upstream_utils/upstream_utils.py
index 6454d54..ccf668b 100644
--- a/upstream_utils/upstream_utils.py
+++ b/upstream_utils/upstream_utils.py
@@ -18,7 +18,10 @@
     root -- root directory of the cloned Git repository
     """
     cwd = os.getcwd()
-    os.chdir(tempfile.gettempdir())
+    if url.startswith("file://"):
+        os.chdir(os.path.dirname(url[7:]))
+    else:
+        os.chdir(tempfile.gettempdir())
 
     repo = os.path.basename(url)
     dest = os.path.join(os.getcwd(), repo)