For PR786:
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31380 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 3cbbc76..9145021 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -537,7 +537,7 @@
// a whole structure at a time), so the level raiser must be trying to
// store into the first field. Check for this and allow it now:
//
- if (const StructType *SElTy = dyn_cast<StructType>(ElTy)) {
+ if (isa<StructType>(ElTy)) {
unsigned Offset = 0;
std::vector<Value*> Indices;
ElTy = getStructOffsetType(ElTy, Offset, Indices, TD, false);
@@ -799,9 +799,6 @@
Value *SrcPtr = VMCI->second;
if (ElTy != NewTy) {
- // We check that this is a struct in the initial scan...
- const StructType *SElTy = cast<StructType>(ElTy);
-
std::vector<Value*> Indices;
Indices.push_back(Constant::getNullValue(Type::UIntTy));
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index 79f21b5..646f5b8 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -259,7 +259,6 @@
// it is safe to unconditionally load the pointer. Use alias analysis to
// check to see if the pointer is guaranteed to not be modified from entry of
// the function to each of the load instructions.
- Function &F = *Arg->getParent();
// Because there could be several/many load instructions, remember which
// blocks we know to be transparent to the load.
@@ -508,7 +507,6 @@
GetElementPtrInst *GEP = cast<GetElementPtrInst>(I->use_back());
std::vector<Value*> Operands(GEP->op_begin()+1, GEP->op_end());
- unsigned ArgNo = 0;
Function::arg_iterator TheArg = I2;
for (ScalarizeTable::iterator It = ArgIndices.begin();
*It != Operands; ++It, ++TheArg) {
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index bc5aecd..6cdd530 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1770,7 +1770,7 @@
return false;
InstResult = RetVal;
}
- } else if (TerminatorInst *TI = dyn_cast<TerminatorInst>(CurInst)) {
+ } else if (isa<TerminatorInst>(CurInst)) {
BasicBlock *NewBB = 0;
if (BranchInst *BI = dyn_cast<BranchInst>(CurInst)) {
if (BI->isUnconditional()) {
diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp
index 78b6ea5..ef27cd6 100644
--- a/lib/Transforms/IPO/IndMemRemoval.cpp
+++ b/lib/Transforms/IPO/IndMemRemoval.cpp
@@ -77,7 +77,7 @@
BasicBlock* bb = new BasicBlock("entry",FN);
Instruction* c = new CastInst(FN->arg_begin(), Type::UIntTy, "c", bb);
Instruction* a = new MallocInst(Type::SByteTy, c, "m", bb);
- Instruction* R = new ReturnInst(a, bb);
+ new ReturnInst(a, bb);
++NumBounce;
NumBounceSites += F->getNumUses();
F->replaceAllUsesWith(FN);
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index c2aa4cb..c4b033c 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -245,7 +245,7 @@
// significant future optimization possibilities (like scalar promotion, and
// scalarization), so encourage the inlining of the function.
//
- else if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
+ else if (isa<AllocaInst>(I)) {
if (ArgNo < CalleeFI.ArgumentWeights.size())
InlineCost -= CalleeFI.ArgumentWeights[ArgNo].AllocaWeight;
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index ae4032b..edb34be 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -129,8 +129,6 @@
DEBUG(std::cerr << " Inlining: cost=" << InlineCost
<< ", Call: " << *CS.getInstruction());
- Function *Caller = CS.getInstruction()->getParent()->getParent();
-
// Attempt to inline the function...
if (InlineCallIfPossible(CS, CG, SCCFunctions)) {
// Remove this call site from the list.
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index cd46718..e6ff5c9 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -496,7 +496,6 @@
// If not reachable from a setjmp call, don't transform.
if (!DFSBlocks.count(BB)) return;
- BasicBlock* NormalBB = II.getNormalDest();
BasicBlock* ExceptBB = II.getUnwindDest();
Function* Func = BB->getParent();
diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 157ea38..af11709 100644
--- a/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -1106,7 +1106,7 @@
CastInst* DestCast =
new CastInst(dest,PointerType::get(castType),dest->getName()+".cast",ci);
LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci);
- StoreInst* SI = new StoreInst(LI, DestCast, ci);
+ new StoreInst(LI, DestCast, ci);
ci->eraseFromParent();
return true;
}
@@ -2063,7 +2063,7 @@
Constant* INTLZR = GV->getInitializer();
// Handle the ConstantAggregateZero case
- if (ConstantAggregateZero *CAZ = dyn_cast<ConstantAggregateZero>(INTLZR)) {
+ if (isa<ConstantAggregateZero>(INTLZR)) {
// This is a degenerate case. The initializer is constant zero so the
// length of the string must be zero.
len = 0;
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index 5d6654d..671b3bc 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -580,7 +580,6 @@
for(BasicBlock::iterator ib = btarget->begin(), ie = btarget->end();
ib != ie; ++ib)
if (PHINode* phi = dyn_cast<PHINode>(&*ib)) {
- unsigned total = phi->getNumIncomingValues();
std::map<BasicBlock*, Value*> counter;
for(unsigned i = 0; i < phi->getNumIncomingValues(); ) {
if (counter[phi->getIncomingBlock(i)]) {
diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
index 8bf6001..003ea0d 100644
--- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
+++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
@@ -56,7 +56,7 @@
while (isa<AllocaInst>(InsertPos) || isa<PHINode>(InsertPos))
++InsertPos;
- Instruction *InstrCall = new CallInst (InstrFn, Args, "", InsertPos);
+ new CallInst (InstrFn, Args, "", InsertPos);
}
bool TraceBasicBlocks::runOnModule(Module &M) {
diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp
index 35e6a97..3ea6795 100644
--- a/lib/Transforms/Scalar/CorrelatedExprs.cpp
+++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp
@@ -726,7 +726,6 @@
const std::vector<BasicBlock*> &RegionExitBlocks) {
assert(BBVal->getType() == OldVal->getType() && "Should be derived values!");
BasicBlock *BB = BBVal->getParent();
- BasicBlock *OldSucc = OldVal->getParent();
// Loop over all of the blocks we have to place PHIs in, doing it.
for (unsigned i = 0, e = RegionExitBlocks.size(); i != e; ++i) {
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index d3a625b..98c35dd 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2579,8 +2579,6 @@
}
Instruction *InstCombiner::visitFRem(BinaryOperator &I) {
- Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
-
return commonRemTransforms(I);
}
@@ -3109,7 +3107,6 @@
{
Value *A = 0, *B = 0;
- ConstantInt *C1 = 0, *C2 = 0;
if (match(Op0, m_Or(m_Value(A), m_Value(B))))
if (A == Op1 || B == Op1) // (A | ?) & A --> A
return ReplaceInstUsesWith(I, Op1);
@@ -5510,7 +5507,7 @@
// If the first operand is itself a cast, and is eliminable, do not count
// this as an eliminable cast. We would prefer to eliminate those two
// casts first.
- if (CastInst *OpCast = dyn_cast<CastInst>(I->getOperand(0)))
+ if (isa<CastInst>(I->getOperand(0)))
return true;
++NumCastsRemoved;
@@ -6192,7 +6189,6 @@
if (Instruction *TI = dyn_cast<Instruction>(TrueVal))
if (Instruction *FI = dyn_cast<Instruction>(FalseVal))
if (TI->hasOneUse() && FI->hasOneUse()) {
- bool isInverse = false;
Instruction *AddOp = 0, *SubOp = 0;
// Turn (select C, (op X, Y), (op X, Z)) -> (op X, (select C, Y, Z))
@@ -6971,7 +6967,7 @@
// Insert and return the new operation.
if (isa<CastInst>(FirstInst))
return new CastInst(PhiVal, PN.getType());
- else if (LoadInst *LI = dyn_cast<LoadInst>(FirstInst))
+ else if (isa<LoadInst>(FirstInst))
return new LoadInst(PhiVal, "", isVolatile);
else if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst))
return BinaryOperator::create(BinOp->getOpcode(), PhiVal, ConstantOp);
@@ -7327,7 +7323,7 @@
// If the index will be to exactly the right offset with the scale taken
// out, perform the transformation.
if (Scale && Scale->getZExtValue() % ArrayEltSize == 0) {
- if (ConstantInt *C = dyn_cast<ConstantInt>(Scale))
+ if (isa<ConstantInt>(Scale))
Scale = ConstantInt::get(Scale->getType(),
Scale->getZExtValue() / ArrayEltSize);
if (Scale->getZExtValue() != 1) {
@@ -7501,7 +7497,7 @@
Value *Op = LI.getOperand(0);
// load (cast X) --> cast (load X) iff safe
- if (CastInst *CI = dyn_cast<CastInst>(Op))
+ if (isa<CastInst>(Op))
if (Instruction *Res = InstCombineLoadCast(*this, LI))
return Res;
@@ -7728,7 +7724,7 @@
// If the pointer destination is a cast, see if we can fold the cast into the
// source instead.
- if (CastInst *CI = dyn_cast<CastInst>(Ptr))
+ if (isa<CastInst>(Ptr))
if (Instruction *Res = InstCombineStoreToCast(*this, SI))
return Res;
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr))
@@ -8015,7 +8011,7 @@
InsertNewInstBefore(newEI1, EI);
return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1);
}
- } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
+ } else if (isa<LoadInst>(I)) {
Value *Ptr = InsertCastBefore(I->getOperand(0),
PointerType::get(EI.getType()), EI);
GetElementPtrInst *GEP =
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 5b64e54f..dc6b986 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -307,7 +307,7 @@
Start = SCEVAddExpr::get(Start, AE->getOperand(i));
}
- } else if (SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(SH)) {
+ } else if (isa<SCEVAddRecExpr>(SH)) {
TheAddRec = SH;
} else {
return false; // not analyzable.
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp
index 9c59dd3..2fa3fcd 100644
--- a/lib/Transforms/Scalar/LoopUnroll.cpp
+++ b/lib/Transforms/Scalar/LoopUnroll.cpp
@@ -92,7 +92,7 @@
// Ignore PHI nodes in the header.
} else if (I->hasOneUse() && I->use_back() == Term) {
// Ignore instructions only used by the loop terminator.
- } else if (DbgInfoIntrinsic *DbgI = dyn_cast<DbgInfoIntrinsic>(I)) {
+ } else if (isa<DbgInfoIntrinsic>(I)) {
// Ignore debug instructions
} else {
++Size;
@@ -135,7 +135,6 @@
return 0;
DEBUG(std::cerr << "Merging: " << *BB << "into: " << *OnlyPred);
- TerminatorInst *Term = OnlyPred->getTerminator();
// Resolve any PHI nodes at the start of the block. They are all
// guaranteed to have exactly one entry if they exist, unless there are
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 9521725..a91d295 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -576,8 +576,6 @@
// Split all of the edges from inside the loop to their exit blocks. Update
// the appropriate Phi nodes as we do so.
- unsigned NumBlocks = L->getBlocks().size();
-
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
BasicBlock *ExitBlock = ExitBlocks[i];
std::vector<BasicBlock*> Preds(pred_begin(ExitBlock), pred_end(ExitBlock));
@@ -966,9 +964,8 @@
BasicBlock* Split = SplitBlock(Old, SI);
Instruction* OldTerm = Old->getTerminator();
- BranchInst* Branch = new BranchInst(Split, SI->getSuccessor(i),
- ConstantBool::getTrue(),
- OldTerm);
+ new BranchInst(Split, SI->getSuccessor(i),
+ ConstantBool::getTrue(), OldTerm);
Old->getTerminator()->eraseFromParent();
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 44634cd..8e585c2 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -377,7 +377,7 @@
Succs[BCValue.getConstant() == ConstantBool::getFalse()] = true;
}
}
- } else if (InvokeInst *II = dyn_cast<InvokeInst>(&TI)) {
+ } else if (isa<InvokeInst>(&TI)) {
// Invoke instructions successors are always executable.
Succs[0] = Succs[1] = true;
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(&TI)) {
@@ -436,7 +436,7 @@
}
return false;
}
- } else if (InvokeInst *II = dyn_cast<InvokeInst>(TI)) {
+ } else if (isa<InvokeInst>(TI)) {
// Invoke instructions successors are always executable.
return true;
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index ffb095a..3eba528 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -302,7 +302,7 @@
if (const ArrayType *AT = dyn_cast<ArrayType>(*I)) {
uint64_t NumElements = AT->getNumElements();
- if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) {
+ if (isa<ConstantInt>(I.getOperand())) {
// Check to make sure that index falls within the array. If not,
// something funny is going on, so we won't do the optimization.
//
diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp
index 14c4d8b..e732392 100644
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -161,7 +161,6 @@
// occurs when a function passes an argument straight through to its tail
// call.
if (!ArgumentPHIs.empty()) {
- unsigned NumIncoming = ArgumentPHIs[0]->getNumIncomingValues();
for (unsigned i = 0, e = ArgumentPHIs.size(); i != e; ++i) {
PHINode *PN = ArgumentPHIs[i];
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index f80b153..30a7add 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -361,10 +361,7 @@
// requires the CFG to be up-to-date.
for (unsigned phino = 0, e = PHIToResolve.size(); phino != e; ) {
const PHINode *OPN = PHIToResolve[phino];
-
unsigned NumPreds = OPN->getNumIncomingValues();
-
- unsigned BBPHIStart = phino;
const BasicBlock *OldBB = OPN->getParent();
BasicBlock *NewBB = cast<BasicBlock>(ValueMap[OldBB]);
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index 620a581..19293f4 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -763,7 +763,6 @@
// If NewBB dominates some blocks, then it will dominate all blocks that
// NewBBSucc does.
if (NewBBDominatesNewBBSucc) {
- BasicBlock *PredBlock = PredBlocks[0];
Function *F = NewBB->getParent();
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
if (DS.dominates(NewBBSucc, I))
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 1816144..3385ba1 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -370,7 +370,6 @@
// Scan all of the uses and see if the live range is live across an unwind
// edge. If we find a use live across an invoke edge, create an alloca
// and spill the value.
- AllocaInst *SpillLoc = 0;
std::set<InvokeInst*> InvokesWithStoreInserted;
// Find all of the blocks that this value is live in.
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 9794ed6..de9f8ec 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1340,7 +1340,7 @@
}
}
}
- } else if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->begin())) {
+ } else if (isa<UnwindInst>(BB->begin())) {
// Check to see if the first instruction in this block is just an unwind.
// If so, replace any invoke instructions which use this as an exception
// destination with call instructions, and any unconditional branch
@@ -1409,7 +1409,7 @@
return 1;
} else { // Conditional branch
- if (Value *CompVal = isValueEqualityComparison(BI)) {
+ if (isValueEqualityComparison(BI)) {
// If we only have one predecessor, and if it is a branch on this value,
// see if that predecessor totally determines the outcome of this
// switch.
@@ -1764,7 +1764,6 @@
if (OnlySucc) {
DEBUG(std::cerr << "Merging: " << *BB << "into: " << *OnlyPred);
- TerminatorInst *Term = OnlyPred->getTerminator();
// Resolve any PHI nodes at the start of the block. They are all
// guaranteed to have exactly one entry if they exist, unless there are