#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstVisitor.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallSet.h"
// work list so that the users of the instruction are updated later.
inline void markOverdefined(LatticeVal &IV, Value *V) {
if (IV.markOverdefined()) {
- DEBUG(DOUT << "markOverdefined: ";
+ DEBUG(errs() << "markOverdefined: ";
if (Function *F = dyn_cast<Function>(V))
- DOUT << "Function '" << F->getName() << "'\n";
+ errs() << "Function '" << F->getName() << "'\n";
else
- DOUT << *V);
+ errs() << *V);
// Only instructions go on the work list
OverdefinedInstWorkList.push_back(V);
}
Succs[0] = Succs[1] = true;
} else if (BCValue.isConstant()) {
// Constant condition variables mean the branch can only go a single way
- Succs[BCValue.getConstant() == Context->getConstantIntFalse()] = true;
+ Succs[BCValue.getConstant() == Context->getFalse()] = true;
}
}
} else if (isa<InvokeInst>(&TI)) {
// Constant condition variables mean the branch can only go a single way
return BI->getSuccessor(BCValue.getConstant() ==
- Context->getConstantIntFalse()) == To;
+ Context->getFalse()) == To;
}
return false;
}
DenseMap<std::pair<Function*, unsigned>, LatticeVal>::iterator
It = TrackedMultipleRetVals.find(std::make_pair(F, i));
if (It == TrackedMultipleRetVals.end()) break;
- if (Value *Val = FindInsertedValue(I.getOperand(0), i, Context))
+ if (Value *Val = FindInsertedValue(I.getOperand(0), i, I.getContext()))
mergeInValue(It->second, F, getValueState(Val));
}
}
if (GV->isConstant() && GV->hasDefinitiveInitializer())
if (Constant *V =
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE,
- Context)) {
+ *Context)) {
markConstant(IV, &I, V);
return;
}
// as undef, then further analysis could think the undef went another way
// leading to an inconsistent set of conclusions.
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
- BI->setCondition(Context->getConstantIntFalse());
+ BI->setCondition(Context->getFalse());
} else {
SwitchInst *SI = cast<SwitchInst>(TI);
SI->setCondition(SI->getCaseValue(1));
bool SCCP::runOnFunction(Function &F) {
DOUT << "SCCP on function '" << F.getNameStart() << "'\n";
SCCPSolver Solver;
- Solver.setContext(Context);
+ Solver.setContext(&F.getContext());
// Mark the first block of the function as being executable.
Solver.MarkBlockExecutable(F.begin());
Instruction *I = Insts.back();
Insts.pop_back();
if (!I->use_empty())
- I->replaceAllUsesWith(Context->getUndef(I->getType()));
+ I->replaceAllUsesWith(F.getContext().getUndef(I->getType()));
BB->getInstList().erase(I);
MadeChanges = true;
++NumInstRemoved;
continue;
Constant *Const = IV.isConstant()
- ? IV.getConstant() : Context->getUndef(Inst->getType());
+ ? IV.getConstant() : F.getContext().getUndef(Inst->getType());
DOUT << " Constant: " << *Const << " = " << *Inst;
// Replaces all of the uses of a variable with uses of the constant.
}
bool IPSCCP::runOnModule(Module &M) {
- Context = &M.getContext();
+ LLVMContext *Context = &M.getContext();
SCCPSolver Solver;
Solver.setContext(Context);