//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the Owen Anderson and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
SmallVector<uint32_t, 4> varargs;
Expression() { }
- Expression(ExpressionOpcode o) : opcode(o) { }
+ explicit Expression(ExpressionOpcode o) : opcode(o) { }
bool operator==(const Expression &other) const {
if (opcode != other.opcode)
}
namespace llvm {
-template <> struct DenseMapKeyInfo<Expression> {
- static inline Expression getEmptyKey() { return Expression(Expression::EMPTY); }
- static inline Expression getTombstoneKey() { return Expression(Expression::TOMBSTONE); }
+template <> struct DenseMapInfo<Expression> {
+ static inline Expression getEmptyKey() {
+ return Expression(Expression::EMPTY);
+ }
+
+ static inline Expression getTombstoneKey() {
+ return Expression(Expression::TOMBSTONE);
+ }
static unsigned getHashValue(const Expression e) {
unsigned hash = e.opcode;
hash = e.secondVN + hash * 37;
hash = e.thirdVN + hash * 37;
- hash = (unsigned)((uintptr_t)e.type >> 4) ^
- (unsigned)((uintptr_t)e.type >> 9) +
- hash * 37;
+ hash = ((unsigned)((uintptr_t)e.type >> 4) ^
+ (unsigned)((uintptr_t)e.type >> 9)) +
+ hash * 37;
- for (SmallVector<uint32_t, 4>::const_iterator I = e.varargs.begin(), E = e.varargs.end();
- I != E; ++I)
+ for (SmallVector<uint32_t, 4>::const_iterator I = e.varargs.begin(),
+ E = e.varargs.end(); I != E; ++I)
hash = *I + hash * 37;
return hash;
}
+ static bool isEqual(const Expression &LHS, const Expression &RHS) {
+ return LHS == RHS;
+ }
static bool isPod() { return true; }
};
}
e.secondVN = 0;
e.thirdVN = 0;
e.type = G->getType();
- e.opcode = Expression::SELECT;
+ e.opcode = Expression::GEP;
for (GetElementPtrInst::op_iterator I = G->idx_begin(), E = G->idx_end();
I != E; ++I)
FunctionPass *llvm::createGVNPREPass() { return new GVNPRE(); }
static RegisterPass<GVNPRE> X("gvnpre",
- "Global Value Numbering/Partial Redundancy Elimination");
+ "Global Value Numbering/Partial Redundancy Elimination");
STATISTIC(NumInsertedVals, "Number of values inserted");
if (newOp1 != U->getPointerOperand() || changed_idx) {
Instruction* newVal = new GetElementPtrInst(newOp1,
- &newIdx[0], newIdx.size(),
+ newIdx.begin(), newIdx.end(),
U->getName()+".expr");
uint32_t v = VN.lookup_or_add(newVal);
isa<ExtractElementInst>(BI) || isa<SelectInst>(BI) ||
isa<CastInst>(BI) || isa<GetElementPtrInst>(BI)) {
- if (availableOut[BB].test(VN.lookup(BI)) && !availableOut[BB].count(BI)) {
+ if (availableOut[BB].test(VN.lookup(BI)) &&
+ !availableOut[BB].count(BI)) {
Value *leader = find_leader(availableOut[BB], VN.lookup(BI));
if (Instruction* Instr = dyn_cast<Instruction>(leader))
if (Instr->getParent() != 0 && Instr != BI) {
changed_function = true;
}
- for (SmallVector<Instruction*, 8>::iterator I = erase.begin(), E = erase.end();
- I != E; ++I)
+ for (SmallVector<Instruction*, 8>::iterator I = erase.begin(),
+ E = erase.end(); I != E; ++I)
(*I)->eraseFromParent();
return changed_function;
isa<ShuffleVectorInst>(U) ||
isa<ExtractElementInst>(U) ||
isa<InsertElementInst>(U) ||
- isa<SelectInst>(U))
+ isa<SelectInst>(U)) {
if (isa<BinaryOperator>(U->getOperand(1)) ||
isa<CmpInst>(U->getOperand(1)) ||
isa<ShuffleVectorInst>(U->getOperand(1)) ||
} else {
s2 = U->getOperand(1);
}
+ }
// Ternary Operators
Value* s3 = 0;
if (isa<ShuffleVectorInst>(U) ||
isa<InsertElementInst>(U) ||
- isa<SelectInst>(U))
+ isa<SelectInst>(U)) {
if (isa<BinaryOperator>(U->getOperand(2)) ||
isa<CmpInst>(U->getOperand(2)) ||
isa<ShuffleVectorInst>(U->getOperand(2)) ||
} else {
s3 = U->getOperand(2);
}
+ }
// Vararg operators
SmallVector<Value*, 4> sVarargs;
C->getName()+".gvnpre",
(*PI)->getTerminator());
else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(U))
- newVal = new GetElementPtrInst(s1, &sVarargs[0], sVarargs.size(),
+ newVal = new GetElementPtrInst(s1, sVarargs.begin(), sVarargs.end(),
G->getName()+".gvnpre",
(*PI)->getTerminator());