[PATCH] D75281: BumpPtrAllocator: Use extern templates and out of line methods

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 11:35:29 PST 2020


rnk created this revision.
rnk added reviewers: hans, dblaikie.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Prior to this change, BumpPtrAllocatorImpl<>::Allocate was instantiated
everywhere that included this file, and it was expensive, according to
ClangBuildAnalyzer:

- Templates that took longest to instantiate: 44057 ms: llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096, 128>::Allocate (3230 times, avg 13 ms) 34729 ms: std::tie<const unsigned long long, const unsigned long long> (1903 times, avg 18 ms) 33466 ms: std::tie<const unsigned int, const unsigned int, const unsigned int, const unsigned int> (899 times, avg 37 ms) 28112 ms: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (11220 times, avg 2 ms) 23251 ms: std::tie<llvm::StringRef, llvm::StringRef> (1280 times, avg 18 ms) 21820 ms: llvm::SmallDenseMap<void *, std::pair<llvm::PointerUnion<llvm::MetadataAsValue *, llvm::Metadata *>, unsigned long lon... (1298 times, avg 16 ms) 21434 ms: std::tuple<const unsigned int &, const unsigned int &, const unsigned int &, const unsigned int &> (953 times, avg 22 ms) 20595 ms: llvm::SmallVector<std::pair<void *, unsigned long long>, 0> (1972 times, avg 10 ms)

Initially I thought the extern template decl would help, but it did not.
Then I realized that Allocate will be instantiated for optimization
purposes. Moving it out of line prevents that, and realizes the gain.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75281

Files:
  llvm/include/llvm/Support/Allocator.h
  llvm/lib/Support/Allocator.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75281.247048.patch
Type: text/x-patch
Size: 16227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200227/576e4d75/attachment.bin>


More information about the llvm-commits mailing list