wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.07k stars 613 forks source link

[llvm][discussion] Burn down LLVM patches #4256

Open pjreiniger opened 2 years ago

pjreiniger commented 2 years ago

I tried to make the LLVM upgrade as non-invasive as possible, which resulted in 31 (some large) patches. Some of these are important quality of life ones and compiler ones, but I think there might be potential to remove some of them. If nothing else, an explanation on why some of these things are happening would be good to talk about

pjreiniger commented 2 years ago

Also would like to un-snowflake MemoryBuffer and StringExtras, but that is another issue

calcmogul commented 2 years ago

wpi::sgn() gets used a bunch in wpimath and wpilibc. wpi::Lerp() is a shim for C++20's std::lerp().

PeterJohnson commented 2 years ago

0004: The libuv wrappers and uses of them benefit from having a bit more space for captures to avoid memory allocations... I think I actually did some testing on this to decide on 4 vs 3. 0006: Seems reasonable 0007: Correct; a global replace of LLVM with WPI should work just fine 0011: The AllocatorBase.h dependencies look pretty big to me? It's not just AllocatorBase.h but the stuff that it includes... 0012: Yeah this is probably fine to pull out, we probably imported it before DenseMap 0010: Probably fine too 0016: Some of this patch can't be separated, it's directly modifying part of the raw_ostream class. And the upstream one has svector, so it feels like it belongs here. 0002: I don't know how easy it would be do this automatically (particularly since string_view doesn't have all the functions of StringRef, making it necessary to use StringExtras for some things), but this is an important QOL change and we absolutely will not go back to StringRef/ArrayRef.

A lot of StringExtras is the way it is for a reason, in that string_view doesn't have the same functions as StringRef. I would be interested in seeing how you would approach doing this as a patch?

Feel free to take a stab at MemoryBuffer; I think you'll find the patch will end up being a sizeable part of the file.

pjreiniger commented 2 years ago

wpi::sgn() gets used a bunch in wpimath and wpilibc. wpi::Lerp() is a shim for C++20's std::lerp().

<numbers> is a c++20 thing and is implemented in wpimath, these both seem very much like math utils instead of generic utils

pjreiniger commented 2 years ago

Another one I forgot to mention was 0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch

Is there a reason that NOMINMAX is not being defined globally? Its the default for bazels msvc toolchain params, and it removes the need to do this wonky (std::min)(x) stuff. I got everything compiling with that macro being set in bazel, doesn't seem like it causes any problems

calcmogul commented 2 years ago

Seems like something we should do.

PeterJohnson commented 2 years ago

Theoretically NOMINMAX could break other libraries teams pull in.

ThadHouse commented 2 years ago

For the big example, anything including gdiplus.h is broken if NOMIXMAX is defined.

calcmogul commented 2 years ago

Libraries still use GDI+?

pjreiniger commented 2 years ago

Even if they do, which is really the exception and which is the rule? I reckon the usages of std::min are far greater than the usages of gdi.

Having a team do the #undef dance if they are actually using it seems to make more sense than wrapping anything that ends in min and max in parens