This is an archive of the discontinued LLVM Phabricator instance.

Instantiate fewer templates in PassManager::addPass()
ClosedPublic

Authored by aeubanks on Sep 29 2021, 1:54 PM.

Details

Summary

We create many instantiations of PassManager::addPass() in
PassBuilder.cpp. vector::emplace_back() and make_unique() are both
templated and would have many instantiations based on the number of
times we instantiate addPass(). Now we directly construct the
unique_ptr with the type as the actual unique_ptr type in the vector we
are adding it to, so we only have one unique_ptr constructor
instantiation across all addPass() instantiations and only the
non-templated push_back().

This makes PassBuilder.cpp slightly faster to build.

Diff Detail

Event Timeline

aeubanks created this revision.Sep 29 2021, 1:54 PM
aeubanks requested review of this revision.Sep 29 2021, 1:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2021, 1:54 PM
rnk accepted this revision.Sep 30 2021, 9:24 AM

lgtm

I think I understand what's going on: these push_back instantiations are all common instantiations. They are pushing back std::unique_ptr<ZZZConceptT> objects. The emplace_back calls were all unique instantiations depending on the exact pass pointer type.

This revision is now accepted and ready to land.Sep 30 2021, 9:24 AM
This revision was automatically updated to reflect the committed changes.