1 #ifndef _DEPENDENCEGRAPH_H_
2 #define _DEPENDENCEGRAPH_H_
7 #include <AstInterface.h>
8 #include <StmtInfoCollect.h>
24 #include "filteredCFG.h"
25 #include "DominatorTree.h"
26 #include "DominanceFrontier.h"
54 using namespace VirtualCFG;
55 using namespace::DominatorTreesAndDominanceFrontiers;
199 if (depType== ACTUALOUT
200 ||depType== FORMALOUT
202 ||depType== ENTRY)
return true;
209 static const char *typeNames[NUM_NODE_TYPES];
234 sgNode(node),
name(depName),highlight(false)
241 name(depName), highlight(false)
350 os <<
"CONTROL\\n";
break;
352 os <<
"CALLSITE\\n";
break;
354 os <<
"ACTUALIN\\n";
break;
356 os<<
"ACTUALOUT\\n";
break;
358 os<<
"FORMALIN\\n";
break;
360 os<<
"FORMALOUT\\n";
break;
362 os<<
"FORMALRETURN\\n";
break;
364 os<<
"ACTUALRETURN\\n";
break;
366 os<<
"ENTRY\\n";
break;
368 os<<
"NULL!!!!";
break;
370 if (sgNode != NULL) {
371 #ifdef DOT_OUT_VERBOSE
375 os << sgNode->class_name() <<
"\\n";
397 os <<
"[" <<
escapeString(sgNode->unparseToString()) <<
"]";
478 struct CallSiteStructure
481 SgNode* sliceImportantNode;
483 SgNode* sgFunctionCallExpNode;
487 std::vector<SgExpression*> actual_in;
498 SgNode * getActualReturn(
int id)
500 return callSites[id].actual_return;
502 SgNode * getActualIn(
int id,
int varNr)
504 return callSites[id].actual_in[varNr];
506 int getActualInCount(
int id)
508 return callSites[id].actual_in.size();
512 callSites[id].actual_in.push_back(node);
514 void setSliceImportantNode(
int id,
SgNode * node)
516 callSites[id].sliceImportantNode=node;
518 void setActualReturn(
int id,
SgNode * node)
520 callSites[id].actual_return=node;
524 SgNode * getSliceImportantFunctionCallNode(
int i)
526 return callSites[i].sliceImportantNode;
528 std::set<SgNode *> getExitNodes()
538 return callSites.size();
540 SgNode * getFunctionCallExpNode(
int i)
542 return callSites[i].sgFunctionCallExpNode;
544 SgNode * getFunctionEntry()
558 std::map < SgInitializedName *, DependenceNode * >formal_out;
560 Rose_STL_Container < SgInitializedName * >arg_order;
563 std::vector<SgNode*> formal_in;
566 std::set<SgNode *> exitNodes;
570 std::vector<CallSiteStructure> callSites;
572 std::map<SgNode *, int> callSitesMap;
576 int getFormalInCount()
578 return formal_in.size();
580 SgNode * getFormalIn(
int nr)
582 if (formal_in.size()>nr && nr>=0)
583 return formal_in[nr];
587 SgNode * getFormalReturn()
589 return formal_return;
592 void addExitNode(
SgNode * node)
594 exitNodes.insert(node);
599 std::cout <<
"creating interprocedural info\n";
600 decl=functionDeclaration;
602 if (def==NULL) entry=decl;
605 formal_return=functionDeclaration;
607 Rose_STL_Container<SgInitializedName*> argList=functionDeclaration->
get_args();
608 for (Rose_STL_Container<SgInitializedName*>::iterator i=argList.begin();i!=argList.end();i++)
610 std::cout <<
"\tadding formal in "<<*i<<
"\n";
611 formal_in.push_back(*i);
627 int addFunctionCall(
SgNode * functionCall)
629 CallSiteStructure cs;
630 cs.sliceImportantNode=NULL;
631 cs.sgFunctionCallExpNode=functionCall;
632 cs.callSiteDepNode=NULL;
633 cs.actual_return=NULL;
634 callSites.push_back(cs);
635 callSitesMap[functionCall]=callSites.size()-1;
636 return callSites.size()-1;
681 std::set<SimpleDirectedGraphNode *>::iterator i;
682 for (i=_nodes.begin();i!=_nodes.end();i++)
684 std::cout<<
"\t\t"<<(*i)<<
"\n";
708 CONTROL_HELPER = 0xa,
709 GLOBALVAR_HELPER= 0xb,
710 COMPLETENESS_HELPER=0xc,
717 DO_NOT_FOLLOW = 0x10,
721 static const char *edgeNameArray[8];
722 const char *getEdgeName(
EdgeType type);
845 virtual void writeDot(
char *filename);
858 typedef std::pair < DependenceNode *, DependenceNode * >
Edge;
868 std::map < Edge, std::set < EdgeType > >
edgeMap;
870 std::map < Edge, std::set < int > >edgeMap;
875 if (sgFD == NULL)
return false;
948 void computeAdditionalFunctioncallDepencencies();
952 void processDependence(
int aID,
int bID);
953 void createSyntacticDependencies();
959 void addDependence(
int source,
int to,
EdgeType edge=CONTROL);
975 void _buildInterprocedural();
1061 void _processReturns();
1124 std::set < SgNode * >slice(
SgNode * node);
1146 std::set < DependenceNode * >_getReachable(std::set < DependenceNode * >start,
1147 int edgeTypesToFollow = 0);
1256 libraryExtenders.push_back(le);
1259 SgNode *getMainFunction();
1266 void performInterproceduralAnalysis();
1267 void computeSummaryEdges();
1268 void cleanUp(std::set<SgNode*> preserve);
1283 if (interproceduralInformation.count(dec )>0)
1285 return (interproceduralInformation[dec]);
1294 std::cerr<<
"Warning: Interprocedural Information for this function already available"<<std::endl;
1298 interproceduralInformationList.push_back(info);
1329 std::set < FunctionDependenceGraph * >getPDGs();
1355 std::vector<InterproceduralInfo*> getPossibleFuncs(
SgFunctionCallExp * funcCall);
1356 Rose_STL_Container < SgFunctionDeclaration * >_getPossibleFuncs(
SgFunctionCallExp * funcCall);
1362 std::map < SgFunctionDeclaration *, FunctionDependenceGraph * >
_funcs_map;