diff options
author | Fangrui Song <i@maskray.me> | 2023-07-24 22:04:03 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2023-07-24 22:04:03 -0700 |
commit | fb2a971c015fa991b47aa8d93bd97379c012cb68 (patch) | |
tree | 37041f9336f4eebd1634bcc15672ab8036634aa9 /llvm | |
parent | 480d7a3aff8db0b812bdd36e7be8d78a7a0fd430 (diff) | |
download | llvm-fb2a971c015fa991b47aa8d93bd97379c012cb68.zip llvm-fb2a971c015fa991b47aa8d93bd97379c012cb68.tar.gz llvm-fb2a971c015fa991b47aa8d93bd97379c012cb68.tar.bz2 |
[Support] Change MapVector's default template parameter to SmallVector<*, 0>
SmallVector<*, 0> is often a better replacement for std::vector :
both the object size and the code size are smaller.
(SmallMapVector uses SmallVector as well, but it is not common.)
clang size decreases by 0.0226%.
instructions:u decreases 0.037% when compiling a sqlite3 amalgram.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D156016
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/ADT/MapVector.h | 11 | ||||
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/llvm/include/llvm/ADT/MapVector.h b/llvm/include/llvm/ADT/MapVector.h index a129b63..c45779c 100644 --- a/llvm/include/llvm/ADT/MapVector.h +++ b/llvm/include/llvm/ADT/MapVector.h @@ -10,7 +10,7 @@ /// This file implements a map that provides insertion order iteration. The /// interface is purposefully minimal. The key is assumed to be cheap to copy /// and 2 copies are kept, one for indexing in a DenseMap, one for iteration in -/// a std::vector. +/// a SmallVector. /// //===----------------------------------------------------------------------===// @@ -24,16 +24,15 @@ #include <iterator> #include <type_traits> #include <utility> -#include <vector> namespace llvm { /// This class implements a map that also provides access to all stored values -/// in a deterministic order. The values are kept in a std::vector and the +/// in a deterministic order. The values are kept in a SmallVector<*, 0> and the /// mapping is done with DenseMap from Keys to indexes in that vector. -template<typename KeyT, typename ValueT, - typename MapType = DenseMap<KeyT, unsigned>, - typename VectorType = std::vector<std::pair<KeyT, ValueT>>> +template <typename KeyT, typename ValueT, + typename MapType = DenseMap<KeyT, unsigned>, + typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>> class MapVector { MapType Map; VectorType Vector; diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 165b8f1..2076ed4 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -266,7 +266,9 @@ static void computeFunctionSummary( unsigned NumInsts = 0; // Map from callee ValueId to profile count. Used to accumulate profile // counts for all static calls to a given callee. - MapVector<ValueInfo, CalleeInfo> CallGraphEdges; + MapVector<ValueInfo, CalleeInfo, DenseMap<ValueInfo, unsigned>, + std::vector<std::pair<ValueInfo, CalleeInfo>>> + CallGraphEdges; SetVector<ValueInfo> RefEdges, LoadRefEdges, StoreRefEdges; SetVector<GlobalValue::GUID> TypeTests; SetVector<FunctionSummary::VFuncId> TypeTestAssumeVCalls, |