mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 22:00:10 +00:00
[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
This commit is contained in:
parent
480d7a3aff
commit
fb2a971c01
@ -146,7 +146,7 @@ private:
|
||||
Symbol *canonicalizePersonality(Symbol *);
|
||||
|
||||
uint64_t unwindInfoSize = 0;
|
||||
std::vector<decltype(symbols)::value_type> symbolsVec;
|
||||
SmallVector<decltype(symbols)::value_type, 0> symbolsVec;
|
||||
CompactUnwindLayout cuLayout;
|
||||
std::vector<std::pair<compact_unwind_encoding_t, size_t>> commonEncodings;
|
||||
EncodingMap commonEncodingIndexes;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -975,8 +975,8 @@ static StringRef sanitizeIdentifier(StringRef name, SmallString<16> &buffer,
|
||||
void AliasInitializer::initializeAliases(
|
||||
llvm::MapVector<const void *, InProgressAliasInfo> &visitedSymbols,
|
||||
llvm::MapVector<const void *, SymbolAlias> &symbolToAlias) {
|
||||
std::vector<std::pair<const void *, InProgressAliasInfo>> unprocessedAliases =
|
||||
visitedSymbols.takeVector();
|
||||
SmallVector<std::pair<const void *, InProgressAliasInfo>, 0>
|
||||
unprocessedAliases = visitedSymbols.takeVector();
|
||||
llvm::stable_sort(unprocessedAliases, [](const auto &lhs, const auto &rhs) {
|
||||
return lhs.second < rhs.second;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user