DataflowAnalysis

Home


WeChat: cstutorcs
QQ: 749389476
#include “DataflowAnalysis.h”

using namespace llvm;

namespace dataflow {
DataflowAnalysis::DataflowAnalysis(char ID) : FunctionPass(ID){}

bool DataflowAnalysis::runOnFunction(Function &F){
errs() << "Running " << getAnalysisName() << " on " << F.getName() << "\n"; for (inst_iterator I = inst_begin(F), E= inst_end(F); I != E; ++I){ inMap[&(*I)] = new SetVector;
outMap[&(*I)] = new SetVector;

doAnalysis(F);

for (inst_iterator I = inst_begin(F), E= inst_end(F); I != E; ++I){
errs() << "Instruction: " << *I << "\n"; errs() << "In set: \n"; SetVector* inSet = inMap[&(*I)];
errs() << "["; for(SetVector::iterator V = inSet->begin(), VE = inSet->end(); V != VE; ++V){
errs() << **V << "; "; errs() << "]\n"; errs() << "Out set: \n"; SetVector* outSet = outMap[&(*I)];
errs() << "["; for(SetVector::iterator V = outSet->begin(), VE = outSet->end(); V != VE; ++V){
errs() << **V << "; "; errs() << "]\n"; errs() << "\n"; for (inst_iterator I = inst_begin(F), E= inst_end(F); I != E; ++I){ delete inMap[&(*I)]; delete outMap[&(*I)]; return false;