This is an archive of the discontinued LLVM Phabricator instance.

Reduce header footprint of Module.h
ClosedPublic

Authored by zturner on Mar 2 2015, 5:44 PM.

Details

Summary

This is part of a larger effort to reduce header file footprints. Locally, I have a working copy of LLDB that builds between 30-40% faster than ToT. This is done almost entirely by removing header file includes from other headers where they are not needed. I have focused on the biggest offender, which is the clang headers. In particular, this and other subsequent patches will attempt to stop #including clang headers from other headers except where absolutely necessary. The way this happens in practice is that a class needs to store a ClangASTType. This patch (and the ones that follow) address this by changing by-value inclusion of ClangASTType to an std::unique_ptr<ClangASTType>, and then forward declaring the ClangASTType.

I don't expect this to be too controversial, but I want to throw up this small patch for review first before I take it as a sign that I'm going about this the right way. You probably won't notice much of a difference in build speed by applying this patch, but taken in conjunction with the rest of the patches, the build speed on my local machine is between 30-40% faster depending on the run, and I wasn't even done yet :)

Diff Detail

Repository
rL LLVM

Event Timeline

zturner updated this revision to Diff 21069.Mar 2 2015, 5:44 PM
zturner retitled this revision from to Reduce header footprint of Module.h.
zturner updated this object.
zturner edited the test plan for this revision. (Show Details)
zturner added reviewers: clayborg, jingham.
zturner added a subscriber: Unknown Object (MLST).
emaste added a subscriber: emaste.Mar 2 2015, 6:45 PM
clayborg accepted this revision.Mar 3 2015, 9:41 AM
clayborg edited edge metadata.

Looks fine.

This revision is now accepted and ready to land.Mar 3 2015, 9:41 AM
This revision was automatically updated to reflect the committed changes.

Thanks, I'll take this as a sign that it's ok to commit further patches of this nature. Let me know if you have concerns about any of the patches I submit. Removing header file includes from other headers breaks some cpp files, so I'll make sure to test on all 3 platforms before comitting anything.

This is fine as long as you don't take a simple class that contains very few things (like ClangASTType) and try to hide everything behind a unique_ptr just to avoid clang includes. I don't want to trade of compile time for run time performance (heap fragmentation).

Your fix in this patch was fine as it moved a ClangASTContext into a shared pointer which is fine as it is a large class.

Yea I don't plan to impl entire classes. If I end up with any patches that
I'm unsure about, I'll upload them for you to look at first.

What about the ClangASTType member in Value.h? Can I change that to a
unique_ptr<ClangASTType>?