eliminate the SCCPSolver::getValueMapping method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85778 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index e931c37..1e8736f 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -236,10 +236,10 @@
return BBExecutable.count(BB);
}
- /// getValueMapping - Once we have solved for constants, return the mapping of
- /// LLVM values to LatticeVals.
- std::map<Value*, LatticeVal> &getValueMapping() {
- return ValueState;
+ LatticeVal getLatticeValueFor(Value *V) const {
+ std::map<Value*, LatticeVal>::const_iterator I = ValueState.find(V);
+ assert(I != ValueState.end() && "V is not in valuemap!");
+ return I->second;
}
/// getTrackedRetVals - Get the inferred return value map.
@@ -1612,8 +1612,6 @@
// If we decided that there are basic blocks that are dead in this function,
// delete their contents now. Note that we cannot actually delete the blocks,
// as we cannot modify the CFG of the function.
- //
- std::map<Value*, LatticeVal> &Values = Solver.getValueMapping();
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
if (!Solver.isBlockExecutable(BB)) {
@@ -1630,8 +1628,8 @@
if (Inst->getType()->isVoidTy() || isa<TerminatorInst>(Inst))
continue;
- LatticeVal &IV = Values[Inst];
- if (!IV.isConstant() && !IV.isUndefined())
+ LatticeVal IV = Solver.getLatticeValueFor(Inst);
+ if (IV.isOverdefined())
continue;
Constant *Const = IV.isConstant()
@@ -1743,24 +1741,24 @@
// constants if we have found them to be of constant values.
//
SmallVector<BasicBlock*, 512> BlocksToErase;
- std::map<Value*, LatticeVal> &Values = Solver.getValueMapping();
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
- AI != E; ++AI)
- if (!AI->use_empty()) {
- LatticeVal &IV = Values[AI];
- if (IV.isConstant() || IV.isUndefined()) {
- Constant *CST = IV.isConstant() ?
- IV.getConstant() : UndefValue::get(AI->getType());
- DEBUG(errs() << "*** Arg " << *AI << " = " << *CST <<"\n");
-
- // Replaces all of the uses of a variable with uses of the
- // constant.
- AI->replaceAllUsesWith(CST);
- ++IPNumArgsElimed;
- }
- }
+ AI != E; ++AI) {
+ if (AI->use_empty()) continue;
+
+ LatticeVal IV = Solver.getLatticeValueFor(AI);
+ if (IV.isOverdefined()) continue;
+
+ Constant *CST = IV.isConstant() ?
+ IV.getConstant() : UndefValue::get(AI->getType());
+ DEBUG(errs() << "*** Arg " << *AI << " = " << *CST <<"\n");
+
+ // Replaces all of the uses of a variable with uses of the
+ // constant.
+ AI->replaceAllUsesWith(CST);
+ ++IPNumArgsElimed;
+ }
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
if (!Solver.isBlockExecutable(BB)) {
@@ -1789,8 +1787,8 @@
if (Inst->getType()->isVoidTy())
continue;
- LatticeVal &IV = Values[Inst];
- if (!IV.isConstant() && !IV.isUndefined())
+ LatticeVal IV = Solver.getLatticeValueFor(Inst);
+ if (IV.isOverdefined())
continue;
Constant *Const = IV.isConstant()