diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-09-28 16:44:29 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-09-28 16:44:29 +0000 |
commit | da3d76b4cfbb5ebeb79e03a0abeabd403fe9260a (patch) | |
tree | 70ee7143009a87d51442030911295abc756f62e6 /lib/Analysis/UninitializedValues.cpp | |
parent | 1c84c68b6d7a92416493ab6c36f630de48c65d08 (diff) |
Avoid malloc thrashing in the uninitialized value analysis.
- The size of the packed vector is often small, save mallocs using SmallBitVector.
- Copying SmallBitVectors is also cheap, remove a level of indirection.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/UninitializedValues.cpp')
-rw-r--r-- | lib/Analysis/UninitializedValues.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 8ebee9614a..b2e27cad1f 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -13,6 +13,7 @@ #include <utility> #include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/PackedVector.h" #include "llvm/ADT/DenseMap.h" @@ -98,22 +99,21 @@ static bool isAlwaysUninit(const Value v) { namespace { -typedef llvm::PackedVector<Value, 2> ValueVector; +typedef llvm::PackedVector<Value, 2, llvm::SmallBitVector> ValueVector; class CFGBlockValues { const CFG &cfg; - std::vector<ValueVector*> vals; + SmallVector<ValueVector, 8> vals; ValueVector scratch; DeclToIndex declToIndex; public: CFGBlockValues(const CFG &cfg); - ~CFGBlockValues(); unsigned getNumEntries() const { return declToIndex.size(); } void computeSetOfDeclarations(const DeclContext &dc); ValueVector &getValueVector(const CFGBlock *block) { - return *vals[block->getBlockID()]; + return vals[block->getBlockID()]; } void setAllScratchValues(Value V); @@ -139,12 +139,6 @@ public: CFGBlockValues::CFGBlockValues(const CFG &c) : cfg(c), vals(0) {} -CFGBlockValues::~CFGBlockValues() { - for (std::vector<ValueVector*>::iterator I = vals.begin(), E = vals.end(); - I != E; ++I) - delete *I; -} - void CFGBlockValues::computeSetOfDeclarations(const DeclContext &dc) { declToIndex.computeMap(dc); unsigned decls = declToIndex.size(); @@ -154,7 +148,7 @@ void CFGBlockValues::computeSetOfDeclarations(const DeclContext &dc) { return; vals.resize(n); for (unsigned i = 0; i < n; ++i) - vals[i] = new ValueVector(decls); + vals[i].resize(decls); } #if DEBUG_LOGGING |