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.

llvm-svn: 31380
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 79f21b5..646f5b8e 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index bc5aecd..6cdd530 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/IndMemRemoval.cpp b/llvm/lib/Transforms/IPO/IndMemRemoval.cpp
index 78b6ea5..ef27cd6 100644
--- a/llvm/lib/Transforms/IPO/IndMemRemoval.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index c2aa4cb..c4b033c 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index ae4032b..edb34be 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/LowerSetJmp.cpp b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
index cd46718..e6ff5c9 100644
--- a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 157ea38..af11709 100644
--- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/llvm/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;