[llvm] r275366 - [SCCP] Pass a Value * instead of templating this function. NFC.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 20:02:35 PDT 2016
Author: davide
Date: Wed Jul 13 22:02:34 2016
New Revision: 275366
URL: http://llvm.org/viewvc/llvm-project?rev=275366&view=rev
Log:
[SCCP] Pass a Value * instead of templating this function. NFC.
Thanks to Eli for the suggestion!
Modified:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=275366&r1=275365&r2=275366&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Jul 13 22:02:34 2016
@@ -1510,16 +1510,15 @@ bool SCCPSolver::ResolvedUndefsIn(Functi
return false;
}
-template <typename ArgOrInst>
-static bool tryToReplaceWithConstant(SCCPSolver Solver, ArgOrInst *AI) {
+static bool tryToReplaceWithConstant(SCCPSolver Solver, Value *V) {
Constant *Const = nullptr;
- if (AI->getType()->isStructTy()) {
- std::vector<LatticeVal> IVs = Solver.getStructLatticeValueFor(AI);
+ if (V->getType()->isStructTy()) {
+ std::vector<LatticeVal> IVs = Solver.getStructLatticeValueFor(V);
if (std::any_of(IVs.begin(), IVs.end(),
[](LatticeVal &LV) { return LV.isOverdefined(); }))
return false;
std::vector<Constant *> ConstVals;
- StructType *ST = dyn_cast<StructType>(AI->getType());
+ StructType *ST = dyn_cast<StructType>(V->getType());
for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) {
LatticeVal V = IVs[i];
ConstVals.push_back(V.isConstant()
@@ -1528,16 +1527,16 @@ static bool tryToReplaceWithConstant(SCC
}
Const = ConstantStruct::get(ST, ConstVals);
} else {
- LatticeVal IV = Solver.getLatticeValueFor(AI);
+ LatticeVal IV = Solver.getLatticeValueFor(V);
if (IV.isOverdefined())
return false;
- Const = IV.isConstant() ? IV.getConstant() : UndefValue::get(AI->getType());
+ Const = IV.isConstant() ? IV.getConstant() : UndefValue::get(V->getType());
}
assert(Const && "Constant is nullptr here!");
- DEBUG(dbgs() << " Constant: " << *Const << " = " << *AI << '\n');
+ DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n');
// Replaces all of the uses of a variable with uses of the constant.
- AI->replaceAllUsesWith(Const);
+ V->replaceAllUsesWith(Const);
return true;
}
More information about the llvm-commits
mailing list