@@ -117,15 +117,16 @@ struct PointsToGraph::ReachabilityDFSVisitor : boost::default_dfs_visitor {
117117// points-to graph internal stuff
118118
119119PointsToGraph::VertexProperties::VertexProperties (const llvm::Value *V)
120- : V(V), IR(llvmIRToString(V)) {
121- // WARNING: equivalent to llvmIRToString
122- // WARNING 2 : really really really slow (yes it is)
120+ : V(V) {}
121+
122+ std::string PointsToGraph::VertexProperties::getValueAsString () const {
123+ return llvmIRToString (V);
123124}
124125
125- PointsToGraph::EdgeProperties::EdgeProperties (const llvm::Value *V)
126- : V(V), IR(llvmIRToString(V)) {
127- // WARNING: equivalent to llvmIRToString
128- // WARNING 2 : really really really slow (yes it is)
126+ PointsToGraph::EdgeProperties::EdgeProperties (const llvm::Value *V) : V(V) {}
127+
128+ std::string PointsToGraph::EdgeProperties::getValueAsString () const {
129+ return llvmIRToString (V);
129130}
130131
131132// points-to graph stuff
@@ -235,7 +236,7 @@ PointsToGraph::PointsToGraph(llvm::Function *F, llvm::AAResults &AA) {
235236vector<pair<unsigned , const llvm::Value *>>
236237PointsToGraph::getPointersEscapingThroughParams () {
237238 vector<pair<unsigned , const llvm::Value *>> escaping_pointers;
238- for (pair<vertex_iterator_t , vertex_iterator_t > vp = boost::vertices (PAG);
239+ for (pair<vertex_iterator, vertex_iterator > vp = boost::vertices (PAG);
239240 vp.first != vp.second ; ++vp.first ) {
240241 if (const llvm::Argument *arg =
241242 llvm::dyn_cast<llvm::Argument>(PAG[*vp.first ].V )) {
@@ -248,7 +249,7 @@ PointsToGraph::getPointersEscapingThroughParams() {
248249vector<const llvm::Value *>
249250PointsToGraph::getPointersEscapingThroughReturns () const {
250251 vector<const llvm::Value *> escaping_pointers;
251- for (pair<vertex_iterator_t , vertex_iterator_t > vp = boost::vertices (PAG);
252+ for (pair<vertex_iterator, vertex_iterator > vp = boost::vertices (PAG);
252253 vp.first != vp.second ; ++vp.first ) {
253254 for (auto user : PAG[*vp.first ].V ->users ()) {
254255 if (llvm::isa<llvm::ReturnInst>(user)) {
@@ -263,7 +264,7 @@ vector<const llvm::Value *>
263264PointsToGraph::getPointersEscapingThroughReturnsForFunction (
264265 const llvm::Function *F) const {
265266 vector<const llvm::Value *> escaping_pointers;
266- for (pair<vertex_iterator_t , vertex_iterator_t > vp = boost::vertices (PAG);
267+ for (pair<vertex_iterator, vertex_iterator > vp = boost::vertices (PAG);
267268 vp.first != vp.second ; ++vp.first ) {
268269 for (auto user : PAG[*vp.first ].V ->users ()) {
269270 if (auto R = llvm::dyn_cast<llvm::ReturnInst>(user)) {
@@ -289,7 +290,7 @@ set<const llvm::Value *> PointsToGraph::getReachableAllocationSites(
289290}
290291
291292bool PointsToGraph::containsValue (llvm::Value *V) {
292- pair<vertex_iterator_t , vertex_iterator_t > vp;
293+ pair<vertex_iterator, vertex_iterator > vp;
293294 for (vp = boost::vertices (PAG); vp.first != vp.second ; ++vp.first )
294295 if (PAG[*vp.first ].V == V)
295296 return true ;
@@ -353,33 +354,37 @@ bool PointsToGraph::representsSingleFunction() {
353354void PointsToGraph::print (std::ostream &OS) const {
354355 for (const auto &Fn : ContainedFunctions) {
355356 cout << " PointsToGraph for " << Fn << " :\n " ;
356- boost::print_graph (
357- PAG, boost::get (&PointsToGraph::VertexProperties::IR, PAG), OS);
357+ vertex_iterator ui, ui_end;
358+ for (boost::tie (ui, ui_end) = boost::vertices (PAG); ui != ui_end; ++ui) {
359+ OS << PAG[*ui].getValueAsString () << " <--> " ;
360+ out_edge_iterator ei, ei_end;
361+ for (boost::tie (ei, ei_end) = boost::out_edges (*ui, PAG); ei != ei_end;
362+ ++ei) {
363+ OS << PAG[target (*ei, PAG)].getValueAsString () << " " ;
364+ }
365+ OS << ' \n ' ;
366+ }
358367 }
359368}
360369
361- void PointsToGraph::printAsDot (const string &filename) {
362- ofstream ofs (filename);
363- boost::write_graphviz (ofs, PAG,
364- boost::make_label_writer (boost::get (
365- &PointsToGraph::VertexProperties::IR, PAG)),
366- boost::make_label_writer (boost::get (
367- &PointsToGraph::EdgeProperties::IR, PAG)));
370+ void PointsToGraph::printAsDot (std::ostream &OS) const {
371+ boost::write_graphviz (OS, PAG, makePointerVertexOrEdgePrinter (PAG),
372+ makePointerVertexOrEdgePrinter (PAG));
368373}
369374
370375nlohmann::json PointsToGraph::getAsJson () {
371376 nlohmann::json J;
372- vertex_iterator_t vi_v, vi_v_end;
373- out_edge_iterator_t ei, ei_end;
377+ vertex_iterator vi_v, vi_v_end;
378+ out_edge_iterator ei, ei_end;
374379 // iterate all graph vertices
375380 for (boost::tie (vi_v, vi_v_end) = boost::vertices (PAG); vi_v != vi_v_end;
376381 ++vi_v) {
377- J[PhasarConfig::JsonPointToGraphID ()][llvmIRToString ( PAG[*vi_v].V )];
382+ J[PhasarConfig::JsonPointToGraphID ()][PAG[*vi_v].getValueAsString ( )];
378383 // iterate all out edges of vertex vi_v
379384 for (boost::tie (ei, ei_end) = boost::out_edges (*vi_v, PAG); ei != ei_end;
380385 ++ei) {
381- J[PhasarConfig::JsonPointToGraphID ()][llvmIRToString ( PAG[*vi_v].V )] +=
382- llvmIRToString ( PAG[boost::target (*ei, PAG)].V );
386+ J[PhasarConfig::JsonPointToGraphID ()][PAG[*vi_v].getValueAsString ( )] +=
387+ PAG[boost::target (*ei, PAG)].getValueAsString ( );
383388 }
384389 }
385390 return J;
@@ -398,7 +403,7 @@ void PointsToGraph::mergeWith(const PointsToGraph *Other,
398403 copy_graph<PointsToGraph::graph_t , PointsToGraph::vertex_t >(PAG,
399404 Other->PAG );
400405 ValueVertexMap.clear ();
401- vertex_iterator_t vi, vi_end;
406+ vertex_iterator vi, vi_end;
402407 for (boost::tie (vi, vi_end) = boost::vertices (PAG); vi != vi_end; ++vi) {
403408 ValueVertexMap.insert (make_pair (PAG[*vi].V , *vi));
404409 }
@@ -447,7 +452,7 @@ void PointsToGraph::mergeWith(
447452 PointsToGraph::EdgeProperties, const llvm::Instruction *>(
448453 PAG, Other.PAG , v_in_g1_u_in_g2);
449454 ValueVertexMap.clear ();
450- vertex_iterator_t vi, vi_end;
455+ vertex_iterator vi, vi_end;
451456 for (boost::tie (vi, vi_end) = boost::vertices (PAG); vi != vi_end; ++vi) {
452457 ValueVertexMap.insert (make_pair (PAG[*vi].V , *vi));
453458 }
@@ -478,10 +483,9 @@ void PointsToGraph::mergeWith(PointsToGraph *Other, llvm::ImmutableCallSite CS,
478483 }
479484 } else {
480485 ContainedFunctions.insert (F->getName ().str ());
481- // TODO this function has to check if F's points-to graph is already merged
482- // into the 'this' points-to graph. If so, is is not allowed to copy it a
483- // second
484- // time into 'this' PAG.
486+ // TODO this function has to check if F's points-to graph is already
487+ // merged into the 'this' points-to graph. If so, is is not allowed to
488+ // copy it a second time into 'this' PAG.
485489 vector<pair<PointsToGraph::vertex_t , PointsToGraph::vertex_t >>
486490 v_in_g1_u_in_g2;
487491 for (unsigned i = 0 ; i < CS.getNumArgOperands (); ++i) {
@@ -509,8 +513,8 @@ void PointsToGraph::mergeWith(PointsToGraph *Other, llvm::ImmutableCallSite CS,
509513 typename std::vector<PointsToGraph::vertex_t >::iterator, index_map_t ,
510514 PointsToGraph::vertex_t , PointsToGraph::vertex_t &>
511515 IsoMap;
512- // for more generic graphs, one can try typedef std::map<vertex_t, vertex_t>
513- // IsoMap;
516+ // for more generic graphs, one can try typedef std::map<vertex_t,
517+ // vertex_t> IsoMap;
514518 vector<PointsToGraph::vertex_t > orig2copy_data (
515519 boost::num_vertices (Other->PAG ));
516520 IsoMap mapV = boost::make_iterator_property_map (
@@ -523,7 +527,7 @@ void PointsToGraph::mergeWith(PointsToGraph *Other, llvm::ImmutableCallSite CS,
523527 }
524528 }
525529 ValueVertexMap.clear ();
526- vertex_iterator_t vi, vi_end;
530+ vertex_iterator vi, vi_end;
527531 for (boost::tie (vi, vi_end) = boost::vertices (PAG); vi != vi_end; ++vi) {
528532 ValueVertexMap.insert (make_pair (PAG[*vi].V , *vi));
529533 }
0 commit comments