This is an archive of the discontinued LLVM Phabricator instance.

[Support] Move StringExtras.h include from Error.h to Error.cpp
ClosedPublic

Authored by IncludeGuardian on Jul 5 2023, 1:29 PM.

Details

Summary

Add missing parts that caused https://reviews.llvm.org/D153229 to fail compile on main.

Move the implementation of the toString function from
llvm/Support/Error.h to the source file, which allows us to move
#include "llvm/ADT/StringExtras.h" to the source file as well.

As Error.h is present in a large number of translation units this
means we are unnecessarily bringing in the contents of
StringExtras.h - itself a large file with lots of includes - and
slowing down compilation.

Also move the #include "llvm/ADT/SmallVector.h" directive to the
source file as it's no longer needed, but this does not give as much of
a benefit.

This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,920,413,050 to 1,903,629,230 - a
reduction of ~0.87%. This should result in a small improvement in
compilation time.

Diff Detail

Event Timeline

IncludeGuardian created this revision.Jul 5 2023, 1:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 1:29 PM
IncludeGuardian requested review of this revision.Jul 5 2023, 1:29 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 5 2023, 1:29 PM

Fix CompressionTest.cpp

Fix XCOFFDump.cpp

MaskRay accepted this revision.Jul 7 2023, 10:14 AM

I have spot checked a few files and the additional #include looks great!
As mentioned in the other patch, it would be better landing the #include adjustment part separately so that the llvm/Support/Error.h change is more focused.
Also, there is lower risk if something breaks, either you or someone else reverts the patch, and causes unneeded churn to many files.

This revision is now accepted and ready to land.Jul 7 2023, 10:14 AM

[llvm] Move StringExtras.h include from Error.h to Error.cpp

If you land the #include changes separately, I think the tag can be changed to [Support] . Support is sufficient to refer to llvm-project/llvm/

IncludeGuardian retitled this revision from [llvm] Move StringExtras.h include from Error.h to Error.cpp to [Support] Move StringExtras.h include from Error.h to Error.cpp.Jul 7 2023, 1:13 PM

@MaskRay Thanks. I have updated the title to use [Support] and I will land the additional includes separately to the removal. This was very good advice last attempt as it I did have to revert the change.

Rebasing on main

This revision was landed with ongoing or failed builds.Jul 8 2023, 2:20 AM
This revision was automatically updated to reflect the committed changes.