aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-01-20 22:54:45 +0000
committerChris Lattner <sabre@nondot.org>2002-01-20 22:54:45 +0000
commit697954c15da58bd8b186dbafdedd8b06db770201 (patch)
treee119a71f09b5c2513c8c270161ae2a858c6f3b96 /lib/Transforms
parent13c4659220bc78a0a3529f4d9e57546e898088e3 (diff)
Changes to build successfully with GCC 3.02
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1503 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp40
-rw-r--r--lib/Transforms/HoistPHIConstants.cpp10
-rw-r--r--lib/Transforms/IPO/ConstantMerge.cpp8
-rw-r--r--lib/Transforms/IPO/DeadTypeElimination.cpp22
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp8
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp13
-rw-r--r--lib/Transforms/IPO/MutateStructTypes.cpp16
-rw-r--r--lib/Transforms/IPO/SimpleStructMutation.cpp14
-rw-r--r--lib/Transforms/Instrumentation/TraceValues.cpp15
-rw-r--r--lib/Transforms/LevelRaise.cpp8
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp20
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp2
-rw-r--r--lib/Transforms/Scalar/DCE.cpp4
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp10
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp18
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp4
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp14
-rw-r--r--lib/Transforms/Scalar/SymbolStripping.cpp2
-rw-r--r--lib/Transforms/TransformInternals.cpp4
-rw-r--r--lib/Transforms/TransformInternals.h15
-rw-r--r--lib/Transforms/Utils/Linker.cpp32
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp2
-rw-r--r--lib/Transforms/Utils/UnifyFunctionExitNodes.cpp1
23 files changed, 155 insertions, 127 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 02e14b6caa..7f33fe280b 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -18,6 +18,8 @@
#include "Support/STLExtras.h"
#include <map>
#include <algorithm>
+#include <iostream>
+using std::cerr;
#include "llvm/Assembly/Writer.h"
@@ -96,7 +98,8 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
}
static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
- const string &Name, ValueMapCache &VMC){
+ const std::string &Name,
+ ValueMapCache &VMC){
BasicBlock *BB = MI->getParent();
BasicBlock::iterator It = BB->end();
@@ -270,7 +273,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
// index array. If there are, check to see if removing them causes us to
// get to the right type...
//
- vector<Value*> Indices = GEP->copyIndices();
+ std::vector<Value*> Indices = GEP->copyIndices();
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *ElTy = 0;
@@ -302,7 +305,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
// Check to see if 'N' is an expression that can be converted to
// the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(PTy, I->getOperand(1), Indices);
if (ElTy) {
assert(ElTy == PVTy && "Internal error, setup wrong!");
@@ -378,7 +381,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
BasicBlock *BB = I->getParent();
BasicBlock::InstListType &BIL = BB->getInstList();
- string Name = I->getName(); if (!Name.empty()) I->setName("");
+ std::string Name = I->getName(); if (!Name.empty()) I->setName("");
Instruction *Res; // Result of conversion
ValueHandle IHandle(VMC, I); // Prevent I from being removed!
@@ -460,7 +463,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
// index array. If there are, check to see if removing them causes us to
// get to the right type...
//
- vector<Value*> Indices = GEP->copyIndices();
+ std::vector<Value*> Indices = GEP->copyIndices();
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *PVTy = cast<PointerType>(Ty)->getElementType();
Res = 0;
@@ -491,7 +494,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
// Check to see if 'N' is an expression that can be converted to
// the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(NewSrcTy, I->getOperand(1),
Indices, &It);
if (ElTy) {
@@ -634,7 +637,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
case Instruction::Add:
if (isa<PointerType>(Ty)) {
Value *IndexVal = I->getOperand(V == I->getOperand(0) ? 1 : 0);
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
if (const Type *ETy = ConvertableToGEP(Ty, IndexVal, Indices)) {
const Type *RetTy = PointerType::get(ETy);
@@ -685,7 +688,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// They could be loading the first element of a composite type...
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
unsigned Offset = 0; // No offset, get first leaf.
- vector<Value*> Indices; // Discarded...
+ std::vector<Value*> Indices; // Discarded...
LoadedTy = getStructOffsetType(CT, Offset, Indices, false);
assert(Offset == 0 && "Offset changed from zero???");
}
@@ -751,7 +754,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// Check to see if the second argument is an expression that can
// be converted to the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(Ty, Index, Indices);
delete TempScale; // Free our temporary multiply if we made it
@@ -823,7 +826,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
BasicBlock *BB = I->getParent();
BasicBlock::InstListType &BIL = BB->getInstList();
- string Name = I->getName(); if (!Name.empty()) I->setName("");
+ std::string Name = I->getName(); if (!Name.empty()) I->setName("");
Instruction *Res; // Result of conversion
//cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I << "BB Before: " << BB << endl;
@@ -844,12 +847,12 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
case Instruction::Add:
if (isa<PointerType>(NewTy)) {
Value *IndexVal = I->getOperand(OldVal == I->getOperand(0) ? 1 : 0);
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
BasicBlock::iterator It = find(BIL.begin(), BIL.end(), I);
if (const Type *ETy = ConvertableToGEP(NewTy, IndexVal, Indices, &It)) {
// If successful, convert the add to a GEP
- const Type *RetTy = PointerType::get(ETy);
+ //const Type *RetTy = PointerType::get(ETy);
// First operand is actually the given pointer...
Res = new GetElementPtrInst(NewVal, Indices, Name);
assert(cast<PointerType>(Res->getType())->getElementType() == ETy &&
@@ -892,7 +895,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
const Type *LoadedTy =
cast<PointerType>(NewVal->getType())->getElementType();
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
@@ -914,7 +917,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC));
} else { // Replace the source pointer
const Type *ValTy = cast<PointerType>(NewTy)->getElementType();
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
#if 0
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
while (ArrayType *AT = dyn_cast<ArrayType>(ValTy)) {
@@ -948,7 +951,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
// Perform the conversion now...
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(NewVal->getType(), Index, Indices, &It);
assert(ElTy != 0 && "GEP Conversion Failure!");
Res = new GetElementPtrInst(NewVal, Indices, Name);
@@ -965,7 +968,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
// Check to see if the second argument is an expression that can
// be converted to the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(NewVal->getType(), I->getOperand(1),
Indices, &It);
assert(ElTy != 0 && "GEP Conversion Failure!");
@@ -1001,9 +1004,10 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
case Instruction::Call: {
Value *Meth = I->getOperand(0);
- vector<Value*> Params(I->op_begin()+1, I->op_end());
+ std::vector<Value*> Params(I->op_begin()+1, I->op_end());
- vector<Value*>::iterator OI = find(Params.begin(), Params.end(), OldVal);
+ std::vector<Value*>::iterator OI =
+ find(Params.begin(), Params.end(), OldVal);
assert (OI != Params.end() && "Not using value!");
*OI = NewVal;
diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp
index e28e8a2fe4..43ed725d94 100644
--- a/lib/Transforms/HoistPHIConstants.cpp
+++ b/lib/Transforms/HoistPHIConstants.cpp
@@ -14,8 +14,8 @@
#include <map>
#include <vector>
-typedef pair<BasicBlock *, Value*> BBConstTy;
-typedef map<BBConstTy, CastInst *> CachedCopyMap;
+typedef std::pair<BasicBlock *, Value*> BBConstTy;
+typedef std::map<BBConstTy, CastInst *> CachedCopyMap;
static Value *NormalizePhiOperand(PHINode *PN, Value *CPV,
BasicBlock *Pred, CachedCopyMap &CopyCache) {
@@ -33,7 +33,7 @@ static Value *NormalizePhiOperand(PHINode *PN, Value *CPV,
// Create a copy instruction and add it to the cache...
CastInst *Inst = new CastInst(CPV, CPV->getType());
- CopyCache.insert(make_pair(BBConstTy(Pred, CPV), Inst));
+ CopyCache.insert(std::make_pair(BBConstTy(Pred, CPV), Inst));
// Insert the copy just before the terminator inst of the predecessor BB
assert(Pred->getTerminator() && "Degenerate BB encountered!");
@@ -52,7 +52,7 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) {
bool Changed = false;
for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) {
- vector<PHINode*> phis; // normalizing invalidates BB iterator
+ std::vector<PHINode*> phis; // normalizing invalidates BB iterator
for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) {
if (PHINode *PN = dyn_cast<PHINode>(*II))
@@ -61,7 +61,7 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) {
break; // All PHIs occur at top of BB!
}
- for (vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end(); ++PI)
+ for (std::vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end();++PI)
for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) {
Value *Op = (*PI)->getIncomingValue(i);
diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp
index 70e3437bb9..ff2442d2b6 100644
--- a/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/lib/Transforms/IPO/ConstantMerge.cpp
@@ -23,7 +23,7 @@
//
static inline
bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
- map<Constant*, GlobalVariable*> &CMap) {
+ std::map<Constant*, GlobalVariable*> &CMap) {
Module::GlobalListType &GList = M->getGlobalList();
if (GList.size() <= ConstantNo) return false; // No new constants
bool MadeChanges = false;
@@ -35,10 +35,10 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
Constant *Init = GV->getInitializer();
// Check to see if the initializer is already known...
- map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
+ std::map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
if (I == CMap.end()) { // Nope, add it to the map
- CMap.insert(make_pair(Init, GV));
+ CMap.insert(std::make_pair(Init, GV));
} else { // Yup, this is a duplicate!
// Make all uses of the duplicate constant use the cannonical version...
GV->replaceAllUsesWith(I->second);
@@ -59,7 +59,7 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
// deal with passes.
//
bool ConstantMerge::mergeDuplicateConstants(Module *M) {
- map<Constant*, GlobalVariable*> Constants;
+ std::map<Constant*, GlobalVariable*> Constants;
unsigned LastConstantSeen = 0;
return ::mergeDuplicateConstants(M, LastConstantSeen, Constants);
}
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index ec4c3fd66e..d5e9ea07bd 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -23,6 +23,10 @@
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
#include <algorithm>
+#include <iostream>
+using std::vector;
+using std::string;
+using std::cerr;
static const Type *PtrSByte = 0; // 'sbyte*' type
@@ -78,7 +82,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
SymbolTable *ST = M->getSymbolTable();
if (!ST) return false;
- map<string, vector<Method*> > Methods;
+ std::map<string, vector<Method*> > Methods;
// Loop over the entries in the symbol table. If an entry is a method pointer,
// then add it to the Methods map. We do a two pass algorithm here to avoid
@@ -86,7 +90,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
//
for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I)
if (const PointerType *PT = dyn_cast<PointerType>(I->first))
- if (const MethodType *MT = dyn_cast<MethodType>(PT->getElementType())) {
+ if (isa<MethodType>(PT->getElementType())) {
SymbolTable::VarMap &Plane = I->second;
for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end();
PI != PE; ++PI) {
@@ -101,7 +105,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
// Now we have a list of all methods with a particular name. If there is more
// than one entry in a list, merge the methods together.
//
- for (map<string, vector<Method*> >::iterator I = Methods.begin(),
+ for (std::map<string, vector<Method*> >::iterator I = Methods.begin(),
E = Methods.end(); I != E; ++I) {
vector<Method*> &Methods = I->second;
Method *Implementation = 0; // Find the implementation
@@ -145,7 +149,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
cerr << "Warning: Found methods types that are not compatible:\n";
for (unsigned i = 0; i < Methods.size(); ++i) {
cerr << "\t" << Methods[i]->getType()->getDescription() << " %"
- << Methods[i]->getName() << endl;
+ << Methods[i]->getName() << "\n";
}
cerr << " No linkage of methods named '" << Methods[0]->getName()
<< "' performed!\n";
@@ -185,7 +189,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
++i;
}
} else {
- cerr << "Cannot convert use of method: " << U << endl;
+ cerr << "Cannot convert use of method: " << U << "\n";
++i;
}
}
@@ -201,7 +205,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
// ShouldNukSymtabEntry - Return true if this module level symbol table entry
// should be eliminated.
//
-static inline bool ShouldNukeSymtabEntry(const pair<string, Value*> &E) {
+static inline bool ShouldNukeSymtabEntry(const std::pair<string, Value*> &E) {
// Nuke all names for primitive types!
if (cast<Type>(E.second)->isPrimitiveType()) return true;
@@ -357,8 +361,8 @@ static inline bool FixCastsAndPHIs(BasicBlock *BB) {
Value *Src = CI->getOperand(0);
// Move the cast instruction to the current insert position...
- --InsertPos; // New position for cast to go...
- swap(*InsertPos, *I); // Cast goes down, PHI goes up
+ --InsertPos; // New position for cast to go...
+ std::swap(*InsertPos, *I); // Cast goes down, PHI goes up
if (isa<PHINode>(Src) && // Handle case #1
cast<PHINode>(Src)->getParent() == BB) {
@@ -561,7 +565,7 @@ bool CleanupGCCOutput::doPassFinalization(Module *M) {
if (M->hasSymbolTable()) {
SymbolTable *ST = M->getSymbolTable();
- const set<const Type *> &UsedTypes = FUT.getTypes();
+ const std::set<const Type *> &UsedTypes = FUT.getTypes();
// Check the symbol table for superfluous type entries that aren't used in
// the program
diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp
index 7395bab803..dacd3295ef 100644
--- a/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/lib/Transforms/IPO/GlobalDCE.cpp
@@ -18,14 +18,14 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) {
// Calculate which methods are reachable from the external methods in the call
// graph.
//
- set<cfg::CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
- df_end(&CallGraph));
+ std::set<cfg::CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
+ df_end(&CallGraph));
// Loop over the methods in the module twice. The first time is used to drop
// references that methods have to each other before they are deleted. The
// second pass removes the methods that need to be removed.
//
- vector<cfg::CallGraphNode*> MethodsToDelete; // Track unused methods
+ std::vector<cfg::CallGraphNode*> MethodsToDelete; // Track unused methods
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
cfg::CallGraphNode *N = CallGraph[*I];
if (!ReachableNodes.count(N)) { // Not reachable??
@@ -45,7 +45,7 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) {
// Unreachables methods have been found and should have no references to them,
// delete them now.
//
- for (vector<cfg::CallGraphNode*>::iterator I = MethodsToDelete.begin(),
+ for (std::vector<cfg::CallGraphNode*>::iterator I = MethodsToDelete.begin(),
E = MethodsToDelete.end(); I != E; ++I)
delete CallGraph.removeMethodFromModule(*I);
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index 40b98bd67d..9d86c86895 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -27,6 +27,8 @@
#include "llvm/iOther.h"
#include <algorithm>
#include <map>
+#include <iostream>
+using std::cerr;
#include "llvm/Assembly/Writer.h"
@@ -36,7 +38,7 @@ using namespace opt;
// current values into those specified by ValueMap.
//
static inline void RemapInstruction(Instruction *I,
- map<const Value *, Value*> &ValueMap) {
+ std::map<const Value *, Value*> &ValueMap) {
for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
const Value *Op = I->getOperand(op);
@@ -45,8 +47,8 @@ static inline void RemapInstruction(Instruction *I,
continue; // Globals and constants don't get relocated
if (!V) {
- cerr << "Val = " << endl << Op << "Addr = " << (void*)Op << endl;
- cerr << "Inst = " << I;
+ cerr << "Val = \n" << Op << "Addr = " << (void*)Op;
+ cerr << "\nInst = " << I;
}
assert(V && "Referenced value not in value map!");
I->setOperand(op, V);
@@ -72,10 +74,9 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) {
const Method *CalledMeth = CI->getCalledMethod();
if (CalledMeth == 0 || // Can't inline external method or indirect call!
CalledMeth->isExternal()) return false;
- Method *CurrentMeth = CI->getParent()->getParent();
//cerr << "Inlining " << CalledMeth->getName() << " into "
- // << CurrentMeth->getName() << endl;
+ // << CurrentMeth->getName() << "\n";
BasicBlock *OrigBB = CI->getParent();
@@ -111,7 +112,7 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) {
// code's values. This includes all of: Method arguments, instruction values,
// constant pool entries, and basic blocks.
//
- map<const Value *, Value*> ValueMap;
+ std::map<const Value *, Value*> ValueMap;
// Add the method arguments to the mapping: (start counting at 1 to skip the
// method reference itself)
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index c91c00c647..df2b67ef41 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -21,6 +21,9 @@
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
#include <algorithm>
+using std::map;
+using std::make_pair;
+using std::vector;
// To enable debugging, uncomment this...
//#define DEBUG_MST(x) x
@@ -37,7 +40,7 @@
struct ValuePlaceHolder : public Instruction {
ValuePlaceHolder(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
- virtual Instruction *clone() const { abort(); }
+ virtual Instruction *clone() const { abort(); return 0; }
virtual const char *getOpcodeName() const { return "placeholder"; }
};
@@ -291,8 +294,8 @@ bool MutateStructTypes::doPassInitialization(Module *M) {
// of the methods and global variables that we no longer need.
bool MutateStructTypes::doPassFinalization(Module *M) {
// The first half of the methods in the module have to go.
- unsigned NumMethods = M->size();
- unsigned NumGVars = M->gsize();
+ //unsigned NumMethods = M->size();
+ //unsigned NumGVars = M->gsize();
// Prepare for deletion of globals by dropping their interdependencies...
for(Module::iterator I = M->begin(); I != M->end(); ++I) {
@@ -436,12 +439,11 @@ bool MutateStructTypes::doPerMethodWork(Method *m) {
AdjustIndices(cast<CompositeType>(PTy), Indices);
}
- if (const LoadInst *LI = dyn_cast<LoadInst>(I)) {
+ if (isa<LoadInst>(I)) {
NewI = new LoadInst(NewPtr, Indices);
- } else if (const StoreInst *SI = dyn_cast<StoreInst>(I)) {
+ } else if (isa<StoreInst>(I)) {
NewI = new StoreInst(ConvertValue(I->getOperand(0)), NewPtr, Indices);
- } else if (const GetElementPtrInst *GEP =
- dyn_cast<GetElementPtrInst>(I)) {
+ } else if (isa<GetElementPtrInst>(I)) {
NewI = new GetElementPtrInst(NewPtr, Indices);
} else {
assert(0 && "Unknown memory access inst!!!");
diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp
index d9385453e8..d0b8bb2807 100644
--- a/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/lib/Transforms/IPO/SimpleStructMutation.cpp
@@ -12,9 +12,14 @@
#include "llvm/Analysis/FindUnsafePointerTypes.h"
#include "TransformInternals.h"
#include <algorithm>
+#include <iostream>
+using std::vector;
+using std::set;
+using std::pair;
#include "llvm/Assembly/Writer.h"
+
// PruneTypes - Given a type Ty, make sure that neither it, or one of its
// subtypes, occur in TypesToModify.
//
@@ -26,7 +31,7 @@ static void PruneTypes(const Type *Ty, set<const StructType*> &TypesToModify,
// If the element is in TypesToModify, remove it now...
if (const StructType *ST = dyn_cast<StructType>(Ty)) {
TypesToModify.erase(ST); // This doesn't fail if the element isn't present
- cerr << "Unable to swap type: " << ST << endl;
+ std::cerr << "Unable to swap type: " << ST << "\n";
}
// Remove all types that this type contains as well... do not remove types
@@ -69,7 +74,8 @@ static inline void GetTransformation(const StructType *ST,
// Build mapping from index to size
for (unsigned i = 0; i < NumElements; ++i)
- ElList.push_back(make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
+ ElList.push_back(
+ std::make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess));
@@ -118,14 +124,14 @@ PrebuiltStructMutation::TransformsType
set<const Type*> ProcessedTypes;
for (set<PointerType*>::const_iterator I = UnsafePTys.begin(),
E = UnsafePTys.end(); I != E; ++I) {
- //cerr << "Pruning type: " << *I << endl;
+ //cerr << "Pruning type: " << *I << "\n";
PruneTypes(*I, TypesToModify, ProcessedTypes);
}
// Build up a set of structure types that we are going to modify, and
// information describing how to modify them.
- map<const StructType*, vector<int> > Transforms;
+ std::map<const StructType*, vector<int> > Transforms;
for (set<const StructType*>::iterator I = TypesToModify.begin(),
E = TypesToModify.end(); I != E; ++I) {
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp
index 7948266c25..00acac8d1f 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -18,7 +18,8 @@
#include "llvm/Assembly/Writer.h"
#include "Support/StringExtras.h"
#include <sstream>
-
+using std::vector;
+using std::string;
// Add a prototype for printf if it is not already in the program.
//
@@ -110,8 +111,6 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI,
// Escape Message by replacing all % characters with %% chars.
unsigned Offset = 0;
while ((Offset = Message.find('%', Offset)) != string::npos) {
- string::iterator Offs = Message.begin()+Offset;
- //Message.replace(Offs, Offs+1, "%%");
Message.replace(Offset, 2, "%%");
Offset += 2; // Skip over the new %'s
}
@@ -140,7 +139,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI,
static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
BasicBlock::iterator &BBI,
const string &Message, Method *Printf) {
- ostringstream OutStr;
+ std::ostringstream OutStr;
if (V) WriteAsOperand(OutStr, V);
InsertPrintInst(V, BB, BBI, Message+OutStr.str()+" = ", Printf);
}
@@ -184,7 +183,7 @@ static void TraceValuesAtBBExit(BasicBlock *BB, Method *Printf,
// Copy all of the instructions into a vector to avoid problems with Setcc
const vector<Instruction*> Insts(BB->begin(), InsertPos);
- ostringstream OutStr;
+ std::ostringstream OutStr;
WriteAsOperand(OutStr, BB, false);
InsertPrintInst(0, BB, InsertPos, "LEAVING BB:" + OutStr.str(), Printf);
@@ -211,7 +210,7 @@ static inline void InsertCodeToShowMethodEntry(Method *M, Method *Printf) {
BasicBlock *BB = M->getEntryNode();
BasicBlock::iterator BBI = BB->begin();
- ostringstream OutStr;
+ std::ostringstream OutStr;
WriteAsOperand(OutStr, M, true);
InsertPrintInst(0, BB, BBI, "ENTERING METHOD: " + OutStr.str(), Printf);
@@ -231,7 +230,7 @@ static inline void InsertCodeToShowMethodExit(BasicBlock *BB, Method *Printf) {
BasicBlock::iterator BBI = BB->end()-1;
ReturnInst *Ret = cast<ReturnInst>(*BBI);
- ostringstream OutStr;
+ std::ostringstream OutStr;
WriteAsOperand(OutStr, BB->getParent(), true);
InsertPrintInst(0, BB, BBI, "LEAVING METHOD: " + OutStr.str(), Printf);
@@ -249,8 +248,6 @@ bool InsertTraceCode::doit(Method *M, bool traceBasicBlockExits,
vector<Instruction*> valuesStoredInMethod;
vector<BasicBlock*> exitBlocks;
- Module *module = M->getParent();
-
if (traceMethodEvents)
InsertCodeToShowMethodEntry(M, Printf);
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index e47eb90642..f140676937 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -75,7 +75,7 @@ static bool HandleCastToPointer(BasicBlock::iterator BI,
}
}
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
Value *Src = CI->getOperand(0);
const Type *Result = ConvertableToGEP(DestPTy, Src, Indices, &BI);
if (Result == 0) return false; // Not convertable...
@@ -137,7 +137,7 @@ static bool PeepholeOptimizeAddCast(BasicBlock *BB, BasicBlock::iterator &BI,
if (!CompTy || !SrcPtr || !OffsetVal->getType()->isIntegral())
return false;
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
if (!ConvertableToGEP(SrcPtr->getType(), OffsetVal, Indices, &BI))
return false; // Not convertable... perhaps next time
@@ -174,7 +174,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
PRINT_PEEPHOLE1("cast-of-self-ty", CI);
CI->replaceAllUsesWith(Src);
if (!Src->hasName() && CI->hasName()) {
- string Name = CI->getName();
+ std::string Name = CI->getName();
CI->setName("");
Src->setName(Name, BB->getParent()->getSymbolTable());
}
@@ -299,7 +299,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
const Type *ElTy = 0;
// Build the index vector, full of all zeros
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
while (CurCTy && !isa<PointerType>(CurCTy)) {
if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index a38dbc5617..45a57a2f43 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -17,6 +17,8 @@
#include "Support/DepthFirstIterator.h"
#include <set>
#include <algorithm>
+#include <iostream>
+using std::cerr;
#define DEBUG_ADCE 1
@@ -28,8 +30,8 @@
//
class ADCE {
Method *M; // The method that we are working on...
- vector<Instruction*> WorkList; // Instructions that just became live
- set<Instruction*> LiveSet; // The set of live instructions
+ std::vector<Instruction*> WorkList; // Instructions that just became live
+ std::set<Instruction*> LiveSet; // The set of live instructions
bool MadeChanges;
//===--------------------------------------------------------------------===//
@@ -66,8 +68,8 @@ private:
// fixupCFG - Walk the CFG in depth first order, eliminating references to
// dead blocks.
//
- BasicBlock *fixupCFG(BasicBlock *Head, set<BasicBlock*> &VisitedBlocks,
- const set<BasicBlock*> &AliveBlocks);
+ BasicBlock *fixupCFG(BasicBlock *Head, std::set<BasicBlock*> &VisitedBlocks,
+ const std::set<BasicBlock*> &AliveBlocks);
};
@@ -121,7 +123,7 @@ bool ADCE::doADCE() {
// AliveBlocks - Set of basic blocks that we know have instructions that are
// alive in them...
//
- set<BasicBlock*> AliveBlocks;