diff options
author | Davide Italiano <davide@freebsd.org> | 2016-07-14 03:02:34 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2016-07-14 03:02:34 +0000 |
commit | ed4d5ea82af5a8c1fac741371b0c1f466d888f84 (patch) | |
tree | c0cb0619136aeb6c635d7997b4e7e995a08a7b95 /llvm/lib | |
parent | a579b9196c6eaa1e2a52832e8d0025eaf6160efa (diff) | |
download | bcm5719-llvm-ed4d5ea82af5a8c1fac741371b0c1f466d888f84.tar.gz bcm5719-llvm-ed4d5ea82af5a8c1fac741371b0c1f466d888f84.zip |
[SCCP] Pass a Value * instead of templating this function. NFC.
Thanks to Eli for the suggestion!
llvm-svn: 275366
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 61905a34246..6ef7a2013f0 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1510,16 +1510,15 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { 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(SCCPSolver Solver, ArgOrInst *AI) { } 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; } |