[llvm] r288324 - [SCCP] Prefer `auto` when the type is obvious. NFCI.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 00:36:13 PST 2016
Author: davide
Date: Thu Dec 1 02:36:12 2016
New Revision: 288324
URL: http://llvm.org/viewvc/llvm-project?rev=288324&view=rev
Log:
[SCCP] Prefer `auto` when the type is obvious. NFCI.
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=288324&r1=288323&r2=288324&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Dec 1 02:36:12 2016
@@ -242,7 +242,7 @@ public:
/// this method must be called.
void AddTrackedFunction(Function *F) {
// Add an entry, F -> undef.
- if (StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
+ if (auto *STy = dyn_cast<StructType>(F->getReturnType())) {
MRVFunctionsTracked.insert(F);
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
TrackedMultipleRetVals.insert(std::make_pair(std::make_pair(F, i),
@@ -272,7 +272,7 @@ public:
std::vector<LatticeVal> getStructLatticeValueFor(Value *V) const {
std::vector<LatticeVal> StructValues;
- StructType *STy = dyn_cast<StructType>(V->getType());
+ auto *STy = dyn_cast<StructType>(V->getType());
assert(STy && "getStructLatticeValueFor() can be called only on structs");
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
auto I = StructValueState.find(std::make_pair(V, i));
@@ -315,7 +315,7 @@ public:
/// markAnythingOverdefined - Mark the specified value overdefined. This
/// works with both scalars and structs.
void markAnythingOverdefined(Value *V) {
- if (StructType *STy = dyn_cast<StructType>(V->getType()))
+ if (auto *STy = dyn_cast<StructType>(V->getType()))
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
markOverdefined(getStructValueState(V, i), V);
else
@@ -375,7 +375,7 @@ private:
if (!IV.markOverdefined()) return;
DEBUG(dbgs() << "markOverdefined: ";
- if (Function *F = dyn_cast<Function>(V))
+ if (auto *F = dyn_cast<Function>(V))
dbgs() << "Function '" << F->getName() << "'\n";
else
dbgs() << *V << '\n');
@@ -414,7 +414,7 @@ private:
if (!I.second)
return LV; // Common case, already in the map.
- if (Constant *C = dyn_cast<Constant>(V)) {
+ if (auto *C = dyn_cast<Constant>(V)) {
// Undef values remain unknown.
if (!isa<UndefValue>(V))
LV.markConstant(C); // Constants are constant
@@ -440,7 +440,7 @@ private:
if (!I.second)
return LV; // Common case, already in the map.
- if (Constant *C = dyn_cast<Constant>(V)) {
+ if (auto *C = dyn_cast<Constant>(V)) {
Constant *Elt = C->getAggregateElement(i);
if (!Elt)
@@ -563,7 +563,7 @@ private:
void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
SmallVectorImpl<bool> &Succs) {
Succs.resize(TI.getNumSuccessors());
- if (BranchInst *BI = dyn_cast<BranchInst>(&TI)) {
+ if (auto *BI = dyn_cast<BranchInst>(&TI)) {
if (BI->isUnconditional()) {
Succs[0] = true;
return;
@@ -590,7 +590,7 @@ void SCCPSolver::getFeasibleSuccessors(T
return;
}
- if (SwitchInst *SI = dyn_cast<SwitchInst>(&TI)) {
+ if (auto *SI = dyn_cast<SwitchInst>(&TI)) {
if (!SI->getNumCases()) {
Succs[0] = true;
return;
@@ -634,7 +634,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlo
// Check to make sure this edge itself is actually feasible now.
TerminatorInst *TI = From->getTerminator();
- if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
+ if (auto *BI = dyn_cast<BranchInst>(TI)) {
if (BI->isUnconditional())
return true;
@@ -654,7 +654,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlo
if (TI->isExceptional())
return true;
- if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
+ if (auto *SI = dyn_cast<SwitchInst>(TI)) {
if (SI->getNumCases() < 1)
return true;
@@ -769,7 +769,7 @@ void SCCPSolver::visitReturnInst(ReturnI
// Handle functions that return multiple values.
if (!TrackedMultipleRetVals.empty()) {
- if (StructType *STy = dyn_cast<StructType>(ResultOp->getType()))
+ if (auto *STy = dyn_cast<StructType>(ResultOp->getType()))
if (MRVFunctionsTracked.count(F))
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
mergeInValue(TrackedMultipleRetVals[std::make_pair(F, i)], F,
@@ -828,7 +828,7 @@ void SCCPSolver::visitExtractValueInst(E
}
void SCCPSolver::visitInsertValueInst(InsertValueInst &IVI) {
- StructType *STy = dyn_cast<StructType>(IVI.getType());
+ auto *STy = dyn_cast<StructType>(IVI.getType());
if (!STy)
return markOverdefined(&IVI);
@@ -1058,7 +1058,7 @@ void SCCPSolver::visitLoadInst(LoadInst
return;
// Transform load (constant global) into the value loaded.
- if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) {
+ if (auto *GV = dyn_cast<GlobalVariable>(Ptr)) {
if (!TrackedGlobals.empty()) {
// If we are tracking this global, merge in the known value for it.
DenseMap<GlobalVariable*, LatticeVal>::iterator It =
@@ -1146,7 +1146,7 @@ CallOverdefined:
continue;
}
- if (StructType *STy = dyn_cast<StructType>(AI->getType())) {
+ if (auto *STy = dyn_cast<StructType>(AI->getType())) {
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
LatticeVal CallArg = getStructValueState(*CAI, i);
mergeInValue(getStructValueState(&*AI, i), &*AI, CallArg);
@@ -1158,7 +1158,7 @@ CallOverdefined:
}
// If this is a single/zero retval case, see if we're tracking the function.
- if (StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
+ if (auto *STy = dyn_cast<StructType>(F->getReturnType())) {
if (!MRVFunctionsTracked.count(F))
goto CallOverdefined; // Not tracking this callee.
@@ -1196,7 +1196,7 @@ void SCCPSolver::Solve() {
// Update all of the users of this instruction's value.
//
for (User *U : I->users())
- if (Instruction *UI = dyn_cast<Instruction>(U))
+ if (auto *UI = dyn_cast<Instruction>(U))
OperandChangedState(UI);
}
@@ -1215,7 +1215,7 @@ void SCCPSolver::Solve() {
//
if (I->getType()->isStructTy() || !getValueState(I).isOverdefined())
for (User *U : I->users())
- if (Instruction *UI = dyn_cast<Instruction>(U))
+ if (auto *UI = dyn_cast<Instruction>(U))
OperandChangedState(UI);
}
@@ -1260,7 +1260,7 @@ bool SCCPSolver::ResolvedUndefsIn(Functi
// Look for instructions which produce undef values.
if (I.getType()->isVoidTy()) continue;
- if (StructType *STy = dyn_cast<StructType>(I.getType())) {
+ if (auto *STy = dyn_cast<StructType>(I.getType())) {
// Only a few things that can be structs matter for undef.
// Tracked calls must never be marked overdefined in ResolvedUndefsIn.
@@ -1481,7 +1481,7 @@ bool SCCPSolver::ResolvedUndefsIn(Functi
// we force the branch to go one way or the other to make the successor
// values live. It doesn't really matter which way we force it.
TerminatorInst *TI = BB.getTerminator();
- if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
+ if (auto *BI = dyn_cast<BranchInst>(TI)) {
if (!BI->isConditional()) continue;
if (!getValueState(BI->getCondition()).isUnknown())
continue;
@@ -1502,7 +1502,7 @@ bool SCCPSolver::ResolvedUndefsIn(Functi
return true;
}
- if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
+ if (auto *SI = dyn_cast<SwitchInst>(TI)) {
if (!SI->getNumCases() || !getValueState(SI->getCondition()).isUnknown())
continue;
@@ -1529,7 +1529,7 @@ static bool tryToReplaceWithConstant(SCC
if (any_of(IVs, [](const LatticeVal &LV) { return LV.isOverdefined(); }))
return false;
std::vector<Constant *> ConstVals;
- StructType *ST = dyn_cast<StructType>(V->getType());
+ auto *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()
@@ -1670,7 +1670,7 @@ static bool AddressIsTaken(const GlobalV
for (const Use &U : GV->uses()) {
const User *UR = U.getUser();
- if (const StoreInst *SI = dyn_cast<StoreInst>(UR)) {
+ if (const auto *SI = dyn_cast<StoreInst>(UR)) {
if (SI->getOperand(0) == GV || SI->isVolatile())
return true; // Storing addr of GV.
} else if (isa<InvokeInst>(UR) || isa<CallInst>(UR)) {
@@ -1678,7 +1678,7 @@ static bool AddressIsTaken(const GlobalV
ImmutableCallSite CS(cast<Instruction>(UR));
if (!CS.isCallee(&U))
return true;
- } else if (const LoadInst *LI = dyn_cast<LoadInst>(UR)) {
+ } else if (const auto *LI = dyn_cast<LoadInst>(UR)) {
if (LI->isVolatile())
return true;
} else if (isa<BlockAddress>(UR)) {
@@ -1699,7 +1699,7 @@ static void findReturnsToZap(Function &F
return;
for (BasicBlock &BB : F)
- if (ReturnInst *RI = dyn_cast<ReturnInst>(BB.getTerminator()))
+ if (auto *RI = dyn_cast<ReturnInst>(BB.getTerminator()))
if (!isa<UndefValue>(RI->getOperand(0)))
ReturnsToZap.push_back(RI);
}
@@ -1826,7 +1826,7 @@ static bool runIPSCCP(Module &M, const D
UI != UE;) {
// Grab the user and then increment the iterator early, as the user
// will be deleted. Step past all adjacent uses from the same user.
- Instruction *I = dyn_cast<Instruction>(*UI);
+ auto *I = dyn_cast<Instruction>(*UI);
do { ++UI; } while (UI != UE && *UI == I);
// Ignore blockaddress users; BasicBlock's dtor will handle them.
@@ -1838,10 +1838,10 @@ static bool runIPSCCP(Module &M, const D
// if this is a branch or switch on undef. Fold it manually as a
// branch to the first successor.
#ifndef NDEBUG
- if (BranchInst *BI = dyn_cast<BranchInst>(I)) {
+ if (auto *BI = dyn_cast<BranchInst>(I)) {
assert(BI->isConditional() && isa<UndefValue>(BI->getCondition()) &&
"Branch should be foldable!");
- } else if (SwitchInst *SI = dyn_cast<SwitchInst>(I)) {
+ } else if (auto *SI = dyn_cast<SwitchInst>(I)) {
assert(isa<UndefValue>(SI->getCondition()) && "Switch should fold");
} else {
llvm_unreachable("Didn't fold away reference to block!");
More information about the llvm-commits
mailing list