#include "llvm/ADT/Statistic.h"
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
#include "llvm/Support/CFG.h"
-#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
}
namespace {
- class VISIBILITY_HIDDEN ValueTable {
+ class ValueTable {
private:
DenseMap<Value*, uint32_t> valueNumbering;
DenseMap<Expression, uint32_t> expressionNumbering;
// THIS SHOULD NEVER HAPPEN
default:
- LLVM_UNREACHABLE("Binary operator with unknown opcode?");
+ llvm_unreachable("Binary operator with unknown opcode?");
return Expression::ADD;
}
}
// THIS SHOULD NEVER HAPPEN
default:
- LLVM_UNREACHABLE("Comparison with unknown predicate?");
+ llvm_unreachable("Comparison with unknown predicate?");
return Expression::ICMPEQ;
}
} else {
// THIS SHOULD NEVER HAPPEN
default:
- LLVM_UNREACHABLE("Comparison with unknown predicate?");
+ llvm_unreachable("Comparison with unknown predicate?");
return Expression::FCMPOEQ;
}
}
// THIS SHOULD NEVER HAPPEN
default:
- LLVM_UNREACHABLE("Cast operator with unknown opcode?");
+ llvm_unreachable("Cast operator with unknown opcode?");
return Expression::BITCAST;
}
}
if (VI != valueNumbering.end())
return VI->second;
else
- LLVM_UNREACHABLE("Value not numbered?");
+ llvm_unreachable("Value not numbered?");
return 0;
}
//===----------------------------------------------------------------------===//
namespace {
-
- class VISIBILITY_HIDDEN GVNPRE : public FunctionPass {
+ class GVNPRE : public FunctionPass {
bool runOnFunction(Function &F);
public:
static char ID; // Pass identification, replacement for typeid
if (v == VN.lookup(*I))
return *I;
- LLVM_UNREACHABLE("No leader found, but present bit is set?");
+ llvm_unreachable("No leader found, but present bit is set?");
return 0;
}
newOp1, newOp2,
BO->getName()+".expr");
else if (CmpInst* C = dyn_cast<CmpInst>(U))
- newVal = CmpInst::Create(*Context, C->getOpcode(),
+ newVal = CmpInst::Create(C->getOpcode(),
C->getPredicate(),
newOp1, newOp2,
C->getName()+".expr");
else if (ExtractElementInst* E = dyn_cast<ExtractElementInst>(U))
- newVal = new ExtractElementInst(newOp1, newOp2, E->getName()+".expr");
+ newVal = ExtractElementInst::Create(newOp1, newOp2,
+ E->getName()+".expr");
uint32_t v = VN.lookup_or_add(newVal);
/// dump - Dump a set of values to standard error
void GVNPRE::dump(ValueNumberedSet& s) const {
- DOUT << "{ ";
+ DEBUG(errs() << "{ ");
for (ValueNumberedSet::iterator I = s.begin(), E = s.end();
I != E; ++I) {
- DOUT << "" << VN.lookup(*I) << ": ";
+ DEBUG(errs() << "" << VN.lookup(*I) << ": ");
DEBUG((*I)->dump());
}
- DOUT << "}\n\n";
+ DEBUG(errs() << "}\n\n");
}
/// elimination - Phase 3 of the main algorithm. Perform full redundancy
BO->getName()+".gvnpre",
(*PI)->getTerminator());
else if (CmpInst* C = dyn_cast<CmpInst>(U))
- newVal = CmpInst::Create(*Context, C->getOpcode(),
+ newVal = CmpInst::Create(C->getOpcode(),
C->getPredicate(), s1, s2,
C->getName()+".gvnpre",
(*PI)->getTerminator());
newVal = InsertElementInst::Create(s1, s2, s3, S->getName()+".gvnpre",
(*PI)->getTerminator());
else if (ExtractElementInst* S = dyn_cast<ExtractElementInst>(U))
- newVal = new ExtractElementInst(s1, s2, S->getName()+".gvnpre",
+ newVal = ExtractElementInst::Create(s1, s2, S->getName()+".gvnpre",
(*PI)->getTerminator());
else if (SelectInst* S = dyn_cast<SelectInst>(U))
newVal = SelectInst::Create(s1, s2, s3, S->getName()+".gvnpre",