This is an archive of the discontinued LLVM Phabricator instance.

Reduce dependencies on llvm/BinaryFormat/Dwarf.h
ClosedPublic

Authored by serge-sans-paille on Feb 2 2022, 5:35 AM.

Details

Summary

This header is very large (3M Lines once expended) and was included in location
where dwarf-specific information were not needed.

More specifically, this commit suppresses the dependencies on
llvm/BinaryFormat/Dwarf.h in two headers: llvm/IR/IRBuilder.h and
llvm/IR/DebugInfoMetadata.h. As these headers (esp. the former) are widely used,
this has a decent impact on number of preprocessed lines generated during
compilation of LLVM, as showcased below.

This is achieved by moving some definitions back to the .cpp file, no
performance impact implied[0].

As a consequence of that patch, downstream user may need to manually some extra
files:

llvm/IR/IRBuilder.h no longer includes llvm/BinaryFormat/Dwarf.h
llvm/IR/DebugInfoMetadata.h no longer includes llvm/BinaryFormat/Dwarf.h

In some situations, codes maybe relying on the fact that
llvm/BinaryFormat/Dwarf.h was including llvm/ADT/Triple.h, this hidden
dependency now needs to be explicit.

$ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Transforms/Scalar/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
after: 10978519
before: 11245451

Related Discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
[0] https://llvm-compile-time-tracker.com/compare.php?from=fa7145dfbf94cb93b1c3e610582c495cb806569b&to=995d3e326ee1d9489145e20762c65465a9caeab4&stat=instructions

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Feb 2 2022, 5:35 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptFeb 2 2022, 5:35 AM
$ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Transforms/Scalar/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 10978519
after: 11245451

The number of lines is now larger?

serge-sans-paille edited the summary of this revision. (Show Details)Feb 2 2022, 10:30 PM
$ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Transforms/Scalar/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 10978519
after: 11245451

The number of lines is now larger?

It's not ;-) summary updated

after: 10978519
before: 11245451

Doesn't appear to be a /huge/ win to me... but I don't mind too much.

MaskRay accepted this revision.Feb 3 2022, 12:50 PM

LGTM.

This revision is now accepted and ready to land.Feb 3 2022, 12:50 PM
This revision was landed with ongoing or failed builds.Feb 4 2022, 2:44 AM
This revision was automatically updated to reflect the committed changes.