summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
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
commit7f74a56e2436c40b18a672ad7d58727cd6832329 (patch)
tree6a4683a53f7eb71b8a3425008ef21268c2b2c8fd /llvm/lib/Transforms/IPO
parent850d4f6af1a0e9de3fa6e10afb04e3738fcc5d67 (diff)
downloadbcm5719-llvm-7f74a56e2436c40b18a672ad7d58727cd6832329.tar.gz
bcm5719-llvm-7f74a56e2436c40b18a672ad7d58727cd6832329.zip
Changes to build successfully with GCC 3.02
llvm-svn: 1503
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/ConstantMerge.cpp8
-rw-r--r--llvm/lib/Transforms/IPO/DeadTypeElimination.cpp22
-rw-r--r--llvm/lib/Transforms/IPO/GlobalDCE.cpp8
-rw-r--r--llvm/lib/Transforms/IPO/InlineSimple.cpp13
-rw-r--r--llvm/lib/Transforms/IPO/MutateStructTypes.cpp16
-rw-r--r--llvm/lib/Transforms/IPO/SimpleStructMutation.cpp14
6 files changed, 47 insertions, 34 deletions
diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp
index 70e3437bb9e..ff2442d2b65 100644
--- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp b/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp
index ec4c3fd66e6..d5e9ea07bdf 100644
--- a/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
index 7395bab8030..dacd3295ef9 100644
--- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index 40b98bd67de..9d86c868953 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/MutateStructTypes.cpp b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp
index c91c00c6477..df2b67ef41a 100644
--- a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/llvm/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/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp b/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp
index d9385453e88..d0b8bb2807c 100644
--- a/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/llvm/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) {
OpenPOWER on IntegriCloud