예제 #1
0
int CFAnalyzer::reduceBlockBeginNodes(Flow& flow) {
  LabelSet labs=flow.nodeLabels();
  int cnt=0;
  for(LabelSet::iterator i=labs.begin();i!=labs.end();++i) {
	if(isSgBasicBlock(getNode(*i))) {
	  cnt++;
	  Flow inFlow=flow.inEdges(*i);
	  Flow outFlow=flow.outEdges(*i);

	  // multiple out-edges not supported yet
	  assert(outFlow.size()<=1); 

	  /* description of essential operations:
	   *   inedges: (n_i,b)
	   *   outedge: (b,n2) 
	   *   remove(n_i,b)
	   *   remove(b,n2)
	   *   insert(n1,n2)
	   */
	  for(Flow::iterator initer=inFlow.begin();initer!=inFlow.end();++initer) {
		Edge e1=*initer;
		Edge e2=*outFlow.begin();
		Edge newEdge=Edge(e1.source,e1.types(),e2.target);
		flow.erase(e1);
		flow.erase(e2);
		flow.insert(newEdge);
	  }
	}
  }
  return cnt;
}
예제 #2
0
int CFAnalysis::reduceBlockEndNodes(Flow& flow) {
  LabelSet labs=flow.nodeLabels();
  int cnt=0;
  for(LabelSet::iterator i=labs.begin();i!=labs.end();++i) {
    if(labeler->isBlockEndLabel(*i)) {
      cnt+=reduceNode(flow,*i);
    }
  }
  return cnt;
}
예제 #3
0
LabelSet CFAnalysis::functionEntryLabels(Flow& flow) {
  LabelSet resultSet;
  LabelSet nodeLabels;
  nodeLabels=flow.nodeLabels();
  for(LabelSet::iterator i=nodeLabels.begin();i!=nodeLabels.end();++i) {
    if(labeler->isFunctionEntryLabel(*i))
      resultSet.insert(*i);
  }
  return resultSet;
}
예제 #4
0
int CFAnalysis::reduceBlockBeginNodes(Flow& flow) {
  LabelSet labs=flow.nodeLabels();
  int cnt=0;
  for(LabelSet::iterator i=labs.begin();i!=labs.end();++i) {
    //cout<<"Checking label: "<<(*i)<<" node: "<<getNode(*i)<<" code:"<<getNode(*i)->unparseToString()<<endl;
    if(isSgBasicBlock(getNode(*i))) {
#if 1
      cnt+=reduceNode(flow,*i);
#else
      cnt++;
      Flow inFlow=flow.inEdges(*i);
      Flow outFlow=flow.outEdges(*i);

      // multiple out-edges not supported yet
      assert(outFlow.size()<=1); 

      /* description of essential operations:
       *   inedges: (n_i,b)
       *   outedge: (b,n2) 
       *   remove(n_i,b)
       *   remove(b,n2)
       *   insert(n1,n2)
       */
      for(Flow::iterator initer=inFlow.begin();initer!=inFlow.end();++initer) {
        Edge e1=*initer;
        Edge e2=*outFlow.begin();
        Edge newEdge=Edge(e1.source,e1.types(),e2.target);
        flow.erase(e1);
        flow.erase(e2);
        flow.insert(newEdge);
      }
#endif
    }
  }
  return cnt;
}