Exemple #1
0
OrderedCallGraph::OrderedCallGraph(CallGraph *CG) {
  auto const &Funcs = CG->getBottomUpFunctionOrder();
  Nodes.resize(Funcs.size());
  llvm::DenseMap<CallGraphNode *, Node *> NodeMap;
  int idx = 0;
  for (auto *F : Funcs) {
    auto *CGNode = CG->getCallGraphNode(F);
    Node &ONode = Nodes[idx++];
    ONode.CGNode = CGNode;
    ONode.OCG = this;
    NodeMap[CGNode] = &ONode;

    F->numberValues(InstToIDMap);
  }

  for (Node &ONode : Nodes) {
    llvm::SmallVector<CallGraphEdge *, 8> OrderedEdges;
    orderEdges(ONode.CGNode->getCalleeEdges(), OrderedEdges);

    ONode.NumCallSites = OrderedEdges.size();
    for (auto *CGEdge : OrderedEdges) {
      for (auto *CalleeNode : CGEdge->getCalleeSet()) {
        auto *OrderedChild = NodeMap[CalleeNode];
        assert(OrderedChild);
        ONode.Children.push_back(Edge(CGEdge, OrderedChild));
      }
    }
  }
}
Exemple #2
0
GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound)
  : GEdge(m, tag, 0 , 0), _compound(compound)
{
  if(!looksOk(tag, compound)) return;

  orderEdges();
  int N = _compound.size();
  if(N == (int)_orientation.size()){
    v0 = _orientation[0] ? _compound[0]->getBeginVertex() : _compound[0]->getEndVertex();
    v1 = _orientation[N-1] ? _compound[N-1]->getEndVertex() : _compound[N-1]->getBeginVertex();
    v0->addEdge(this);
    v1->addEdge(this);
  }
  else{
    Msg::Error("Wrong input data for compound edge %d", tag);
    return;
  }

  for (unsigned int i = 0; i < _compound.size(); i++)
    _compound[i]->setCompound(this);
  parametrize();
}