Convert code to use the DEBUG macro so that debug code can simply be

enabled with the -debug command line option.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2721 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-05-22 21:56:32 +00:00
parent d9036a1aad
commit f09c74c385
5 changed files with 147 additions and 197 deletions

View File

@@ -201,12 +201,9 @@ void insertBB(Edge ed,
BasicBlock* BB1=ed.getFirst()->getElement(); BasicBlock* BB1=ed.getFirst()->getElement();
BasicBlock* BB2=ed.getSecond()->getElement(); BasicBlock* BB2=ed.getSecond()->getElement();
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr << "Edges with codes ######################\n";
//debugging info cerr << BB1->getName() << "->" << BB2->getName() << "\n";
cerr<<"Edges with codes ######################\n"; cerr << "########################\n");
cerr<<BB1->getName()<<"->"<<BB2->getName()<<"\n";
cerr<<"########################\n";
#endif
//We need to insert a BB between BB1 and BB2 //We need to insert a BB between BB1 and BB2
TerminatorInst *TI=BB1->getTerminator(); TerminatorInst *TI=BB1->getTerminator();
@@ -250,9 +247,7 @@ void insertBB(Edge ed,
BB2Inst!=BBend; ++BB2Inst){ BB2Inst!=BBend; ++BB2Inst){
if(PHINode *phiInst=dyn_cast<PHINode>(*BB2Inst)){ if(PHINode *phiInst=dyn_cast<PHINode>(*BB2Inst)){
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"YYYYYYYYYYYYYYYYY\n");
cerr<<"YYYYYYYYYYYYYYYYY\n";
#endif
int bbIndex=phiInst->getBasicBlockIndex(BB1); int bbIndex=phiInst->getBasicBlockIndex(BB1);
if(bbIndex>=0) if(bbIndex>=0)

View File

@@ -239,17 +239,15 @@ Graph* Graph::getMaxSpanningTree(){
//keep pulling out vertex of min wt from vt //keep pulling out vertex of min wt from vt
while(!vt.empty()){ while(!vt.empty()){
Node *u=*(min_element(vt.begin(), vt.end(), compare_nodes())); Node *u=*(min_element(vt.begin(), vt.end(), compare_nodes()));
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"popped wt"<<(u)->getWeight()<<"\n";
cerr<<"popped wt"<<(u)->getWeight()<<"\n"; printNode(u));
printNode(u);
#endif
if(parent[u]!=NULL){ //so not root if(parent[u]!=NULL){ //so not root
Edge edge(parent[u],u, ed_weight[u]); //assign edge in spanning tree Edge edge(parent[u],u, ed_weight[u]); //assign edge in spanning tree
st->addEdge(edge,ed_weight[u]); st->addEdge(edge,ed_weight[u]);
#ifdef DEBUG_PATH_PROFILES
cerr<<"added:\n"; DEBUG(cerr<<"added:\n";
printEdge(edge); printEdge(edge));
#endif
} }
//vt.erase(u); //vt.erase(u);
@@ -276,21 +274,19 @@ Graph* Graph::getMaxSpanningTree(){
break; break;
} }
} }
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"wt:v->wt"<<weight<<":"<<v->getWeight()<<"\n";
cerr<<"wt:v->wt"<<weight<<":"<<v->getWeight()<<"\n"; printNode(v);cerr<<"node wt:"<<(*v).weight<<"\n");
printNode(v);cerr<<"node wt:"<<(*v).weight<<"\n";
#endif
//so if v in in vt, change wt(v) to wt(u->v) //so if v in in vt, change wt(v) to wt(u->v)
//only if wt(u->v)<wt(v) //only if wt(u->v)<wt(v)
if(contains && weight<v->getWeight()){ if(contains && weight<v->getWeight()){
parent[v]=u; parent[v]=u;
ed_weight[v]=weight; ed_weight[v]=weight;
v->setWeight(weight); v->setWeight(weight);
#ifdef DEBUG_PATH_PROFILES
cerr<<v->getWeight()<<":Set weight------\n"; DEBUG(cerr<<v->getWeight()<<":Set weight------\n";
printGraph(); printGraph();
printEdge(Edge(u,v,weight)); printEdge(Edge(u,v,weight)));
#endif
} }
} }
} }
@@ -352,10 +348,8 @@ void Graph::makeUnDirectional(){
for(nodeList::iterator NLI=nl.begin(), NLE=nl.end(); NLI!=NLE; ++NLI){ for(nodeList::iterator NLI=nl.begin(), NLE=nl.end(); NLI!=NLE; ++NLI){
Edge ed(NLI->element, *NI, NLI->weight); Edge ed(NLI->element, *NI, NLI->weight);
if(!hasEdgeAndWt(ed)){ if(!hasEdgeAndWt(ed)){
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"######doesn't hv\n";
cerr<<"######doesn't hv\n"; printEdge(ed));
printEdge(ed);
#endif
addEdgeForce(ed); addEdgeForce(ed);
} }
} }

View File

@@ -355,19 +355,17 @@ static void moveDummyCode(const vector<Edge> &stDummy,
map<Edge, getEdgeCode *> &insertions){ map<Edge, getEdgeCode *> &insertions){
typedef vector<Edge >::const_iterator vec_iter; typedef vector<Edge >::const_iterator vec_iter;
#ifdef DEBUG_PATH_PROFILES DEBUG( //print all back, st and ex dummy
//print all back, st and ex dummy cerr<<"BackEdges---------------\n";
cerr<<"BackEdges---------------\n"; for(vec_iter VI=be.begin(); VI!=be.end(); ++VI)
for(vec_iter VI=be.begin(); VI!=be.end(); ++VI) printEdge(*VI);
printEdge(*VI); cerr<<"StEdges---------------\n";
cerr<<"StEdges---------------\n"; for(vec_iter VI=stDummy.begin(); VI!=stDummy.end(); ++VI)
for(vec_iter VI=stDummy.begin(); VI!=stDummy.end(); ++VI) printEdge(*VI);
printEdge(*VI); cerr<<"ExitEdges---------------\n";
cerr<<"ExitEdges---------------\n"; for(vec_iter VI=exDummy.begin(); VI!=exDummy.end(); ++VI)
for(vec_iter VI=exDummy.begin(); VI!=exDummy.end(); ++VI) printEdge(*VI);
printEdge(*VI); cerr<<"------end all edges\n");
cerr<<"------end all edges\n";
#endif
std::vector<Edge> toErase; std::vector<Edge> toErase;
for(map<Edge,getEdgeCode *>::iterator MI=insertions.begin(), for(map<Edge,getEdgeCode *>::iterator MI=insertions.begin(),
@@ -375,17 +373,16 @@ static void moveDummyCode(const vector<Edge> &stDummy,
Edge ed=MI->first; Edge ed=MI->first;
getEdgeCode *edCd=MI->second; getEdgeCode *edCd=MI->second;
bool dummyHasIt=false; bool dummyHasIt=false;
#ifdef DEBUG_PATH_PROFILES
cerr<<"Current edge considered---\n"; DEBUG(cerr<<"Current edge considered---\n";
printEdge(ed); printEdge(ed));
#endif
//now check if stDummy has ed //now check if stDummy has ed
for(vec_iter VI=stDummy.begin(), VE=stDummy.end(); VI!=VE && !dummyHasIt; for(vec_iter VI=stDummy.begin(), VE=stDummy.end(); VI!=VE && !dummyHasIt;
++VI){ ++VI){
if(*VI==ed){ if(*VI==ed){
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"Edge matched with stDummy\n");
cerr<<"Edge matched with stDummy\n";
#endif
dummyHasIt=true; dummyHasIt=true;
bool dummyInBe=false; bool dummyInBe=false;
//dummy edge with code //dummy edge with code
@@ -395,10 +392,9 @@ static void moveDummyCode(const vector<Edge> &stDummy,
Node *dm=ed.getSecond(); Node *dm=ed.getSecond();
if(*dm==*st){ if(*dm==*st){
//so this is the back edge to use //so this is the back edge to use
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"Moving to backedge\n";
cerr<<"Moving to backedge\n"; printEdge(backEdge));
printEdge(backEdge);
#endif
getEdgeCode *ged=new getEdgeCode(); getEdgeCode *ged=new getEdgeCode();
ged->setCdIn(edCd); ged->setCdIn(edCd);
toErase.push_back(ed); toErase.push_back(ed);
@@ -416,9 +412,7 @@ static void moveDummyCode(const vector<Edge> &stDummy,
++VI){ ++VI){
if(*VI==ed){ if(*VI==ed){
inExDummy=true; inExDummy=true;
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"Edge matched with exDummy\n");
cerr<<"Edge matched with exDummy\n";
#endif
bool dummyInBe2=false; bool dummyInBe2=false;
//dummy edge with code //dummy edge with code
for(vec_iter BE=be.begin(), BEE=be.end(); BE!=BEE && !dummyInBe2; for(vec_iter BE=be.begin(), BEE=be.end(); BE!=BEE && !dummyInBe2;
@@ -445,17 +439,13 @@ static void moveDummyCode(const vector<Edge> &stDummy,
} }
} }
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"size of deletions: "<<toErase.size()<<"\n");
cerr<<"size of deletions: "<<toErase.size()<<"\n";
#endif
for(vector<Edge >::iterator vmi=toErase.begin(), vme=toErase.end(); vmi!=vme; for(vector<Edge >::iterator vmi=toErase.begin(), vme=toErase.end(); vmi!=vme;
++vmi) ++vmi)
insertions.erase(*vmi); insertions.erase(*vmi);
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"SIZE OF INSERTIONS AFTER DEL "<<insertions.size()<<"\n");
cerr<<"SIZE OF INSERTIONS AFTER DEL "<<insertions.size()<<"\n";
#endif
} }
//Do graph processing: to determine minimal edge increments, //Do graph processing: to determine minimal edge increments,
@@ -490,9 +480,8 @@ void processGraph(Graph &g,
//step 1-3 are already done on the graph when this function is called //step 1-3 are already done on the graph when this function is called
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g));
printGraph(g);
#endif
//step 4: Get Max spanning tree of graph //step 4: Get Max spanning tree of graph
//now insert exit to root edge //now insert exit to root edge
@@ -510,13 +499,11 @@ void processGraph(Graph &g,
//make g2 undirectional: this gives a better //make g2 undirectional: this gives a better
//maximal spanning tree //maximal spanning tree
g2.makeUnDirectional(); g2.makeUnDirectional();
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g2));
printGraph(g2);
#endif
Graph *t=g2.getMaxSpanningTree(); Graph *t=g2.getMaxSpanningTree();
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(*t));
printGraph(*t);
#endif
//now edges of tree t have weights reversed //now edges of tree t have weights reversed
//(negative) because the algorithm used //(negative) because the algorithm used
//to find max spanning tree is //to find max spanning tree is
@@ -539,11 +526,11 @@ void processGraph(Graph &g,
//the tree so that now, all edge directions in the tree match //the tree so that now, all edge directions in the tree match
//the edge directions of corresponding edges in the directed graph //the edge directions of corresponding edges in the directed graph
removeTreeEdges(g, *t); removeTreeEdges(g, *t);
#ifdef DEBUG_PATH_PROFILES
cerr<<"Spanning tree---------\n"; DEBUG(cerr<<"Spanning tree---------\n";
printGraph(*t); printGraph(*t);
cerr<<"-------end spanning tree\n"; cerr<<"-------end spanning tree\n");
#endif
//now remove the exit->root node //now remove the exit->root node
//and re-add it with weight 0 //and re-add it with weight 0
//since infinite weight is kinda confusing //since infinite weight is kinda confusing
@@ -555,10 +542,9 @@ void processGraph(Graph &g,
t->addEdge(edNew,0); t->addEdge(edNew,0);
} }
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g);
printGraph(g); printGraph(*t));
printGraph(*t);
#endif
//step 5: Get edge increments //step 5: Get edge increments
//Now we select a subset of all edges //Now we select a subset of all edges
@@ -566,14 +552,13 @@ void processGraph(Graph &g,
//if we consider just this subset, it still represents //if we consider just this subset, it still represents
//the path sum along any path in the graph //the path sum along any path in the graph
map<Edge, int> increment=getEdgeIncrements(g,*t); map<Edge, int> increment=getEdgeIncrements(g,*t);
#ifdef DEBUG_PATH_PROFILES
//print edge increments for debugging DEBUG(//print edge increments for debugging
for(map<Edge, int>::iterator M_I=increment.begin(), M_E=increment.end(); for(map<Edge, int>::iterator MI=increment.begin(), ME = increment.end();
M_I!=M_E; ++M_I){ MI != ME; ++MI) {
printEdge(M_I->first); printEdge(MI->first);
cerr<<"Increment for above:"<<M_I->second<<"\n"; cerr << "Increment for above:" << MI->second << "\n";
} });
#endif
//step 6: Get code insertions //step 6: Get code insertions
@@ -587,33 +572,30 @@ void processGraph(Graph &g,
map<Edge, getEdgeCode *> codeInsertions; map<Edge, getEdgeCode *> codeInsertions;
getCodeInsertions(g, codeInsertions, chords,increment); getCodeInsertions(g, codeInsertions, chords,increment);
#ifdef DEBUG_PATH_PROFILES DEBUG (//print edges with code for debugging
//print edges with code for debugging cerr<<"Code inserted in following---------------\n";
cerr<<"Code inserted in following---------------\n"; for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(),
for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions->begin(), cd_e=codeInsertions.end(); cd_i!=cd_e; ++cd_i){
cd_e=codeInsertions->end(); cd_i!=cd_e; ++cd_i){ printEdge(cd_i->first);
printEdge(cd_i->first); cerr<<cd_i->second->getCond()<<":"<<cd_i->second->getInc()<<"\n";
cerr<<cd_i->second->getCond()<<":"<<cd_i->second->getInc()<<"\n"; }
} cerr<<"-----end insertions\n");
cerr<<"-----end insertions\n";
#endif
//step 7: move code on dummy edges over to the back edges //step 7: move code on dummy edges over to the back edges
//Move the incoming dummy edge code and outgoing dummy //Move the incoming dummy edge code and outgoing dummy
//edge code over to the corresponding back edge //edge code over to the corresponding back edge
moveDummyCode(stDummy, exDummy, be, codeInsertions); moveDummyCode(stDummy, exDummy, be, codeInsertions);
#ifdef DEBUG_PATH_PROFILES DEBUG(//debugging info
//debugging info cerr<<"After moving dummy code\n";
cerr<<"After moving dummy code\n"; for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(),
for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(), cd_e=codeInsertions.end(); cd_i != cd_e; ++cd_i){
cd_e=codeInsertions.end(); cd_i != cd_e; ++cd_i){ printEdge(cd_i->first);
printEdge(cd_i->first); cerr<<cd_i->second->getCond()<<":"
cerr<<cd_i->second->getCond()<<":" <<cd_i->second->getInc()<<"\n";
<<cd_i->second->getInc()<<"\n"; }
} cerr<<"Dummy end------------\n");
cerr<<"Dummy end------------\n";
#endif
//see what it looks like... //see what it looks like...
//now insert code along edges which have codes on them //now insert code along edges which have codes on them

View File

@@ -355,19 +355,17 @@ static void moveDummyCode(const vector<Edge> &stDummy,
map<Edge, getEdgeCode *> &insertions){ map<Edge, getEdgeCode *> &insertions){
typedef vector<Edge >::const_iterator vec_iter; typedef vector<Edge >::const_iterator vec_iter;
#ifdef DEBUG_PATH_PROFILES DEBUG( //print all back, st and ex dummy
//print all back, st and ex dummy cerr<<"BackEdges---------------\n";
cerr<<"BackEdges---------------\n"; for(vec_iter VI=be.begin(); VI!=be.end(); ++VI)
for(vec_iter VI=be.begin(); VI!=be.end(); ++VI) printEdge(*VI);
printEdge(*VI); cerr<<"StEdges---------------\n";
cerr<<"StEdges---------------\n"; for(vec_iter VI=stDummy.begin(); VI!=stDummy.end(); ++VI)
for(vec_iter VI=stDummy.begin(); VI!=stDummy.end(); ++VI) printEdge(*VI);
printEdge(*VI); cerr<<"ExitEdges---------------\n";
cerr<<"ExitEdges---------------\n"; for(vec_iter VI=exDummy.begin(); VI!=exDummy.end(); ++VI)
for(vec_iter VI=exDummy.begin(); VI!=exDummy.end(); ++VI) printEdge(*VI);
printEdge(*VI); cerr<<"------end all edges\n");
cerr<<"------end all edges\n";
#endif
std::vector<Edge> toErase; std::vector<Edge> toErase;
for(map<Edge,getEdgeCode *>::iterator MI=insertions.begin(), for(map<Edge,getEdgeCode *>::iterator MI=insertions.begin(),
@@ -375,17 +373,16 @@ static void moveDummyCode(const vector<Edge> &stDummy,
Edge ed=MI->first; Edge ed=MI->first;
getEdgeCode *edCd=MI->second; getEdgeCode *edCd=MI->second;
bool dummyHasIt=false; bool dummyHasIt=false;
#ifdef DEBUG_PATH_PROFILES
cerr<<"Current edge considered---\n"; DEBUG(cerr<<"Current edge considered---\n";
printEdge(ed); printEdge(ed));
#endif
//now check if stDummy has ed //now check if stDummy has ed
for(vec_iter VI=stDummy.begin(), VE=stDummy.end(); VI!=VE && !dummyHasIt; for(vec_iter VI=stDummy.begin(), VE=stDummy.end(); VI!=VE && !dummyHasIt;
++VI){ ++VI){
if(*VI==ed){ if(*VI==ed){
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"Edge matched with stDummy\n");
cerr<<"Edge matched with stDummy\n";
#endif
dummyHasIt=true; dummyHasIt=true;
bool dummyInBe=false; bool dummyInBe=false;
//dummy edge with code //dummy edge with code
@@ -395,10 +392,9 @@ static void moveDummyCode(const vector<Edge> &stDummy,
Node *dm=ed.getSecond(); Node *dm=ed.getSecond();
if(*dm==*st){ if(*dm==*st){
//so this is the back edge to use //so this is the back edge to use
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"Moving to backedge\n";
cerr<<"Moving to backedge\n"; printEdge(backEdge));
printEdge(backEdge);
#endif
getEdgeCode *ged=new getEdgeCode(); getEdgeCode *ged=new getEdgeCode();
ged->setCdIn(edCd); ged->setCdIn(edCd);
toErase.push_back(ed); toErase.push_back(ed);
@@ -416,9 +412,7 @@ static void moveDummyCode(const vector<Edge> &stDummy,
++VI){ ++VI){
if(*VI==ed){ if(*VI==ed){
inExDummy=true; inExDummy=true;
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"Edge matched with exDummy\n");
cerr<<"Edge matched with exDummy\n";
#endif
bool dummyInBe2=false; bool dummyInBe2=false;
//dummy edge with code //dummy edge with code
for(vec_iter BE=be.begin(), BEE=be.end(); BE!=BEE && !dummyInBe2; for(vec_iter BE=be.begin(), BEE=be.end(); BE!=BEE && !dummyInBe2;
@@ -445,17 +439,13 @@ static void moveDummyCode(const vector<Edge> &stDummy,
} }
} }
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"size of deletions: "<<toErase.size()<<"\n");
cerr<<"size of deletions: "<<toErase.size()<<"\n";
#endif
for(vector<Edge >::iterator vmi=toErase.begin(), vme=toErase.end(); vmi!=vme; for(vector<Edge >::iterator vmi=toErase.begin(), vme=toErase.end(); vmi!=vme;
++vmi) ++vmi)
insertions.erase(*vmi); insertions.erase(*vmi);
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr<<"SIZE OF INSERTIONS AFTER DEL "<<insertions.size()<<"\n");
cerr<<"SIZE OF INSERTIONS AFTER DEL "<<insertions.size()<<"\n";
#endif
} }
//Do graph processing: to determine minimal edge increments, //Do graph processing: to determine minimal edge increments,
@@ -490,9 +480,8 @@ void processGraph(Graph &g,
//step 1-3 are already done on the graph when this function is called //step 1-3 are already done on the graph when this function is called
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g));
printGraph(g);
#endif
//step 4: Get Max spanning tree of graph //step 4: Get Max spanning tree of graph
//now insert exit to root edge //now insert exit to root edge
@@ -510,13 +499,11 @@ void processGraph(Graph &g,
//make g2 undirectional: this gives a better //make g2 undirectional: this gives a better
//maximal spanning tree //maximal spanning tree
g2.makeUnDirectional(); g2.makeUnDirectional();
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g2));
printGraph(g2);
#endif
Graph *t=g2.getMaxSpanningTree(); Graph *t=g2.getMaxSpanningTree();
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(*t));
printGraph(*t);
#endif
//now edges of tree t have weights reversed //now edges of tree t have weights reversed
//(negative) because the algorithm used //(negative) because the algorithm used
//to find max spanning tree is //to find max spanning tree is
@@ -539,11 +526,11 @@ void processGraph(Graph &g,
//the tree so that now, all edge directions in the tree match //the tree so that now, all edge directions in the tree match
//the edge directions of corresponding edges in the directed graph //the edge directions of corresponding edges in the directed graph
removeTreeEdges(g, *t); removeTreeEdges(g, *t);
#ifdef DEBUG_PATH_PROFILES
cerr<<"Spanning tree---------\n"; DEBUG(cerr<<"Spanning tree---------\n";
printGraph(*t); printGraph(*t);
cerr<<"-------end spanning tree\n"; cerr<<"-------end spanning tree\n");
#endif
//now remove the exit->root node //now remove the exit->root node
//and re-add it with weight 0 //and re-add it with weight 0
//since infinite weight is kinda confusing //since infinite weight is kinda confusing
@@ -555,10 +542,9 @@ void processGraph(Graph &g,
t->addEdge(edNew,0); t->addEdge(edNew,0);
} }
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g);
printGraph(g); printGraph(*t));
printGraph(*t);
#endif
//step 5: Get edge increments //step 5: Get edge increments
//Now we select a subset of all edges //Now we select a subset of all edges
@@ -566,14 +552,13 @@ void processGraph(Graph &g,
//if we consider just this subset, it still represents //if we consider just this subset, it still represents
//the path sum along any path in the graph //the path sum along any path in the graph
map<Edge, int> increment=getEdgeIncrements(g,*t); map<Edge, int> increment=getEdgeIncrements(g,*t);
#ifdef DEBUG_PATH_PROFILES
//print edge increments for debugging DEBUG(//print edge increments for debugging
for(map<Edge, int>::iterator M_I=increment.begin(), M_E=increment.end(); for(map<Edge, int>::iterator MI=increment.begin(), ME = increment.end();
M_I!=M_E; ++M_I){ MI != ME; ++MI) {
printEdge(M_I->first); printEdge(MI->first);
cerr<<"Increment for above:"<<M_I->second<<"\n"; cerr << "Increment for above:" << MI->second << "\n";
} });
#endif
//step 6: Get code insertions //step 6: Get code insertions
@@ -587,33 +572,30 @@ void processGraph(Graph &g,
map<Edge, getEdgeCode *> codeInsertions; map<Edge, getEdgeCode *> codeInsertions;
getCodeInsertions(g, codeInsertions, chords,increment); getCodeInsertions(g, codeInsertions, chords,increment);
#ifdef DEBUG_PATH_PROFILES DEBUG (//print edges with code for debugging
//print edges with code for debugging cerr<<"Code inserted in following---------------\n";
cerr<<"Code inserted in following---------------\n"; for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(),
for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions->begin(), cd_e=codeInsertions.end(); cd_i!=cd_e; ++cd_i){
cd_e=codeInsertions->end(); cd_i!=cd_e; ++cd_i){ printEdge(cd_i->first);
printEdge(cd_i->first); cerr<<cd_i->second->getCond()<<":"<<cd_i->second->getInc()<<"\n";
cerr<<cd_i->second->getCond()<<":"<<cd_i->second->getInc()<<"\n"; }
} cerr<<"-----end insertions\n");
cerr<<"-----end insertions\n";
#endif
//step 7: move code on dummy edges over to the back edges //step 7: move code on dummy edges over to the back edges
//Move the incoming dummy edge code and outgoing dummy //Move the incoming dummy edge code and outgoing dummy
//edge code over to the corresponding back edge //edge code over to the corresponding back edge
moveDummyCode(stDummy, exDummy, be, codeInsertions); moveDummyCode(stDummy, exDummy, be, codeInsertions);
#ifdef DEBUG_PATH_PROFILES DEBUG(//debugging info
//debugging info cerr<<"After moving dummy code\n";
cerr<<"After moving dummy code\n"; for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(),
for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(), cd_e=codeInsertions.end(); cd_i != cd_e; ++cd_i){
cd_e=codeInsertions.end(); cd_i != cd_e; ++cd_i){ printEdge(cd_i->first);
printEdge(cd_i->first); cerr<<cd_i->second->getCond()<<":"
cerr<<cd_i->second->getCond()<<":" <<cd_i->second->getInc()<<"\n";
<<cd_i->second->getInc()<<"\n"; }
} cerr<<"Dummy end------------\n");
cerr<<"Dummy end------------\n";
#endif
//see what it looks like... //see what it looks like...
//now insert code along edges which have codes on them //now insert code along edges which have codes on them

View File

@@ -102,9 +102,7 @@ bool ProfilePaths::runOnFunction(Function *M){
Graph g(nodes,edges, startNode, exitNode); Graph g(nodes,edges, startNode, exitNode);
#ifdef DEBUG_PATH_PROFILES DEBUG(printGraph(g));
printGraph(g);
#endif
BasicBlock *fr=M->front(); BasicBlock *fr=M->front();
@@ -114,9 +112,8 @@ bool ProfilePaths::runOnFunction(Function *M){
// by removing back edges for now, and adding them later on // by removing back edges for now, and adding them later on
vector<Edge> be; vector<Edge> be;
g.getBackEdges(be); g.getBackEdges(be);
#ifdef DEBUG_PATH_PROFILES DEBUG(cerr << "Backedges:" << be.size() << "\n");
cerr<<"Backedges:"<<be.size()<<endl;
#endif
// Now we need to reflect the effect of back edges // Now we need to reflect the effect of back edges
// This is done by adding dummy edges // This is done by adding dummy edges
// If a->b is a back edge // If a->b is a back edge