This is an archive of the discontinued LLVM Phabricator instance.

[Support] Don't include <algorithm> in MathExtras.h
ClosedPublic

Authored by thakis on Apr 16 2021, 8:44 AM.

Details

Summary

MathExtras.h is indirectly included in over 98% of LLVM's
translation units. It currently expands to over 1MB of stuff,
over which far more than half is due to <algorithm>. Since not
using <algorithm> is slighly less code, do that.

No behavior change.

Diff Detail

Event Timeline

thakis created this revision.Apr 16 2021, 8:44 AM
thakis requested review of this revision.Apr 16 2021, 8:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2021, 8:44 AM

(Found by https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html – it's unclear how many TUs don't include <algorithm> after this, maybe it's still included in most places through some other common header)

hans accepted this revision.Apr 16 2021, 8:49 AM

slightly different codegen: https://godbolt.org/z/1zebofo98
but probably just as good :)

This revision is now accepted and ready to land.Apr 16 2021, 8:49 AM
This revision was landed with ongoing or failed builds.Apr 16 2021, 8:53 AM
This revision was automatically updated to reflect the committed changes.

This broke several windows bots, for example the MLIR one:

https://lab.llvm.org/buildbot/#/builders/13/builds/6984

…isn't the fix for that to instead add the include to APInt.h? Why the revert?

Well, trying again in 0b36a33ab894 :)