mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[SCCP] Pass a Value * instead of templating this function. NFC.
Thanks to Eli for the suggestion! llvm-svn: 275366
This commit is contained in:
parent
b9db25ac49
commit
7dbaefb75a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user