ElementIndex = RHS.ElementIndex;
std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits);
}
+
+ // Assignment
+ SparseBitVectorElement& operator=(const SparseBitVectorElement& RHS) {
+ ElementIndex = RHS.ElementIndex;
+ std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits);
+
+ return *this;
+ }
// Comparison.
bool operator==(const SparseBitVectorElement &RHS) const {
CurrElementIter = Elements.begin ();
}
+
+ // Assignment
+ SparseBitVector& operator=(const SparseBitVector& RHS) {
+ Elements.clear();
+
+ ElementListConstIter ElementIter = RHS.Elements.begin();
+ while (ElementIter != RHS.Elements.end()) {
+ Elements.push_back(SparseBitVectorElement<ElementSize>(*ElementIter));
+ ++ElementIter;
+ }
+
+ CurrElementIter = Elements.begin ();
+
+ return *this;
+ }
// Test, Reset, and Set a bit in the bitmap.
bool test(unsigned Idx) {
#include "llvm/Instructions.h"
#include "llvm/ParameterAttributes.h"
#include "llvm/Value.h"
-#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SparseBitVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/AliasAnalysis.h"
class VISIBILITY_HIDDEN ValueNumberedSet {
private:
SmallPtrSet<Value*, 8> contents;
- BitVector numbers;
+ SparseBitVector<64> numbers;
public:
- ValueNumberedSet() { numbers.resize(1); }
+ ValueNumberedSet() { }
ValueNumberedSet(const ValueNumberedSet& other) {
numbers = other.numbers;
contents = other.contents;
size_t size() { return contents.size(); }
void set(unsigned i) {
- if (i >= numbers.size())
- numbers.resize(i+1);
-
numbers.set(i);
}
}
void reset(unsigned i) {
- if (i < numbers.size())
- numbers.reset(i);
+ numbers.reset(i);
}
bool test(unsigned i) {
- if (i >= numbers.size())
- return false;
-
return numbers.test(i);
}
-
- void clear() {
- contents.clear();
- numbers.clear();
- }
};
}
if (isa<AllocationInst>(I))
return false;
+ // Allocations are always unique, so don't bother value numbering them.
+ if (isa<AllocationInst>(I))
+ return false;
+
if (MemCpyInst* M = dyn_cast<MemCpyInst>(I)) {
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();