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/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;
+