#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
-#include "llvm/iPHINode.h"
-#include "llvm/iMemory.h"
-#include "llvm/iTerminators.h"
-#include "llvm/iOther.h"
+#include "llvm/Instructions.h"
#include "llvm/Constants.h"
#include "Support/STLExtras.h"
#include "Support/Statistic.h"
#include <algorithm>
-using std::map;
-using std::vector;
-
// ValuePlaceHolder - A stupid little marker value. It appears as an
// instruction of type Instruction::UserOp1.
//
if (Ty->isPrimitiveType() ||
isa<OpaqueType>(Ty)) return Ty; // Don't convert primitives
- map<const Type *, PATypeHolder>::iterator I = TypeMap.find(Ty);
+ std::map<const Type *, PATypeHolder>::iterator I = TypeMap.find(Ty);
if (I != TypeMap.end()) return I->second;
const Type *DestTy = 0;
case Type::FunctionTyID: {
const FunctionType *MT = cast<FunctionType>(Ty);
const Type *RetTy = ConvertType(MT->getReturnType());
- vector<const Type*> ArgTypes;
+ std::vector<const Type*> ArgTypes;
for (FunctionType::ParamTypes::const_iterator I = MT->getParamTypes().begin(),
E = MT->getParamTypes().end(); I != E; ++I)
case Type::StructTyID: {
const StructType *ST = cast<StructType>(Ty);
const StructType::ElementTypes &El = ST->getElementTypes();
- vector<const Type *> Types;
+ std::vector<const Type *> Types;
for (StructType::ElementTypes::const_iterator I = El.begin(), E = El.end();
I != E; ++I)
// using the specified OldTy as the base type being indexed into.
//
void MutateStructTypes::AdjustIndices(const CompositeType *OldTy,
- vector<Value*> &Idx,
+ std::vector<Value*> &Idx,
unsigned i) {
assert(i < Idx.size() && "i out of range!");
const CompositeType *NewCT = cast<CompositeType>(ConvertType(OldTy));
unsigned ElNum = cast<ConstantUInt>(Idx[i])->getValue();
assert(ElNum < OldST->getElementTypes().size());
- map<const StructType*, TransformType>::iterator I = Transforms.find(OldST);
+ std::map<const StructType*, TransformType>::iterator
+ I = Transforms.find(OldST);
if (I != Transforms.end()) {
assert(ElNum < I->second.second.size());
// Apply the XForm specified by Transforms map...
// Check to see if this is an out of function reference first...
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
// Check to see if the value is in the map...
- map<const GlobalValue*, GlobalValue*>::iterator I = GlobalMap.find(GV);
+ std::map<const GlobalValue*, GlobalValue*>::iterator I = GlobalMap.find(GV);
if (I == GlobalMap.end())
return (Value*)GV; // Not mapped, just return value itself
return I->second;
}
- map<const Value*, Value*>::iterator I = LocalValueMap.find(V);
+ std::map<const Value*, Value*>::iterator I = LocalValueMap.find(V);
if (I != LocalValueMap.end()) return I->second;
if (const BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
// Loop over the types and insert dummy entries into the type map so that
// recursive types are resolved properly...
- for (map<const StructType*, vector<int> >::const_iterator I = XForm.begin(),
- E = XForm.end(); I != E; ++I) {
+ for (std::map<const StructType*, std::vector<int> >::const_iterator
+ I = XForm.begin(), E = XForm.end(); I != E; ++I) {
const StructType *OldTy = I->first;
TypeMap.insert(std::make_pair(OldTy, OpaqueType::get()));
}
// Loop over the type specified and figure out what types they should become
- for (map<const StructType*, vector<int> >::const_iterator I = XForm.begin(),
- E = XForm.end(); I != E; ++I) {
+ for (std::map<const StructType*, std::vector<int> >::const_iterator
+ I = XForm.begin(), E = XForm.end(); I != E; ++I) {
const StructType *OldTy = I->first;
- const vector<int> &InVec = I->second;
+ const std::vector<int> &InVec = I->second;
assert(OldTy->getElementTypes().size() == InVec.size() &&
"Action not specified for every element of structure type!");
- vector<const Type *> NewType;
+ std::vector<const Type *> NewType;
// Convert the elements of the type over, including the new position mapping
int Idx = 0;
- vector<int>::const_iterator TI = find(InVec.begin(), InVec.end(), Idx);
+ std::vector<int>::const_iterator TI = find(InVec.begin(), InVec.end(), Idx);
while (TI != InVec.end()) {
unsigned Offset = TI-InVec.begin();
const Type *NewEl = ConvertType(OldTy->getContainedType(Offset));
//
void MutateStructTypes::transformFunction(Function *m) {
const Function *M = m;
- map<const GlobalValue*, GlobalValue*>::iterator GMI = GlobalMap.find(M);
+ std::map<const GlobalValue*, GlobalValue*>::iterator GMI = GlobalMap.find(M);
if (GMI == GlobalMap.end())
return; // Do not affect one of our new functions that we are creating
break;
case Instruction::GetElementPtr: {
const GetElementPtrInst &GEP = cast<GetElementPtrInst>(I);
- vector<Value*> Indices(GEP.idx_begin(), GEP.idx_end());
+ std::vector<Value*> Indices(GEP.idx_begin(), GEP.idx_end());
if (!Indices.empty()) {
const Type *PTy =
cast<PointerType>(GEP.getOperand(0)->getType())->getElementType();
break;
case Instruction::Call: {
Value *Meth = ConvertValue(I.getOperand(0));
- vector<Value*> Operands;
+ std::vector<Value*> Operands;
for (unsigned i = 1; i < I.getNumOperands(); ++i)
Operands.push_back(ConvertValue(I.getOperand(i)));
NewI = new CallInst(Meth, Operands);
NewBB->getInstList().push_back(NewI);
// Check to see if we had to make a placeholder for this value...
- map<const Value*,Value*>::iterator LVMI = LocalValueMap.find(&I);
+ std::map<const Value*,Value*>::iterator LVMI = LocalValueMap.find(&I);
if (LVMI != LocalValueMap.end()) {
// Yup, make sure it's a placeholder...
Instruction *I = cast<Instruction>(LVMI->second);
#include "Support/DepthFirstIterator.h"
#include "Support/Statistic.h"
#include <algorithm>
-using std::cerr;
-using std::vector;
namespace {
Statistic<> NumBlockRemoved("adce", "Number of basic blocks removed");
inline void markInstructionLive(Instruction *I) {
if (LiveSet.count(I)) return;
- DEBUG(cerr << "Insn Live: " << I);
+ DEBUG(std::cerr << "Insn Live: " << I);
LiveSet.insert(I);
WorkList.push_back(I);
}
inline void markTerminatorLive(const BasicBlock *BB) {
- DEBUG(cerr << "Terminat Live: " << BB->getTerminator());
+ DEBUG(std::cerr << "Terminat Live: " << BB->getTerminator());
markInstructionLive((Instruction*)BB->getTerminator());
}
};
}
}
- DEBUG(cerr << "Processing work list\n");
+ DEBUG(std::cerr << "Processing work list\n");
// AliveBlocks - Set of basic blocks that we know have instructions that are
// alive in them...
markInstructionLive(Operand);
}
- if (DebugFlag) {
- cerr << "Current Function: X = Live\n";
+ DEBUG(
+ std::cerr << "Current Function: X = Live\n";
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
- if (LiveSet.count(BI)) cerr << "X ";
- cerr << *BI;
+ if (LiveSet.count(BI)) std::cerr << "X ";
+ std::cerr << *BI;
}
- }
+ );
// Find the first postdominator of the entry node that is alive. Make it the
// new entry node...
if (!AliveBlocks.count(BB)) {
// Remove all outgoing edges from this basic block and convert the
// terminator into a return instruction.
- vector<BasicBlock*> Succs(succ_begin(BB), succ_end(BB));
+ std::vector<BasicBlock*> Succs(succ_begin(BB), succ_end(BB));
if (!Succs.empty()) {
// Loop over all of the successors, removing this block from PHI node