diff options
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 19 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/FunctionRepBuilder.cpp | 104 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/FunctionRepBuilder.h | 32 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/NodeImpl.cpp | 11 | ||||
-rw-r--r-- | lib/Analysis/LiveVar/BBLiveVar.cpp | 22 | ||||
-rw-r--r-- | lib/Analysis/LiveVar/BBLiveVar.h | 10 | ||||
-rw-r--r-- | lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp | 16 | ||||
-rw-r--r-- | lib/Analysis/LiveVar/ValueSet.cpp | 10 |
8 files changed, 109 insertions, 115 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 248ed918bb..8d53b41186 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -6,7 +6,6 @@ #include "llvm/Analysis/DataStructure.h" #include "llvm/Module.h" -#include "llvm/Function.h" #include <fstream> #include <algorithm> @@ -42,9 +41,9 @@ void DataStructure::print(std::ostream &O, Module *M) const { timeval TV1, TV2; gettimeofday(&TV1, 0); for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - if (!(*I)->isExternal()) { - getDSGraph(*I); - getClosedDSGraph(*I); + if (!I->isExternal() && I->getName() == "main") { + //getDSGraph(*I); + getClosedDSGraph(I); } gettimeofday(&TV2, 0); cerr << "Analysis took " @@ -53,9 +52,9 @@ void DataStructure::print(std::ostream &O, Module *M) const { } for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - if (!(*I)->isExternal()) { + if (!I->isExternal()) { - string Filename = "ds." + (*I)->getName() + ".dot"; + string Filename = "ds." + I->getName() + ".dot"; O << "Writing '" << Filename << "'..."; ofstream F(Filename.c_str()); if (F.good()) { @@ -65,8 +64,8 @@ void DataStructure::print(std::ostream &O, Module *M) const { << "\tsize=\"10,7.5\";\n" << "\trotate=\"90\";\n"; - getDSGraph(*I).printFunction(F, "Local"); - getClosedDSGraph(*I).printFunction(F, "Closed"); + getDSGraph(I).printFunction(F, "Local"); + getClosedDSGraph(I).printFunction(F, "Closed"); F << "}\n"; } else { @@ -74,8 +73,8 @@ void DataStructure::print(std::ostream &O, Module *M) const { } if (Time) - O << " [" << getDSGraph(*I).getGraphSize() << ", " - << getClosedDSGraph(*I).getGraphSize() << "]\n"; + O << " [" << getDSGraph(I).getGraphSize() << ", " + << getClosedDSGraph(I).getGraphSize() << "]\n"; else O << "\n"; } diff --git a/lib/Analysis/DataStructure/FunctionRepBuilder.cpp b/lib/Analysis/DataStructure/FunctionRepBuilder.cpp index 1566ca87da..1282d7a3b6 100644 --- a/lib/Analysis/DataStructure/FunctionRepBuilder.cpp +++ b/lib/Analysis/DataStructure/FunctionRepBuilder.cpp @@ -68,12 +68,12 @@ void InitVisitor::visitOperand(Value *V) { // node if the call returns a pointer value. Check to see if the call node // uses any global variables... // -void InitVisitor::visitCallInst(CallInst *CI) { - CallDSNode *C = new CallDSNode(CI); +void InitVisitor::visitCallInst(CallInst &CI) { + CallDSNode *C = new CallDSNode(&CI); Rep->CallNodes.push_back(C); - Rep->CallMap[CI] = C; + Rep->CallMap[&CI] = C; - if (PointerType *PT = dyn_cast<PointerType>(CI->getType())) { + if (const PointerType *PT = dyn_cast<PointerType>(CI.getType())) { // Create a critical shadow node to represent the memory object that the // return value points to... ShadowDSNode *Shad = new ShadowDSNode(PT->getElementType(), @@ -86,17 +86,17 @@ void InitVisitor::visitCallInst(CallInst *CI) { C->getLink(0).add(Shad); // The call instruction returns a pointer to the shadow block... - Rep->ValueMap[CI].add(Shad, CI); + Rep->ValueMap[&CI].add(Shad, &CI); // If the call returns a value with pointer type, add all of the users // of the call instruction to the work list... - Rep->addAllUsesToWorkList(CI); + Rep->addAllUsesToWorkList(&CI); } // Loop over all of the operands of the call instruction (except the first // one), to look for global variable references... // - for_each(CI->op_begin(), CI->op_end(), + for_each(CI.op_begin(), CI.op_end(), bind_obj(this, &InitVisitor::visitOperand)); } @@ -105,22 +105,22 @@ void InitVisitor::visitCallInst(CallInst *CI) { // allocation instructions do not take pointer arguments, they cannot refer to // global vars... // -void InitVisitor::visitAllocationInst(AllocationInst *AI) { - AllocDSNode *N = new AllocDSNode(AI); +void InitVisitor::visitAllocationInst(AllocationInst &AI) { + AllocDSNode *N = new AllocDSNode(&AI); Rep->AllocNodes.push_back(N); - Rep->ValueMap[AI].add(N, AI); + Rep->ValueMap[&AI].add(N, &AI); // Add all of the users of the malloc instruction to the work list... - Rep->addAllUsesToWorkList(AI); + Rep->addAllUsesToWorkList(&AI); } // Visit all other instruction types. Here we just scan, looking for uses of // global variables... // -void InitVisitor::visitInstruction(Instruction *I) { - for_each(I->op_begin(), I->op_end(), +void InitVisitor::visitInstruction(Instruction &I) { + for_each(I.op_begin(), I.op_end(), bind_obj(this, &InitVisitor::visitOperand)); } @@ -150,20 +150,18 @@ void FunctionRepBuilder::initializeWorkList(Function *Func) { // Add all of the arguments to the method to the graph and add all users to // the worklists... // - for (Function::ArgumentListType::iterator I = Func->getArgumentList().begin(), - E = Func->getArgumentList().end(); I != E; ++I) { - Value *Arg = (Value*)(*I); + for (Function::aiterator I = Func->abegin(), E = Func->aend(); I != E; ++I) { // Only process arguments that are of pointer type... - if (PointerType *PT = dyn_cast<PointerType>(Arg->getType())) { + if (const PointerType *PT = dyn_cast<PointerType>(I->getType())) { // Add a shadow value for it to represent what it is pointing to and add // this to the value map... ShadowDSNode *Shad = new ShadowDSNode(PT->getElementType(), Func->getParent()); ShadowNodes.push_back(Shad); - ValueMap[Arg].add(PointerVal(Shad), Arg); + ValueMap[I].add(PointerVal(Shad), I); // Make sure that all users of the argument are processed... - addAllUsesToWorkList(Arg); + addAllUsesToWorkList(I); } } @@ -179,15 +177,15 @@ void FunctionRepBuilder::initializeWorkList(Function *Func) { PointerVal FunctionRepBuilder::getIndexedPointerDest(const PointerVal &InP, - const MemAccessInst *MAI) { + const MemAccessInst &MAI) { unsigned Index = InP.Index; - const Type *SrcTy = MAI->getPointerOperand()->getType(); + const Type *SrcTy = MAI.getPointerOperand()->getType(); - for (MemAccessInst::const_op_iterator I = MAI->idx_begin(), - E = MAI->idx_end(); I != E; ++I) + for (MemAccessInst::const_op_iterator I = MAI.idx_begin(), + E = MAI.idx_end(); I != E; ++I) if ((*I)->getType() == Type::UByteTy) { // Look for struct indices... - StructType *STy = cast<StructType>(SrcTy); - unsigned StructIdx = cast<ConstantUInt>(*I)->getValue(); + const StructType *STy = cast<StructType>(SrcTy); + unsigned StructIdx = cast<ConstantUInt>(I->get())->getValue(); for (unsigned i = 0; i != StructIdx; ++i) Index += countPointerFields(STy->getContainedType(i)); @@ -211,11 +209,11 @@ static PointerValSet &getField(const PointerVal &DestPtr) { // changing. This means that the set of possible values for the GEP // needs to be expanded. // -void FunctionRepBuilder::visitGetElementPtrInst(GetElementPtrInst *GEP) { - PointerValSet &GEPPVS = ValueMap[GEP]; // PointerValSet to expand +void FunctionRepBuilder::visitGetElementPtrInst(GetElementPtrInst &GEP) { + PointerValSet &GEPPVS = ValueMap[&GEP]; // PointerValSet to expand // Get the input pointer val set... - const PointerValSet &SrcPVS = ValueMap[GEP->getOperand(0)]; + const PointerValSet &SrcPVS = ValueMap[GEP.getOperand(0)]; bool Changed = false; // Process each input value... propogating it. for (unsigned i = 0, e = SrcPVS.size(); i != e; ++i) { @@ -230,20 +228,20 @@ void FunctionRepBuilder::visitGetElementPtrInst(GetElementPtrInst *GEP) { // If our current value set changed, notify all of the users of our // value. // - if (Changed) addAllUsesToWorkList(GEP); + if (Changed) addAllUsesToWorkList(&GEP); } -void FunctionRepBuilder::visitReturnInst(ReturnInst *RI) { - RetNode.add(ValueMap[RI->getOperand(0)]); +void FunctionRepBuilder::visitReturnInst(ReturnInst &RI) { + RetNode.add(ValueMap[RI.getOperand(0)]); } -void FunctionRepBuilder::visitLoadInst(LoadInst *LI) { +void FunctionRepBuilder::visitLoadInst(LoadInst &LI) { // Only loads that return pointers are interesting... - const PointerType *DestTy = dyn_cast<PointerType>(LI->getType()); + const PointerType *DestTy = dyn_cast<PointerType>(LI.getType()); if (DestTy == 0) return; - const PointerValSet &SrcPVS = ValueMap[LI->getOperand(0)]; - PointerValSet &LIPVS = ValueMap[LI]; + const PointerValSet &SrcPVS = ValueMap[LI.getOperand(0)]; + PointerValSet &LIPVS = ValueMap[&LI]; bool Changed = false; for (unsigned si = 0, se = SrcPVS.size(); si != se; ++si) { @@ -264,18 +262,18 @@ void FunctionRepBuilder::visitLoadInst(LoadInst *LI) { } } - if (Changed) addAllUsesToWorkList(LI); + if (Changed) addAllUsesToWorkList(&LI); } -void FunctionRepBuilder::visitStoreInst(StoreInst *SI) { +void FunctionRepBuilder::visitStoreInst(StoreInst &SI) { // The only stores that are interesting are stores the store pointers // into data structures... // - if (!isa<PointerType>(SI->getOperand(0)->getType())) return; - if (!ValueMap.count(SI->getOperand(0))) return; // Src scalar has no values! + if (!isa<PointerType>(SI.getOperand(0)->getType())) return; + if (!ValueMap.count(SI.getOperand(0))) return; // Src scalar has no values! - const PointerValSet &SrcPVS = ValueMap[SI->getOperand(0)]; - const PointerValSet &PtrPVS = ValueMap[SI->getOperand(1)]; + const PointerValSet &SrcPVS = ValueMap[SI.getOperand(0)]; + const PointerValSet &PtrPVS = ValueMap[SI.getOperand(1)]; for (unsigned si = 0, se = SrcPVS.size(); si != se; ++si) { const PointerVal &SrcPtr = SrcPVS[si]; @@ -301,24 +299,24 @@ void FunctionRepBuilder::visitStoreInst(StoreInst *SI) { } } -void FunctionRepBuilder::visitCallInst(CallInst *CI) { - CallDSNode *DSN = CallMap[CI]; +void FunctionRepBuilder::visitCallInst(CallInst &CI) { + CallDSNode *DSN = CallMap[&CI]; unsigned PtrNum = 0; - for (unsigned i = 0, e = CI->getNumOperands(); i != e; ++i) - if (isa<PointerType>(CI->getOperand(i)->getType())) - DSN->addArgValue(PtrNum++, ValueMap[CI->getOperand(i)]); + for (unsigned i = 0, e = CI.getNumOperands(); i != e; ++i) + if (isa<PointerType>(CI.getOperand(i)->getType())) + DSN->addArgValue(PtrNum++, ValueMap[CI.getOperand(i)]); } -void FunctionRepBuilder::visitPHINode(PHINode *PN) { - assert(isa<PointerType>(PN->getType()) && "Should only update ptr phis"); +void FunctionRepBuilder::visitPHINode(PHINode &PN) { + assert(isa<PointerType>(PN.getType()) && "Should only update ptr phis"); - PointerValSet &PN_PVS = ValueMap[PN]; + PointerValSet &PN_PVS = ValueMap[&PN]; bool Changed = false; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - Changed |= PN_PVS.add(ValueMap[PN->getIncomingValue(i)], - PN->getIncomingValue(i)); + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) + Changed |= PN_PVS.add(ValueMap[PN.getIncomingValue(i)], + PN.getIncomingValue(i)); - if (Changed) addAllUsesToWorkList(PN); + if (Changed) addAllUsesToWorkList(&PN); } diff --git a/lib/Analysis/DataStructure/FunctionRepBuilder.h b/lib/Analysis/DataStructure/FunctionRepBuilder.h index e45ea41998..9eedf0259a 100644 --- a/lib/Analysis/DataStructure/FunctionRepBuilder.h +++ b/lib/Analysis/DataStructure/FunctionRepBuilder.h @@ -27,9 +27,9 @@ class InitVisitor : public InstVisitor<InitVisitor> { public: InitVisitor(FunctionRepBuilder *R, Function *F) : Rep(R), Func(F) {} - void visitCallInst(CallInst *CI); - void visitAllocationInst(AllocationInst *AI); - void visitInstruction(Instruction *I); + void visitCallInst(CallInst &CI); + void visitAllocationInst(AllocationInst &AI); + void visitInstruction(Instruction &I); // visitOperand - If the specified instruction operand is a global value, add // a node for it... @@ -90,7 +90,7 @@ public: const map<Value*, PointerValSet> &getValueMap() const { return ValueMap; } private: static PointerVal getIndexedPointerDest(const PointerVal &InP, - const MemAccessInst *MAI); + const MemAccessInst &MAI); void initializeWorkList(Function *Func); void processWorkList() { @@ -101,7 +101,7 @@ private: cerr << "Processing worklist inst: " << I; #endif - visit(I); // Dispatch to a visitXXX function based on instruction type... + visit(*I); // Dispatch to a visitXXX function based on instruction type... #ifdef DEBUG_DATA_STRUCTURE_CONSTRUCTION if (I->hasName() && ValueMap.count(I)) { cerr << "Inst %" << I->getName() << " value is:\n"; @@ -117,18 +117,16 @@ private: // Allow the visitor base class to invoke these methods... friend class InstVisitor<FunctionRepBuilder>; - void visitGetElementPtrInst(GetElementPtrInst *GEP); - void visitReturnInst(ReturnInst *RI); - void visitLoadInst(LoadInst *LI); - void visitStoreInst(StoreInst *SI); - void visitCallInst(CallInst *CI); - void visitPHINode(PHINode *PN); - void visitSetCondInst(SetCondInst *SCI) {} // SetEQ & friends are ignored - void visitFreeInst(FreeInst *FI) {} // Ignore free instructions - void visitInstruction(Instruction *I) { - std::cerr << "\n\n\nUNKNOWN INSTRUCTION type: "; - I->dump(); - std::cerr << "\n\n\n"; + void visitGetElementPtrInst(GetElementPtrInst &GEP); + void visitReturnInst(ReturnInst &RI); + void visitLoadInst(LoadInst &LI); + void visitStoreInst(StoreInst &SI); + void visitCallInst(CallInst &CI); + void visitPHINode(PHINode &PN); + void visitSetCondInst(SetCondInst &SCI) {} // SetEQ & friends are ignored + void visitFreeInst(FreeInst &FI) {} // Ignore free instructions + void visitInstruction(Instruction &I) { + std::cerr << "\n\n\nUNKNOWN INSTRUCTION type: " << I << "\n\n\n"; assert(0 && "Cannot proceed"); } }; diff --git a/lib/Analysis/DataStructure/NodeImpl.cpp b/lib/Analysis/DataStructure/NodeImpl.cpp index 76b82ba42e..bd279b6082 100644 --- a/lib/Analysis/DataStructure/NodeImpl.cpp +++ b/lib/Analysis/DataStructure/NodeImpl.cpp @@ -8,7 +8,6 @@ #include "llvm/Assembly/Writer.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" -#include "llvm/BasicBlock.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" #include "Support/STLExtras.h" @@ -18,6 +17,7 @@ bool AllocDSNode::isEquivalentTo(DSNode *Node) const { if (AllocDSNode *N = dyn_cast<AllocDSNode>(Node)) return getType() == Node->getType(); + //&& isAllocaNode() == N->isAllocaNode(); return false; } @@ -423,12 +423,11 @@ PointerValSet FunctionDSGraph::cloneFunctionIntoSelf(const FunctionDSGraph &DSG, // Convert over the arguments... Function *OF = DSG.getFunction(); - for (Function::ArgumentListType::iterator I = OF->getArgumentList().begin(), - E = OF->getArgumentList().end(); I != E; ++I) - if (isa<PointerType>(((Value*)*I)->getType())) { + for (Function::aiterator I = OF->abegin(), E = OF->aend(); I != E; ++I) + if (isa<PointerType>(I->getType())) { PointerValSet ArgPVS; - assert(DSG.getValueMap().find((Value*)*I) != DSG.getValueMap().end()); - MapPVS(ArgPVS, DSG.getValueMap().find((Value*)*I)->second, NodeMap); + assert(DSG.getValueMap().find(I) != DSG.getValueMap().end()); + MapPVS(ArgPVS, DSG.getValueMap().find(I)->second, NodeMap); assert(!ArgPVS.empty() && "Argument has no links!"); Args.push_back(ArgPVS); } diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp index 7d735b79e4..eb58671a79 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.cpp +++ b/lib/Analysis/LiveVar/BBLiveVar.cpp @@ -18,23 +18,23 @@ using std::cerr; static AnnotationID AID(AnnotationManager::getID("Analysis::BBLiveVar")); -BBLiveVar *BBLiveVar::CreateOnBB(const BasicBlock *BB, unsigned POID) { +BBLiveVar *BBLiveVar::CreateOnBB(const BasicBlock &BB, unsigned POID) { BBLiveVar *Result = new BBLiveVar(BB, POID); - BB->addAnnotation(Result); + BB.addAnnotation(Result); return Result; } -BBLiveVar *BBLiveVar::GetFromBB(const BasicBlock *BB) { - return (BBLiveVar*)BB->getAnnotation(AID); +BBLiveVar *BBLiveVar::GetFromBB(const BasicBlock &BB) { + return (BBLiveVar*)BB.getAnnotation(AID); } -void BBLiveVar::RemoveFromBB(const BasicBlock *BB) { - bool Deleted = BB->deleteAnnotation(AID); +void BBLiveVar::RemoveFromBB(const BasicBlock &BB) { + bool Deleted = BB.deleteAnnotation(AID); assert(Deleted && "BBLiveVar annotation did not exist!"); } -BBLiveVar::BBLiveVar(const BasicBlock *bb, unsigned id) +BBLiveVar::BBLiveVar(const BasicBlock &bb, unsigned id) : Annotation(AID), BB(bb), POID(id) { InSetChanged = OutSetChanged = false; @@ -50,7 +50,7 @@ BBLiveVar::BBLiveVar(const BasicBlock *bb, unsigned id) void BBLiveVar::calcDefUseSets() { // get the iterator for machine instructions - const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec(); + const MachineCodeForBasicBlock &MIVec = BB.getMachineInstrVec(); // iterate over all the machine instructions in BB for (MachineCodeForBasicBlock::const_reverse_iterator MII = MIVec.rbegin(), @@ -129,7 +129,7 @@ void BBLiveVar::calcDefUseSets() { //----------------------------------------------------------------------------- // To add an operand which is a def //----------------------------------------------------------------------------- -void BBLiveVar::addDef(const Value *Op) { +void BBLiveVar::addDef(const Value *Op) { DefSet.insert(Op); // operand is a def - so add to def set InSet.erase(Op); // this definition kills any later uses InSetChanged = true; @@ -211,9 +211,9 @@ bool BBLiveVar::applyFlowFunc() { // bool needAnotherIt = false; - for (pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); + for (pred_const_iterator PI = pred_begin(&BB), PE = pred_end(&BB); PI != PE ; ++PI) { - BBLiveVar *PredLVBB = BBLiveVar::GetFromBB(*PI); + BBLiveVar *PredLVBB = BBLiveVar::GetFromBB(**PI); // do set union if (setPropagate(&PredLVBB->OutSet, &InSet, *PI)) { diff --git a/lib/Analysis/LiveVar/BBLiveVar.h b/lib/Analysis/LiveVar/BBLiveVar.h index 79cf7dce07..0eed3375ab 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.h +++ b/lib/Analysis/LiveVar/BBLiveVar.h @@ -24,7 +24,7 @@ enum LiveVarDebugLevel_t { extern LiveVarDebugLevel_t DEBUG_LV; class BBLiveVar : public Annotation { - const BasicBlock *BB; // pointer to BasicBlock + const BasicBlock &BB; // pointer to BasicBlock unsigned POID; // Post-Order ID ValueSet DefSet; // Def set (with no preceding uses) for LV analysis @@ -49,12 +49,12 @@ class BBLiveVar : public Annotation { void calcDefUseSets(); // calculates the Def & Use sets for this BB - BBLiveVar(const BasicBlock *BB, unsigned POID); + BBLiveVar(const BasicBlock &BB, unsigned POID); ~BBLiveVar() {} // make dtor private public: - static BBLiveVar *CreateOnBB(const BasicBlock *BB, unsigned POID); - static BBLiveVar *GetFromBB(const BasicBlock *BB); - static void RemoveFromBB(const BasicBlock *BB); + static BBLiveVar *CreateOnBB(const BasicBlock &BB, unsigned POID); + static BBLiveVar *GetFromBB(const BasicBlock &BB); + static void RemoveFromBB(const BasicBlock &BB); inline bool isInSetChanged() const { return InSetChanged; } inline bool isOutSetChanged() const { return OutSetChanged; } diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index 1105640612..ab0a761b73 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -33,12 +33,12 @@ static cl::Enum<LiveVarDebugLevel_t> DEBUG_LV_opt(DEBUG_LV, "dlivevar", cl::Hidd // gets OutSet of a BB const ValueSet &FunctionLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const { - return BBLiveVar::GetFromBB(BB)->getOutSet(); + return BBLiveVar::GetFromBB(*BB)->getOutSet(); } // gets InSet of a BB const ValueSet &FunctionLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const { - return BBLiveVar::GetFromBB(BB)->getInSet(); + return BBLiveVar::GetFromBB(*BB)->getInSet(); } @@ -46,15 +46,15 @@ const ValueSet &FunctionLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const { // Performs live var analysis for a function //----------------------------------------------------------------------------- -bool FunctionLiveVarInfo::runOnFunction(Function *Meth) { - M = Meth; +bool FunctionLiveVarInfo::runOnFunction(Function &F) { + M = &F; if (DEBUG_LV) std::cerr << "Analysing live variables ...\n"; // create and initialize all the BBLiveVars of the CFG - constructBBs(Meth); + constructBBs(M); unsigned int iter=0; - while (doSingleBackwardPass(Meth, iter++)) + while (doSingleBackwardPass(M, iter++)) ; // Iterate until we are done. if (DEBUG_LV) std::cerr << "Live Variable Analysis complete!\n"; @@ -71,7 +71,7 @@ void FunctionLiveVarInfo::constructBBs(const Function *M) { for(po_iterator<const Function*> BBI = po_begin(M), BBE = po_end(M); BBI != BBE; ++BBI, ++POId) { - const BasicBlock *BB = *BBI; // get the current BB + const BasicBlock &BB = **BBI; // get the current BB if (DEBUG_LV) std::cerr << " For BB " << RAV(BB) << ":\n"; @@ -105,7 +105,7 @@ bool FunctionLiveVarInfo::doSingleBackwardPass(const Function *M, bool NeedAnotherIteration = false; for (po_iterator<const Function*> BBI = po_begin(M), BBE = po_end(M); BBI != BBE; ++BBI) { - BBLiveVar *LVBB = BBLiveVar::GetFromBB(*BBI); + BBLiveVar *LVBB = BBLiveVar::GetFromBB(**BBI); assert(LVBB && "BasicBlock information not set for block!"); if (DEBUG_LV) std::cerr << " For BB " << (*BBI)->getName() << ":\n"; diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp index 82fccb7e84..1914f03302 100644 --- a/lib/Analysis/LiveVar/ValueSet.cpp +++ b/lib/Analysis/LiveVar/ValueSet.cpp @@ -6,13 +6,13 @@ #include <iostream> std::ostream &operator<<(std::ostream &O, RAV V) { // func to print a Value - const Value *v = V.V; - if (v->hasName()) - return O << (void*)v << "(" << v->getName() << ") "; + const Value &v = V.V; + if (v.hasName()) + return O << (void*)&v << "(" << v.getName() << ") "; else if (isa<Constant>(v)) - return O << (void*)v << "(" << v << ") "; + return O << (void*)&v << "(" << v << ") "; else - return O << (void*)v << " "; + return O << (void*)&v << " "; } void printSet(const ValueSet &S) { |