Ejemplo n.º 1
0
void
RtedTransformation::insertVariableCreateInitForParams( SgFunctionDefinition& fndef)
{
    SgBasicBlock* body = fndef.get_body();
    ROSE_ASSERT( body);

    SgInitializedNamePtrList names = fndef.get_declaration()->get_parameterList()->get_args();

    BOOST_FOREACH( SgInitializedName* param, names)
    {
      SgType* initType = param->get_type();

      // nov2010 code:
      // reference variables don't allocate new memory
      // if we call createVariable the RTS will think it's a double
      // allocation fault

      // \pp we skip array types because they will be handled elsewhere
      // \todo not sure if this is correct here, b/c arrays would decay
      //       to pointers anyway. However, this decay is not represented
      //       in the nov2010 code, thus we skip these initializations
      //       here.
      if ( isSgReferenceType(initType) || isSgArrayType(skip_ModifierType(initType)) )
        continue;

      SgFunctionDeclaration* fndecl = fndef.get_declaration();
      std::cerr << ">>> " << fndecl->get_name() << std::endl;
      ROSE_ASSERT(isSgFunctionDefinition(param->get_scope()));

      body->prepend_statement( buildVariableCreateCallStmt(param, true) );
    }
Ejemplo n.º 2
0
int main( int argc, char * argv[] ) 
{
        // Build the AST used by ROSE
        SgProject* project = frontend(argc,argv);
        
        generatePDF ( *project );
        
        Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
        for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) {
                SgFunctionDefinition* curFunc = isSgFunctionDefinition(*i);
                ROSE_ASSERT(curFunc);
                                
                SgBasicBlock *funcBody = curFunc->get_body();
                InterestingNode funcCFGStart = (InterestingNode)funcBody->cfgForBeginning();;
                        
                // output the CFG to a file
                ofstream fileCFG;
                fileCFG.open((curFunc->get_declaration()->get_name().getString()+"_cfg.dot").c_str());
                cout << "writing to file "<<(curFunc->get_declaration()->get_name().getString()+"_cfg.dot")<<"\n";
                VirtualCFG::cfgToDot(fileCFG, curFunc->get_declaration()->get_name(), funcCFGStart);
                fileCFG.close();
        }
        
        // Unparse and compile the project (so this can be used for testing)
        return backend(project);
}
Ejemplo n.º 3
0
// Create one parameter for an outlined function
// return the created parameter
SgInitializedName* createOneFunctionParameter(const SgInitializedName* i_name, 
					      bool readOnly, 
					      SgFunctionDeclaration* func)
			
{
  ROSE_ASSERT (i_name);
  ROSE_ASSERT (func);
  SgFunctionParameterList* params = func->get_parameterList ();
  ROSE_ASSERT (params);
  SgFunctionDefinition* def = func->get_definition ();
  ROSE_ASSERT (def);

  // It handles language-specific details internally, like pass-by-value, pass-by-reference
  // name and type is not enough, need the SgInitializedName also for tell 
  // if an array comes from a parameter list
  OutlinedFuncParam_t param = createParam (i_name,readOnly);
 
  SgName p_sg_name (param.first.c_str ());
  // name, type, declaration, scope, 
  // TODO function definition's declaration should not be passed to createInitName()
  SgInitializedName* p_init_name = createInitName (param.first, param.second, def->get_declaration(), def);

  ROSE_ASSERT (p_init_name);
  prependArg(params,p_init_name);
  return p_init_name;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[]) 
{
  // Build the AST used by ROSE
  SgProject* sageProject = frontend(argc,argv);

  // Process all function definition bodies for static control flow graph generation
  Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(sageProject, V_SgFunctionDefinition);
  for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) 
  {
    SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
    ROSE_ASSERT (proc != NULL); 
    string fileName= StringUtility::stripPathFromFileName(proc->get_file_info()->get_filenameString());
    string dotFileName1=fileName+"."+ proc->get_declaration()->get_name() +".debug.dot";
    string dotFileName2=fileName+"."+ proc->get_declaration()->get_name() +".interesting.dot";

    StaticCFG::CFG cfg(proc);

    // Dump out the full CFG, including bookkeeping nodes
    cfg.buildFullCFG();
    cfg.cfgToDot(proc, dotFileName1);

    // Dump out only those nodes which are "interesting" for analyses
    cfg.buildFilteredCFG();
    cfg.cfgToDot(proc, dotFileName2);
  }

  return 0;
}
int main(int argc, char *argv[]) {
  
  struct timeval t1, t2;
  SgProject* proj = frontend(argc,argv);
  ROSE_ASSERT (proj != NULL); 

  SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);

  SgFunctionDefinition* mainDef = mainDefDecl->get_definition(); 
   visitorTraversal* vis = new visitorTraversal();
    StaticCFG::CFG cfg(mainDef);
   //cfg.buildFullCFG();
    stringstream ss;
    string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
    string dotFileName1=fileName+"."+ mainDef->get_declaration()->get_name() +".dot";

    cfgToDot(mainDef,dotFileName1); 
    //cfg->buildFullCFG();
    SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();
    g = cfg.getGraph();
    myGraph* mg = new myGraph();
    mg = instantiateGraph(g, cfg);
    vis->tltnodes = 0;
    vis->paths = 0;
    //vis->firstPrepGraph(constcfg);
    t1 = getCPUTime();
    vis->constructPathAnalyzer(mg, true, 0, 0, true);
    t2 = getCPUTime();
    std::cout << "took: " << timeDifference(t2, t1) << std::endl;
    //cfg.clearNodesAndEdges();
    std::cout << "finished" << std::endl;
    std::cout << "tltnodes: " << vis->tltnodes << " paths: " << vis->paths << std::endl;
    delete vis;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[]) 
{
  SgProject* sageProject = frontend(argc,argv);
  AstTests::runAllTests(sageProject);

  Rose_STL_Container <SgNode*> functions = NodeQuery::querySubTree(sageProject, V_SgFunctionDefinition);

  for (Rose_STL_Container <SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) 
  {
    SgFunctionDefinition* proc = isSgFunctionDefinition(*i);
    ROSE_ASSERT (proc);
    string file_name = StringUtility::stripPathFromFileName(proc->get_file_info()->get_filename());
    string file_func_name= file_name+ "_"+proc->get_mangled_name().getString();
    
    string full_output = file_func_name +"_scfg.dot";
    // Full CFG graph
    StaticCFG::CFG cfg(proc);
    cfg.buildFullCFG();
    cfg.cfgToDot(proc, full_output);


#if 0 // not ready
    string simple_output = file_func_name +"_simple_vcfg.dot";
    std::ofstream simplegraph(simple_output.c_str());
    // Simplified CFG suitable for most analyses
    // This will cause assertion failure
    //StaticCFG::cfgToDot(simplegraph, proc->get_declaration()->get_name(), StaticCFG::makeInterestingCfg(proc)); 
    // This will generate identical graph as cfgToDotForDebugging ()
    StaticCFG::cfgToDot(simplegraph, proc->get_declaration()->get_name(), proc->cfgForBeginning());
#endif    
  }
  return 0;
}
Ejemplo n.º 7
0
void runCurrentFile(vector<string> &argvList, bool debug, bool debug_map) {
  // Build the AST used by ROSE

  if (debug)
    std::cout << ">>>> Starting ROSE frontend ... " << endl;
  SgProject* project = frontend(argvList);
  if (debug)
    std::cout << ">>>> generate PDF " << endl;
  generatePDF ( *project );
  if (debug)
    std::cout << ">>>> start def-use analysis ... " << endl;

  // Call the Def-Use Analysis
  DFAnalysis* defuse = new DefUseAnalysis(project);
  int val = defuse->run(debug);
  if (debug)
    std::cout << "Analysis is : " << (val ?  "failure" : "success" ) << " " << val <<std::endl;
  if (val==1) exit(1);
  if (debug==false)
    defuse->dfaToDOT();

  LivenessAnalysis* liv = new LivenessAnalysis(true,(DefUseAnalysis*)defuse);

  //example usage
  // testing
  std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions;
  bool abortme=false;
  NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
  NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
  for (; i!=vars.end();++i) {
    SgFunctionDefinition* func = isSgFunctionDefinition(*i);
    string funcName = func->get_declaration()->get_qualified_name().str();
    if (debug)
      cerr << " running live analysis for func : " << funcName << endl;
    FilteredCFGNode <IsDFAFilter> rem_source = liv->run(func,abortme);
    if (rem_source.getNode()!=NULL)
      dfaFunctions.push_back(rem_source);
    if (abortme)
      break;
  }


  std::ofstream f2("var.dot");
  dfaToDot(f2, string("var"), dfaFunctions,
           (DefUseAnalysis*)defuse, liv);
  f2.close();
  if (abortme) {
    cerr<<"ABORTING ." << endl;
    exit(1);
  }


  delete project;
  delete defuse;
}
Ejemplo n.º 8
0
void PreAndPostOrderTraversal::preOrderVisit(SgNode* n) {

        SgFunctionDeclaration * dec = isSgFunctionDeclaration(n);
        if (dec != NULL) {
                cout << "Found function declaration " << dec->get_name().getString();
                Sg_File_Info * start = dec->get_startOfConstruct();
                Sg_File_Info * end = dec->get_endOfConstruct();
                if(start->isCompilerGenerated()) {
                        cout << ", which is compiler-generated" << endl;
                } else {
                        cout << " in file " << start->get_raw_filename() << ", " << start->get_file_id() << " from line " << 
                            start->get_line() << ", col " << start->get_col() << " to line " << 
                            end->get_line() << ", col " << end->get_col() << endl;
                }
                SgFunctionType * type = dec->get_type();
                SgType * retType = type->get_return_type();
        cout << "Return type: " << retType->unparseToString() << endl;
        SgFunctionParameterList * params = dec->get_parameterList();
        SgInitializedNamePtrList & ptrList = params->get_args();
        if(!ptrList.empty()) {
            cout << "Parameter types: ";
            for(SgInitializedNamePtrList::iterator j = ptrList.begin(); j != ptrList.end(); j++) {
                SgType * pType = (*j)->get_type();
                cout << pType->unparseToString() << " ";
            }
            cout << endl;
        }
        cout << "Linkage: " << dec->get_linkage() << endl;
               cout << endl;
        }


        SgFunctionDefinition * def = isSgFunctionDefinition(n);
        if (def != NULL) {
                cout << "Found function definition " << def->get_declaration()->get_name().getString();
                Sg_File_Info * start = def->get_startOfConstruct();
                Sg_File_Info * end = def->get_endOfConstruct();
                if(start->isCompilerGenerated()) {
                        cout << ", which is compiler-generated" << endl;
                } else {
                        cout << " in file " << start->get_raw_filename() << " from line " << start->get_line() << ", col " << start->get_col() << " to line " << end->get_line() << ", col " << end->get_col() << endl;
                SgBasicBlock * body = def->get_body();
        Sg_File_Info * bodyStart = body->get_startOfConstruct();
        Sg_File_Info * bodyEnd =   body->get_endOfConstruct();
        cout << "Function body from line " << bodyStart->get_line() << ", col " << bodyStart->get_col() << " to line " << bodyEnd->get_line() << ", col " << bodyEnd->get_col() << endl; 
 }
        cout << endl;
        }
}
Ejemplo n.º 9
0
void findCandidateFunctionDefinitions (SgProject* project, std::vector<SgFunctionDefinition* >& candidateFuncDefs)
{
  ROSE_ASSERT (project != NULL);
  // For each source file in the project
  SgFilePtrList & ptr_list = project->get_fileList();
  for (SgFilePtrList::iterator iter = ptr_list.begin(); iter!=ptr_list.end();
      iter++)
  {
    SgFile* sageFile = (*iter);
    SgSourceFile * sfile = isSgSourceFile(sageFile);
    ROSE_ASSERT(sfile);
//    SgGlobal *root = sfile->get_globalScope();

    if (enable_debug)
      cout<<"Processing each function within the files "<< sfile->get_file_info()->get_filename() <<endl;
    //      cout<<"\t loop at:"<< cur_loop->get_file_info()->get_line() <<endl;

    // This is wrong, many functions in question are not top level declarations!!
    //SgDeclarationStatementPtrList& declList = root->get_declarations ();
    //VariantVector vv;
    Rose_STL_Container<SgNode*> defList = NodeQuery::querySubTree(sfile, V_SgFunctionDefinition); 
//    bool hasOpenMP= false; // flag to indicate if omp.h is needed in this file

    //For each function body in the scope
    //for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) 
    for (Rose_STL_Container<SgNode*>::iterator p = defList.begin(); p != defList.end(); ++p) 
    {
      SgFunctionDefinition *defn = isSgFunctionDefinition(*p);
      ROSE_ASSERT (defn != NULL);

      SgFunctionDeclaration *func = defn->get_declaration();
      ROSE_ASSERT (func != NULL);

      if (enable_debug)
        cout<<"\t considering function "<< func->get_name() << " at "<< func->get_file_info()->get_line()<<endl;
      //ignore functions in system headers, Can keep them to test robustness
      if (defn->get_file_info()->get_filename()!=sageFile->get_file_info()->get_filename())
      {
        if (enable_debug)
          cout<<"\t Skipped since the function's associated file name does not match current file being considered. Mostly from a header. "<<endl;
        continue;
      }
      candidateFuncDefs.push_back(defn);
    } // end for def list
  } // end for file list
}
Ejemplo n.º 10
0
ScopExtractor::ScopExtractor(SgProject* project, PolyRoseOptions& polyopts)
{
  //   this->project = project;
  this->polyoptions = polyopts;
  isVerbose = ! polyopts.getQuiet();
  if (isVerbose)
    std::cout << "[PolyOpt] Using generic scop extractor" << std::endl;

  SgFilePtrList& file_list = project->get_fileList();
  SgFilePtrList::const_iterator file_iter;
  // Iterate on all files of the project.
  for (file_iter = file_list.begin(); file_iter != file_list.end(); file_iter++)
    {
      SgSourceFile* file = isSgSourceFile(*file_iter);
      if (polyoptions.getScVerboseLevel())
	cout << "[Extr] File: " << file->getFileName() << endl;
      SgNodePtrList funcDefnList =
	NodeQuery::querySubTree(file, V_SgFunctionDefinition);
      SgNodePtrList::const_iterator iter;
      // Iterate on all function defined in a file.
      for (iter = funcDefnList.begin(); iter != funcDefnList.end(); ++iter)
	{
	  SgFunctionDefinition *fun = isSgFunctionDefinition(*iter);
	  if (!fun)
	    {
	      cout << "[Extr] Warning: Expected SgFunctionDefinition in " <<
		file->getFileName() << endl;
	      continue; // with the next function definition
	    }
	  SgName name = fun->get_declaration()->get_name();
	  if (polyoptions.getScVerboseLevel())
	    cout << "[Extr] Function: " << name.getString() << endl;
	  SgBasicBlock* body = fun->get_body();

	  // Ensure the function is a candidate (no (unsafe) function
	  // calls).
	  if (assertFunctionIsCandidate(project, body))
	    {
	      // Proceed recursively, bottom up.
	      inspectBottomUpFunctionBody(project, body);
	    }
	}
    }
  if (isVerbose)
    std::cout << "[ScopExtraction] Generic: done" << std::endl;
}
Ejemplo n.º 11
0
/**
 * Create scops for a sub-tree.
 *
 */
void
ScopExtractor::extractScops(SgNode* root)
{
  if (isVerbose)
    std::cout << "[PolyOpt] Using generic scop extractor" << std::endl;

  SgNodePtrList funcDefnList =
    NodeQuery::querySubTree(root, V_SgFunctionDefinition);
  SgNodePtrList::const_iterator iter;
  // Iterate on all functions defined in a sub-tree.
  for (iter = funcDefnList.begin(); iter != funcDefnList.end(); ++iter)
    {
      SgFunctionDefinition *fun = isSgFunctionDefinition(*iter);
      if (!fun)
	{
	  cout << "[Extr] Warning: Expected SgFunctionDefinition" << endl;
	  continue; // with the next function definition
	}
      SgName name = fun->get_declaration()->get_name();
      if (polyoptions.getScVerboseLevel())
	cout << "[Extr] Function: " << name.getString() << endl;
      SgBasicBlock* body = fun->get_body();

      // Ensure the function is a candidate (no (unsafe) function
      // calls).
      if (assertFunctionIsCandidate(NULL, body))
	{
	  // Proceed recursively, bottom up.
	  inspectBottomUpFunctionBody(NULL, body);
	}
    }

  // If no function is defined in the subtree, simply process it
  // as-is.
  if (funcDefnList.size() == 0)
    if (assertFunctionIsCandidate(NULL, root))
      // Proceed recursively, bottom up.
      inspectBottomUpFunctionBody(NULL, root);

  if (isVerbose)
    std::cout << "[ScopExtraction] Generic: done" << std::endl;
}
Ejemplo n.º 12
0
int main(int argc, char *argv[]) 
{
  // Build the AST used by ROSE
  SgProject* proj = frontend(argc,argv);
  ROSE_ASSERT (proj != NULL); 

  SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);
  ROSE_ASSERT (mainDefDecl != NULL); 

  SgFunctionDefinition* mainDef = mainDefDecl->get_definition();
  ROSE_ASSERT (mainDef != NULL); 

  string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
  string dotFileName1=fileName+"."+ mainDef->get_declaration()->get_name() +".IPCFG.dot";

  StaticCFG::InterproceduralCFG cfg(mainDef);

  // Dump out the full CFG, including bookkeeping nodes
  cfg.cfgToDot(mainDef, dotFileName1);

  return 0;
}
Ejemplo n.º 13
0
//Searches through the expression for variables of the given type then links them with the key node provided
void Analysis::linkVariables(SgNode* key, SgType* type, SgExpression* expression){
  RoseAst ast(expression);
  for(RoseAst::iterator i = ast.begin(); i!=ast.end(); i++){
    if(SgExpression* exp = isSgExpression(*i)){
      if(sameType(exp->get_type(), type)){
        if(SgFunctionCallExp* funCall = isSgFunctionCallExp(exp)){
          SgFunctionDeclaration* funDec = funCall->getAssociatedFunctionDeclaration();
          SgFunctionDefinition* funDef = SgNodeHelper::determineFunctionDefinition(funCall);
          if(!funDef) continue;
          funDec = funDef->get_declaration();
          addToMap(key, funDec);
          i.skipChildrenOnForward();
        }
        else if(SgPntrArrRefExp* refExp = isSgPntrArrRefExp(exp)){
          linkVariables(key, refExp->get_lhs_operand()->get_type(), refExp->get_lhs_operand());
          i.skipChildrenOnForward();
        }
        else if(SgPointerDerefExp* refExp = isSgPointerDerefExp(exp)){
          linkVariables(key, refExp->get_operand()->get_type(), refExp->get_operand());
          i.skipChildrenOnForward();
        }
        else if(SgVarRefExp* varRef = isSgVarRefExp(exp)){
          SgVariableSymbol* varSym = varRef->get_symbol();
          if(varSym){  
            SgInitializedName* refInitName = varSym->get_declaration();
            SgNode* target = refInitName;
            if(!SgNodeHelper::isFunctionParameterVariableSymbol(varSym)) target = refInitName->get_declaration();
            if(target){
              addToMap(key, target);
            }
          }
        }
      }
    }
  }
}
Ejemplo n.º 14
0
int main(int argc, char *argv[]) {
SgProject* proj = frontend(argc,argv);
ROSE_ASSERT (proj != NULL);
SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);
SgFunctionDefinition* mainDef = mainDefDecl->get_definition();
visitorTraversal* vis = new visitorTraversal();
StaticCFG::CFG cfg(mainDef);
stringstream ss;
string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
string dotFileName1=fileName+"."+ mainDef->get_declaration()->get_name() +".dot";
cfgToDot(mainDef,dotFileName1);
SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();
g = cfg.getGraph();
myGraph* mg = new myGraph();
mg = instantiateGraph(g, cfg);
std::set<std::vector<string> > sssv;
std::vector<string> sss;
sss.push_back("Start(::main)<SgFunctionDefinition> @line=1 :idx=0");
sss.push_back("main_parameter_list_<SgFunctionParameterList> @line=1 :idx=0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @line=1 :idx=1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @line=1 :idx=2");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=0");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=0");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=1");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=1");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=1");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=0");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=0");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=1");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=1");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=4");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=2");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=1");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=1");
sss.push_back("End(::main)<SgFunctionDefinition> @line=1 :idx=3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @line=1 :idx=0");
sss.push_back("main_parameter_list_<SgFunctionParameterList> @line=1 :idx=0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @line=1 :idx=1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @line=1 :idx=2");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=0");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=0");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=1");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=1");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=1");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=0");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=0");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=1");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=1");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=0");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=0");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=0");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=1");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=1");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=0");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=1");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=1");
sss.push_back("0x2b916c912478<SgBasicBlock> @line=5 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=6 :idx=0");
sss.push_back("SgAssignOp_undef_name<SgAssignOp> @line=6 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=6 :idx=0");
sss.push_back("SgAssignOp_undef_name<SgAssignOp> @line=6 :idx=1");
sss.push_back("SgAddOp_undef_name<SgAddOp> @line=6 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=6 :idx=0");
sss.push_back("SgAddOp_undef_name<SgAddOp> @line=6 :idx=1");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=6 :idx=0");
sss.push_back("SgAddOp_undef_name<SgAddOp> @line=6 :idx=2");
sss.push_back("SgAssignOp_undef_name<SgAssignOp> @line=6 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=6 :idx=1");
sss.push_back("0x2b916c912478<SgBasicBlock> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=1");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=1");
sss.push_back("0x2b916c9125f0<SgBasicBlock> @line=8 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=9 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=9 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=9 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=9 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=9 :idx=1");
sss.push_back("0x2b916c9125f0<SgBasicBlock> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=4");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=4");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=2");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=1");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=1");
sss.push_back("End(::main)<SgFunctionDefinition> @line=1 :idx=3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @line=1 :idx=0");
sss.push_back("main_parameter_list_<SgFunctionParameterList> @line=1 :idx=0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @line=1 :idx=1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @line=1 :idx=2");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=0");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=0");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=1");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=1");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=1");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=0");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=0");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=1");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=1");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=0");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=0");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=0");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=1");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=1");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=0");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=1");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=1");
sss.push_back("0x2b916c912478<SgBasicBlock> @line=5 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=6 :idx=0");
sss.push_back("SgAssignOp_undef_name<SgAssignOp> @line=6 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=6 :idx=0");
sss.push_back("SgAssignOp_undef_name<SgAssignOp> @line=6 :idx=1");
sss.push_back("SgAddOp_undef_name<SgAddOp> @line=6 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=6 :idx=0");
sss.push_back("SgAddOp_undef_name<SgAddOp> @line=6 :idx=1");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=6 :idx=0");
sss.push_back("SgAddOp_undef_name<SgAddOp> @line=6 :idx=2");
sss.push_back("SgAssignOp_undef_name<SgAssignOp> @line=6 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=6 :idx=1");
sss.push_back("0x2b916c912478<SgBasicBlock> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=1");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=4");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=4");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=2");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=1");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=1");
sss.push_back("End(::main)<SgFunctionDefinition> @line=1 :idx=3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @line=1 :idx=0");
sss.push_back("main_parameter_list_<SgFunctionParameterList> @line=1 :idx=0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @line=1 :idx=1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @line=1 :idx=2");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=0");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=0");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=1");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=1");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=1");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=0");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=0");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=1");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=1");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=0");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=0");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=0");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=1");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=1");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=0");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=1");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=1");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=1");
sss.push_back("0x2b916c9125f0<SgBasicBlock> @line=8 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=9 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=9 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=9 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=9 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=9 :idx=1");
sss.push_back("0x2b916c9125f0<SgBasicBlock> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=4");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=4");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=2");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=1");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=1");
sss.push_back("End(::main)<SgFunctionDefinition> @line=1 :idx=3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @line=1 :idx=0");
sss.push_back("main_parameter_list_<SgFunctionParameterList> @line=1 :idx=0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @line=1 :idx=1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @line=1 :idx=2");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=0");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=0");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=1");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=1");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=1");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=0");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=0");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=1");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=1");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=0");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=0");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=0");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=1");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=1");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=0");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=5 :idx=0");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=5 :idx=1");
sss.push_back("SgModOp_undef_name<SgModOp> @line=5 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=5 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=5 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=1");
sss.push_back("0x2b916cb41010<SgIfStmt> @line=5 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=0");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=0");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=0");
sss.push_back("var_ref_of_k<SgVarRefExp> @line=8 :idx=0");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=8 :idx=1");
sss.push_back("SgSubtractOp_undef_name<SgSubtractOp> @line=8 :idx=2");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=1");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=8 :idx=1");
sss.push_back("SgEqualityOp_undef_name<SgEqualityOp> @line=8 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=1");
sss.push_back("0x2b916cb41180<SgIfStmt> @line=8 :idx=2");
sss.push_back("0x2b916c912300<SgBasicBlock> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=4");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=4");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=2");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=1");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=1");
sss.push_back("End(::main)<SgFunctionDefinition> @line=1 :idx=3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @line=1 :idx=0");
sss.push_back("main_parameter_list_<SgFunctionParameterList> @line=1 :idx=0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @line=1 :idx=1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @line=1 :idx=2");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=0");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=0");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=2 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=2 :idx=1");
sss.push_back("initialized_name_k<SgInitializedName> k :idx=1");
sss.push_back("_variable_declaration_k<SgVariableDeclaration> @line=2 :idx=1");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=0");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=0");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=3 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=3 :idx=1");
sss.push_back("initialized_name_i<SgInitializedName> i :idx=1");
sss.push_back("_variable_declaration_i<SgVariableDeclaration> @line=3 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=0");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=0");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=0");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=0");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=0");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=4 :idx=1");
sss.push_back("SgAssignInitializer_undef_name<SgAssignInitializer> @line=4 :idx=1");
sss.push_back("initialized_name_j<SgInitializedName> j :idx=1");
sss.push_back("_variable_declaration_j<SgVariableDeclaration> @line=4 :idx=1");
sss.push_back("SgForInitStatement<SgForInitStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=0");
sss.push_back("var_ref_of_j<SgVarRefExp> @line=4 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=4 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=4 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=4 :idx=1");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=2");
sss.push_back("0x2b916cac7178<SgForStatement> @line=4 :idx=4");
sss.push_back("0x2b916c912188<SgBasicBlock> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=3");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgPlusPlusOp_undef_name<SgPlusPlusOp> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=1");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=0");
sss.push_back("var_ref_of_i<SgVarRefExp> @line=3 :idx=0");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=1");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=0");
sss.push_back("integer_value_exp_2<SgIntVal> @line=3 :idx=1");
sss.push_back("SgLessThanOp_undef_name<SgLessThanOp> @line=3 :idx=2");
sss.push_back("SgExprStatement<SgExprStatement> @line=3 :idx=1");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=2");
sss.push_back("0x2b916cac7010<SgForStatement> @line=3 :idx=4");
sss.push_back("0x2b916c912010<SgBasicBlock> @line=1 :idx=2");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=0");
sss.push_back("integer_value_exp_0<SgIntVal> @line=13 :idx=1");
sss.push_back("SgReturnStmt<SgReturnStmt> @line=13 :idx=1");
sss.push_back("End(::main)<SgFunctionDefinition> @line=1 :idx=3");
sssv.insert(sss);
sss.clear();
vis->sssv = sssv;
vis->constructPathAnalyzer(mg, true, 0, 0, true);
ROSE_ASSERT(vis->sssv.size() == vis->paths.size());
std::cout << "finished" << std::endl;
std::cout << " paths: " << vis->paths.size() << std::endl;
delete vis;
}
Ejemplo n.º 15
0
    void process() {
        int i;

        for (i = 0; i < fdefList.size(); i++) {
            SgFunctionDefinition* fndef = fdefList.at(i);       

            if (fndef == NULL) {
                return;
            }

            std::string functionName = 
                fndef->get_declaration()->get_name().getString();

            SgFunctionDeclaration *f = fndef->get_declaration();

            if (!debugHooks) {
                SgNode *body = fndef->get_body();

                // Move any preprocessing info before the function to a new
                // null statement preceding the function.
                AttachedPreprocessingInfoType save_buf;
                SageInterface::cutPreprocessingInfo(f, 
                                                    PreprocessingInfo::before, 
                                                    save_buf) ;
                if (save_buf.size()) {
                    SgVariableDeclaration *dummy = 
                        SageBuilder::buildVariableDeclaration(
                            "___htc_dummy_decl_for_preproc_info", 
                            SageBuilder::buildIntType(), 0, f->get_scope());
                    SageInterface::setExtern(dummy);

                    SageInterface::insertStatementBefore(f, dummy);
                    SageInterface::pastePreprocessingInfo(
                        dummy, 
                        PreprocessingInfo::before, 
                        save_buf); 
                }

                SageInterface::addTextForUnparser(
                    f, 
                    "\n#if 0",     
                    AstUnparseAttribute::e_before);

                std::string CapFnName = Capitalize(functionName);
                std::string before_body = "\n#endif\n";
                std::string macro_name = "HTC_KEEP_MODULE_" + Upper(functionName);
                before_body += 
                    "#ifdef " +
                    macro_name +
                    "\n";
                before_body += "#include \"Ht.h\"\n";
                before_body += "#include \"Pers" +
                    CapFnName +
                    ".h\"\n";
                before_body += "#ifndef __htc_GW_write_addr\n";
                before_body += "#define __htc_GW_write_addr(v,a) v.write_addr(a)\n";
                before_body += "#endif\n";
                before_body += "#ifndef __htc_GW_write_addr2\n";
                before_body += "#define __htc_GW_write_addr2(v,a,b) v.write_addr(a,b)\n";
                before_body += "#endif\n";
                before_body += "void CPers" +
                    CapFnName +
                    "::Pers" +
                    CapFnName +
                    "()\n";
                SageInterface::addTextForUnparser(body, before_body,
                                                  AstUnparseAttribute::e_before);
                std::string after_body =
                    "\n#endif /* " +
                    macro_name +
                    " */\n";
                SageInterface::addTextForUnparser(body, after_body,
                                                  AstUnparseAttribute::e_after);
                
                // Write the _src.cpp file
                generate_src_cpp_file(fndef, CapFnName, macro_name);            
            }
        }
        for (i = 0; i < fdeclList.size(); i++) {

            SgFunctionDeclaration *fdecl = fdeclList.at(i);

            if (!debugHooks && 
                fdecl && 
                fdecl->get_definingDeclaration() != fdecl) {

                // Move any preprocessing info before the function to a new
                // null statement preceding the function.
                AttachedPreprocessingInfoType save_buf;
                SageInterface::cutPreprocessingInfo(fdecl, 
                                                    PreprocessingInfo::before, 
                                                    save_buf) ;
                if (save_buf.size()) {
                    SgVariableDeclaration *dummy2 = 
                        SageBuilder::buildVariableDeclaration(
                            "___htc_dummy_decl2_for_preproc_info", 
                            SageBuilder::buildIntType(), 
                            0, 
                            fdecl->get_scope());
                    SageInterface::setExtern(dummy2);

                    SageInterface::insertStatementBefore(fdecl, dummy2);
                    SageInterface::pastePreprocessingInfo(
                        dummy2, 
                        PreprocessingInfo::before, 
                        save_buf); 

                }

                SageInterface::addTextForUnparser(fdecl, "\n/* ",
                                                  AstUnparseAttribute::e_before);
                SageInterface::addTextForUnparser(fdecl, " */",
                                                  AstUnparseAttribute::e_after);
                // comment out function prototypes
                //            fdecl->setCompilerGenerated();
                //            fdecl->unsetOutputInCodeGeneration();
            }
        }

    }
Ejemplo n.º 16
0
  //return name for various named constructs
  string roseNode::getName() const
  {
    string result;
    ROSE_ASSERT(mNode!=NULL);
    // only declarations with symbols in ROSE have user-level names
    // need to double check this
    if (isSgFile(mNode)) 
    {
      return isSgFile(mNode)->get_file_info()->get_filenameString ();
    } 
    else  if (isSgProject(mNode))
    { // No name field for rose projects
      return "";
    }
    else if (isSgFunctionDefinition(mNode))
    {
      SgFunctionDefinition* def = isSgFunctionDefinition(mNode);
      return (def->get_declaration()->search_for_symbol_from_symbol_table()->get_name()).getString();
    }  

    SgDeclarationStatement* decl = isSgDeclarationStatement(mNode); 
    if (decl)
    {
      switch (decl->variantT())
      { 
        case V_SgVariableDeclaration:
          {
            SgVariableSymbol * symbol=SageInterface::getFirstVarSym(isSgVariableDeclaration(decl));
            result = symbol->get_name();
            break;
          }
        case V_SgClassDeclaration:
        case V_SgTypedefDeclaration:
        case V_SgNamespaceDeclarationStatement:
        case V_SgFunctionDeclaration:
        case V_SgTemplateDeclaration:
        case V_SgMemberFunctionDeclaration:
          {
            result = (decl->search_for_symbol_from_symbol_table()->get_name()).getString();
            ROSE_ASSERT(result.length()!=0);
            break;
          }
         // No explicit name available
        case V_SgCtorInitializerList:
        case V_SgPragmaDeclaration:
        case V_SgFunctionParameterList:
        case V_SgUsingDirectiveStatement:
        case V_SgStmtDeclarationStatement:
          {
            break;
          }
        default:
          {
            cerr<<"error, unhandled declaration type in roseNode::getName(): "<<mNode->class_name()<<endl;
            ROSE_ASSERT(false);
            break;
          }
      }// end switch
    }
    return result ;
  }
Ejemplo n.º 17
0
int main(int argc, char *argv[]) {
SgProject* proj = frontend(argc,argv);
ROSE_ASSERT (proj != NULL);
SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);
SgFunctionDefinition* mainDef = mainDefDecl->get_definition();
visitorTraversal* vis = new visitorTraversal();
StaticCFG::CFG cfg(mainDef);
stringstream ss;
string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
string dotFileName1=fileName+"."+ mainDef->get_declaration()->get_name() +".dot";
cfgToDot(mainDef,dotFileName1);
SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();
g = cfg.getGraph();
myGraph* mg = new myGraph();
mg = instantiateGraph(g, cfg);
std::set<std::vector<string> > sssv;
std::vector<string> sss;
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @8 :0");
sss.push_back("<SgExprStatement> @9 :0");
sss.push_back("<SgAssignOp> @9 :0");
sss.push_back("<SgVarRefExp> @9 :0");
sss.push_back("<SgAssignOp> @9 :1");
sss.push_back("<SgIntVal> @9 :0");
sss.push_back("<SgIntVal> @9 :1");
sss.push_back("<SgAssignOp> @9 :2");
sss.push_back("<SgExprStatement> @9 :1");
sss.push_back("<SgBasicBlock> @8 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
sss.push_back("Start(::main)<SgFunctionDefinition> @1 :0");
sss.push_back("<SgFunctionParameterList> @1 :0");
sss.push_back("After parameters(::main)<SgFunctionDefinition> @1 :1");
sss.push_back("After pre-initialization(::main)<SgFunctionDefinition> @1 :2");
sss.push_back("<SgBasicBlock> @2 :0");
sss.push_back("<SgVariableDeclaration> @3 :0");
sss.push_back("<SgInitializedName> k :0");
sss.push_back("<SgAssignInitializer> @3 :0");
sss.push_back("<SgIntVal> @3 :0");
sss.push_back("<SgIntVal> @3 :1");
sss.push_back("<SgAssignInitializer> @3 :1");
sss.push_back("<SgInitializedName> k :1");
sss.push_back("<SgVariableDeclaration> @3 :1");
sss.push_back("<SgBasicBlock> @2 :1");
sss.push_back("<SgVariableDeclaration> @4 :0");
sss.push_back("<SgInitializedName> x :0");
sss.push_back("<SgAssignInitializer> @4 :0");
sss.push_back("<SgIntVal> @4 :0");
sss.push_back("<SgIntVal> @4 :1");
sss.push_back("<SgAssignInitializer> @4 :1");
sss.push_back("<SgInitializedName> x :1");
sss.push_back("<SgVariableDeclaration> @4 :1");
sss.push_back("<SgBasicBlock> @2 :2");
sss.push_back("<SgIfStmt> @5 :0");
sss.push_back("<SgExprStatement> @5 :0");
sss.push_back("<SgOrOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgAndOp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :0");
sss.push_back("<SgBoolValExp> @5 :1");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgAndOp> @5 :1");
sss.push_back("<SgAndOp> @5 :2");
sss.push_back("<SgOrOp> @5 :1");
sss.push_back("<SgOrOp> @5 :2");
sss.push_back("<SgExprStatement> @5 :1");
sss.push_back("<SgIfStmt> @5 :1");
sss.push_back("<SgBasicBlock> @5 :0");
sss.push_back("<SgExprStatement> @6 :0");
sss.push_back("<SgAssignOp> @6 :0");
sss.push_back("<SgVarRefExp> @6 :0");
sss.push_back("<SgAssignOp> @6 :1");
sss.push_back("<SgIntVal> @6 :0");
sss.push_back("<SgIntVal> @6 :1");
sss.push_back("<SgAssignOp> @6 :2");
sss.push_back("<SgExprStatement> @6 :1");
sss.push_back("<SgBasicBlock> @5 :1");
sss.push_back("<SgIfStmt> @5 :2");
sss.push_back("<SgBasicBlock> @2 :3");
sss.push_back("<SgReturnStmt> @11 :0");
sss.push_back("<SgIntVal> @11 :0");
sss.push_back("<SgIntVal> @11 :1");
sss.push_back("<SgReturnStmt> @11 :1");
sss.push_back("End(::main)<SgFunctionDefinition> @1 :3");
sssv.insert(sss);
sss.clear();
vis->sssv = sssv;
vis->constructPathAnalyzer(mg, true, 0, 0, true);
std::cout << "finished" << std::endl;
std::cout << " paths: " << vis->paths.size() << std::endl;
delete vis;
}
void ControlDependenceGraph::_buildInterprocedural()
{


    // Go through the SGNODE dependence nodes and create the appropriate
    // call site nodes, entry nodes etc.

    SgFunctionDefinition *func = isSgFunctionDefinition(_head);

    ROSE_ASSERT(func != NULL);

    // First create the entry node for the procedure
    _interprocedural->procedureEntry.entry =
        new DependenceNode(DependenceNode::ENTRY, func->get_declaration());
    DependenceNode *entry = createNode(_interprocedural->procedureEntry.entry);

    // Link the entry node up with all the nodes in the CDG which do not have
    // predecessors
    for (set < SimpleDirectedGraphNode * >::iterator i = _nodes.begin(); i != _nodes.end(); i++)
    {
        DependenceNode *node = dynamic_cast < DependenceNode * >(*i);

        if ((node->numPredecessors() == 0) && (node != entry))
        {
            establishEdge(entry, node);
        }
    }

    // create a formal out return argument, control dependent on the entry
    // node
    string return_name = func->get_declaration()->get_name().str();

    return_name = return_name + " return";
    _interprocedural->procedureEntry.formal_return =
        new DependenceNode(DependenceNode::FORMALOUT, return_name);
    DependenceNode *formal_return = createNode(_interprocedural->procedureEntry.formal_return);

    establishEdge(entry, formal_return);

    // for each of the arguments in the function parameter list, add a
    // formal-in and formal-out node
    SgFunctionParameterList *paramlist = func->get_declaration()->get_parameterList();
    SgInitializedNamePtrList params = paramlist->get_args();

    for (SgInitializedNamePtrList::iterator i = params.begin(); i != params.end(); i++)
    {
        SgInitializedName *name = *i;
        DependenceNode *formal_in = new DependenceNode(DependenceNode::FORMALIN,
                                                       name->get_name().str());
        DependenceNode *formal_out = new DependenceNode(DependenceNode::FORMALOUT,
                                                        name->get_name().str());

        establishEdge(entry, createNode(formal_in));
        establishEdge(entry, createNode(formal_out));
        _interprocedural->procedureEntry.formal_in[name] = formal_in;
        _interprocedural->procedureEntry.formal_out[name] = formal_out;

        // To preserve the order of arguments, we insert them into arg_order
        _interprocedural->procedureEntry.arg_order.push_back(name);
    }

    // Now we go through each of the SgNodes in our CDG. If any of them
    // contain a function call, we want to build a call site node for them.
    map < SgNode *, DependenceNode * >::iterator sgnode_iterator;
    for (sgnode_iterator = _sgnode_map.begin();
         sgnode_iterator != _sgnode_map.end(); sgnode_iterator++)
    {
        SgNode *currnode = sgnode_iterator->first;

        list < SgFunctionCallExp * >calls = InterproceduralInfo::extractFunctionCalls(currnode);
        if (calls.empty())
            continue;

        for (list < SgFunctionCallExp * >::iterator i = calls.begin(); i != calls.end(); i++)
        {
            SgFunctionCallExp *call = *i;

            // This needs to be replaced with some call graph analysis
            SgFunctionRefExp *func = isSgFunctionRefExp(call->get_function());

            ROSE_ASSERT(func != NULL);
            SgName func_name = func->get_symbol()->get_name();

            InterproceduralInfo::CallSiteStructure callstructure;
            callstructure.callsite = new DependenceNode(DependenceNode::CALLSITE, call);
            // the call site is control dependent on the statement (i.e. for
            // the call site to happen, the statement must be executed)
            DependenceNode *callsite = createNode(callstructure.callsite);

            // addLink(callsite, getNode(currnode));
            establishEdge(getNode(currnode), callsite);

            // create an actual out node for the return value, control
            // dependent on callsite
            string return_name = func_name.str();

            return_name = return_name + " return";
            callstructure.actual_return =
                new DependenceNode(DependenceNode::ACTUALOUT, return_name);
            DependenceNode *actual_return = createNode(callstructure.actual_return);

            establishEdge(callsite, actual_return);

            // For each argument in the function call, build an actual_in and
            // actual_out, control dependent on callsite
            SgExpressionPtrList args = call->get_args()->get_expressions();

            for (SgExpressionPtrList::iterator j = args.begin(); j != args.end(); j++)
            {
                SgExpression *arg = *j;
                DependenceNode *actual_in = new DependenceNode(DependenceNode::ACTUALIN, arg);
                DependenceNode *actual_out = new DependenceNode(DependenceNode::ACTUALOUT, arg);

                establishEdge(callsite, createNode(actual_in));
                establishEdge(callsite, createNode(actual_out));
                callstructure.actual_in[arg] = actual_in;
                callstructure.actual_out[arg] = actual_out;

                // To preserve the order of expressions in the parameter list, 
                // 
                // we insert them into expr_order
                callstructure.expr_order.push_back(arg);
            }

            // add the callstructure to interprocedural info
            _interprocedural->callsite_map[call] = callstructure;
        }
    }
}
void SimpleInstrumentation::visit(SgNode* astNode)
   {
  // SgFile *file=isSgFile(astNode);
     SgFunctionDefinition* funcdef = isSgFunctionDefinition(astNode);
     if (funcdef != NULL && !done)
        {
          printf ("In visit(): Found SgFunctionDefinition: funcdef->get_declaration()->get_name() = %s \n",funcdef->get_declaration()->get_name().str());

          SgScopeStatement *scope = getGlobalScope(funcdef);
#if 1
       // DQ (11/9/2015): Unless this is marked to be output in code generaton, this function will not show up in the output.
          printf ("Calling buildDefiningFunctionDeclaration() \n");
          SgFunctionDeclaration *func_defn = buildDefiningFunctionDeclaration(SgName("testFunc"),buildVoidType(),buildFunctionParameterList(buildInitializedName(SgName("param1"),buildIntType(),NULL)),scope);
#endif
#if 1
          reportNodesMarkedAsModified(func_defn);
#endif
#if 1
          printf ("Calling buildNondefiningFunctionDeclaration() \n");
          SgFunctionDeclaration *func_decl = buildNondefiningFunctionDeclaration(func_defn, scope);
#endif
#if 1
          reportNodesMarkedAsModified(func_decl);
#endif
          if (NULL != isSgGlobal(scope))
             {
               SgStatement *first_stmt = findFirstDefiningFunctionDecl(scope);

               printf ("Handling the global scope: first_stmt = %p \n",first_stmt);

               if (NULL == first_stmt)
                  {
                    first_stmt = getFirstStatement(scope);
                  }

               if (NULL != first_stmt)
                  {
                 // DQ (11/9/2015): Unless this is marked to be output in code generaton, this function will not show up in the output.
                    printf ("Calling insertStatementBefore() \n");
#if 1
                    insertStatementBefore(first_stmt,func_decl);
#endif
                  }
                 else
                  {
                 // DQ (11/9/2015): Unless this is marked to be output in code generaton, this function will not show up in the output.
                    printf ("Calling prependStatement() \n");
#if 1
                    prependStatement(func_decl,scope);
#endif
                  }
             }
            else
             {
            // DQ (11/9/2015): Unless this is marked to be output in code generaton, this function will not show up in the output.
               printf ("Handling the non-global scope \n");
#if 1
               prependStatement(func_decl, scope);
#endif
             }

#if 1
          reportNodesMarkedAsModified(scope);
#endif
#if 0
          SgProject::set_verbose(3);
#endif
          printf ("Calling insertStatementAfter() \n");
#if 0
          SgStatement *last_global_decl = findLastDeclarationStatement(scope);
          insertStatementAfter(last_global_decl, func_defn);
#else
       // DQ (11/9/2015): Unless this is marked to be output in code generaton, this function will not show up in the output.
          insertStatementAfter(funcdef->get_declaration(), func_defn);
#endif

#if 1
          reportNodesMarkedAsModified(scope);
#endif

          SgBasicBlock *func_body = func_defn->get_definition()->get_body();

#if 0
          SgProject::set_verbose(0);
#endif
          printf ("Calling buildVariableDeclaration() \n");
          SgVariableDeclaration *i = buildVariableDeclaration(SgName("i"),buildIntType(),buildAssignInitializer(buildIntVal(0),buildIntType()),func_body);

#if 1
          reportNodesMarkedAsModified(scope);
#endif

#if 0
          SgProject::set_verbose(3);
#endif
       // DQ (11/9/2015): Unless this is marked to be output in code generaton, this function will not show up in the output.
          printf ("Calling appendStatement() \n");
          appendStatement(i,func_body);

#if 1
          reportNodesMarkedAsModified(scope);
#endif
#if 0
          SgProject::set_verbose(0);
#endif
          done = true;

          printf ("Leaving visit(): SgFunctionDefinition: funcdef->get_declaration()->get_name() = %s \n",funcdef->get_declaration()->get_name().str());
        }
   }
Ejemplo n.º 20
0
int main(int argc,char ** argv)
{
	SgProject *project = frontend(argc, argv);
	VisPromelaAST * debugPromelaAst=new VisPromelaAST(project);
	cout <<"reverting mpi"<<endl;
	revertMPIDefinitions(project);
	
	announceStep(1,0,"Identify modelchecking targets");
	//! step1: Identify modelchecking targets
	PromelaMarker initialMarker;
	initialMarker.traverse(project, preorder);
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.inital_marking.dot");		
	// since the next step is creating a slice, we must identify all statements which are modelchekcing targets so that we have a valid slice
	SlicingInfo si=SlicingInfo();
	// it might be better to use the AST-Attributes as a method for containing this information, but right now the pragma is sufficient
	si.setSliceTargetString(string("SPIN_TARGET"));
	si.traverse(project, preorder);


	announceStep(2,0,"Create abstractions using sdg and other means");
	// create the sdg
	SystemDependenceGraph * sdg=new SystemDependenceGraph();
	sdg->parseProject(project);
	//TODO: at this point one would implement abstractions, because they alter the code in such a way, that slicing might be able to remove additional statements, which otherwihse would not be removed
	

	announceStep(3,0,"Slice program to reduce state-space and\n\t eliminate dead code from abstractions");
	//! Step2: Slice program to reduce towards abstraction and goal
		
	// create the set of nodes, that are in the slice, in terms of the sdg
	CreateSliceSet sliceSet(sdg,si.getSlicingTargets());

	// using the set of statements that are within the slice construct an unnamed CreateSlice-class and slice the project
	CreateSlice(sliceSet.computeSliceSet()).traverse(project);
	
	// since now the ast is substantially different from the previouse version the sdg is not valid anymore
	delete(sdg);

	//DEVEL: output the sliced statement-graph
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.sliced.dot");		
	//DEVEL: run-ast-consistancy-test to enshure a valid ast
	AstTests::runAllTests(project);


	announceStep(4,1,"Perform sanity-check for non-transformable code like scanf and parameterinput  argc and argv");
	//TODO: implement the sanitiy-checks
	

	announceStep(4,2,"Identify Process and Thread functions and mark them as PROMELA-Procs");
	// find process functions,like main and thread-functions.
	// For this version of the transformation only main is valid, 
	// but later on threadfunctions might also work. Therefore the
	// a vector is used to store the main function
	vector<SgFunctionDefinition*> procFuncVec=findProcessFunctions(project);
	// mark those function declarations,definitions and main-basic block to enshure proper promela-output
	for (int i=0;i<procFuncVec.size();i++)
	{
		cout <<"\t*marking function for promela-output: "<<procFuncVec[i]->get_declaration()->get_name().getString()<<endl;
		// mark the function body for transformation
		markForPromelaTransformation(procFuncVec[i]);
		// force the first SgBasicBlock to be converted to promela!!!!!
		markForPromelaTransformation(procFuncVec[i]->get_body () );
		//CI (04/16/2007): This is currently not necessary
		if (isSgFile(procFuncVec[i]->get_parent()->get_parent()->get_parent()))
		{
			cout <<"marking file"<<endl;
			markForPromelaTransformation(procFuncVec[i]->get_parent()->get_parent()->get_parent());
		}
	}
	
	
	announceStep(4,3,"Identify functions using global variables and add them to the inlining list");
	vector<SgVariableDeclaration *> globalVarDeclVec;
	vector<SgFunctionDefinition *> functionsToInline;
	std::map<SgNode*,bool> functionToInlineMap;
	
	//TODO: search in each functions for uses of a global variable, if the function contains a use, mark it and continue with the next function
	list<SgNode*> sgGlobalList=NodeQuery::querySubTree(project,V_SgGlobal);	
	for (list<SgNode*>::iterator sgGlobalIt=sgGlobalList.begin();sgGlobalIt!=sgGlobalList.end();sgGlobalIt++)	
	{
		// iterate over this scope without recursing and find all variabledeclarations ...
		SgDeclarationStatementPtrList globalDeclList=isSgGlobal(*sgGlobalIt)->get_declarations ();
		for (SgDeclarationStatementPtrList::iterator it=globalDeclList.begin();it!=globalDeclList.end();it++)
		{
			if (isSgVariableDeclaration(*it))
			{
				cout <<"\t\t*found VarDecl:"<<(*it)->unparseToString()<<endl;
				//TODO:	check if its from a header and if it is used..
				globalVarDeclVec.push_back(isSgVariableDeclaration(*it));
			}
		}		
	}
	
	// remove MPI-Symbols form the globals	
	vector<SgVariableDeclaration *> globalVarDeclVecTmp;
	for (int i=0;i<globalVarDeclVec.size();i++)
	{
		// if the current declaration is an mpi declaration, remove it from the global list (it is from a header, and will be directly supported in spin
		if (isNodeMPI(globalVarDeclVec[i]))
		{
			cout<<"\t\t* found an MPI-Var-Decl, ignoring"<<endl;
		}
		else
		{
			globalVarDeclVecTmp.push_back(globalVarDeclVec[i]);
		}
	}
	globalVarDeclVec=globalVarDeclVecTmp;
	
	// now that we have a list of all global declarations, find their uses
	list<SgNode*>  functionList=NodeQuery::querySubTree(project,V_SgFunctionDefinition);
	for (list<SgNode*>::iterator fIt=functionList.begin();fIt!=functionList.end();fIt++)
	{
		//check if the function is main, .. kind of silly to inline main...
		if (isSgFunctionDefinition(*fIt)->get_declaration()->get_name().getString()=="main") continue;
		// search the function for globals
		list<SgNode*> sgVarRefList=NodeQuery::querySubTree(*fIt,V_SgVarRefExp);	
		for (list<SgNode*>::iterator it=sgVarRefList.begin();sgVarRefList.end()!=it;it++)
		{
			//
			// get the declaration and then if the declaration is of global scope -> it is a global
			if (isSgFunctionParameterList(isSgVarRefExp(*it)->get_symbol () ->get_declaration ()->get_declaration())) continue;
			if (isSgVarRefExp(*it)->get_symbol () ->get_declaration ()->get_declaration()==NULL) // is an initialized name form the function.parameter.list
				continue;
			SgNode * tmp=(*it);
			while(!isSgStatement(tmp) && !isSgGlobal(tmp)) tmp=tmp->get_parent();
//			cout <<"\t\tParentStmt: "<<tmp->unparseToString()<<endl;
//			cout <<"\t\tdebug:"<<(*it)->unparseToString()<<endl;
//			cout <<"\t\tclass:"<<isSgVarRefExp(*it)->get_symbol () ->get_declaration ()->get_declaration()->class_name()<<endl;
			SgVariableDeclaration *decl=isSgVariableDeclaration(isSgVarRefExp(*it)->get_symbol () ->get_declaration ()->get_declaration());
			assert(decl!=NULL);
//			cout <<"\t\t*decl: "<<decl->unparseToString()<<endl;
			if (isSgGlobal(decl->get_parent())) // is a global scope -> global
			{
				// we have a global, add the function to the list and break
				functionsToInline.push_back(isSgFunctionDefinition(*fIt));
				functionToInlineMap[isSgFunctionDefinition(*fIt)]=true;
				cout <<"\t\t*Found use of Global <"<<decl->get_definition()->get_vardefn ()->get_name ().getString()<<"> in "<<isSgFunctionDefinition(*fIt)->get_declaration()->get_name().getString()<<", -> added to inline list"<<endl;
				break;
			}
		}
	}
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step4_3.dot");


	announceStep(4,4,"Identify function called by proc-functions that contain modelchecking critical code");
	// a function that contains modelchecking code is marked as a promela-target after PropagatePromelaTargetTraversal -> propagate promela-targets
	PropagatePromelaTargetTraversal().traverse(project);
	for (list<SgNode*>::iterator fIt=functionList.begin();fIt!=functionList.end();fIt++)
	{
		// if the definition has a promela and is not main
		//check if the function is main, .. kind of silly to inline main...
		if (isSgFunctionDefinition(*fIt)->get_declaration()->get_name().getString()=="main") continue;
		// add it to the list of inline targets..
		if (!functionToInlineMap.count(isSgFunctionDefinition(*fIt)) || !functionToInlineMap[isSgFunctionDefinition(*fIt)])
		{
		functionsToInline.push_back(isSgFunctionDefinition(*fIt));
		functionToInlineMap[isSgFunctionDefinition(*fIt)]=true;
		cout <<"\t\t*"<<isSgFunctionDefinition(*fIt)->get_declaration()->get_name().getString()<<" contains a modelchecking target, -> added to inline list"<<endl;
		}
		else
		{
			cout <<"\t\t*"<<isSgFunctionDefinition(*fIt)->get_declaration()->get_name().getString()<<" contains a modelchecking target, but is already marked for inlining"<<endl;
		}
	}	
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step4_4.dot");
	
	
	
	announceStep(4,5,"Inlining identifyed functions");
	bool doneSomeInlineing=false;
	if (functionsToInline.size())
	{
		// for all thread functions
		for (int procNr=0;procNr<procFuncVec.size();procNr++)
		{
			list<SgNode*> callSiteList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgFunctionCallExp);
			for (list<SgNode*>::iterator callSite=callSiteList.begin();callSite!=callSiteList.end();callSite++)
			{
				SgFunctionDefinition * def;
				// get the definition for that function
				if (isSgFunctionRefExp(isSgFunctionCallExp((*callSite))->get_function()))
				{
					// straight function call
					def=isSgFunctionRefExp(isSgFunctionCallExp((*callSite))->get_function())->get_symbol()->get_declaration()->get_definition();
				}
				else
				{
					cerr <<"ERROR: could not identify function-definition"<<endl;
					assert(false);
				}

				if (functionToInlineMap[def])
				{
					cout <<"\t\t*need to inline function >"<<def->get_declaration()->get_name().getString()<<"<"<<endl;
					bool inliningOK=false;
					inliningOK=doInline(isSgFunctionCallExp(*callSite));
					assert(inliningOK==true);
					doneSomeInlineing|=true;
				}
			}
		}
		if (doneSomeInlineing)
		{
			cout <<"\t\t*Inlineing done->performing ast-consistancy-check"<<endl;
			// now we can remove the definion and declaration of the iline functions
			for (int fNr=0;fNr<functionsToInline.size();fNr++)
			{
				cout <<"\t\t* removing function declaration and definition of "<<functionsToInline[fNr]->get_declaration()->get_name().getString()<<endl;
				LowLevelRewrite::remove(isSgStatement(functionsToInline[fNr]));
				LowLevelRewrite::remove(isSgStatement(functionsToInline[fNr]->get_declaration()));
				
			}
//			AstTests::runAllTests(project);
		}
	}
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step4_5.dot");
//this one failes..	AstTests::runAllTests(project);
	
	announceStep(4,6,"transform for loops to whjile loops");
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
        {
		changeForLoops(procFuncVec[procNr]);
	}
	
	announceStep(4,6,"MPI-Specific: Moving globals into main");
	for(int i=0;i<globalVarDeclVec.size();i++)
	{
		bool used=false;
		// do a nast search if or not the globals are used (->rules aout includesd stuff)
		SgInitializedName * gIniName=globalVarDeclVec[globalVarDeclVec.size()-1-i]->get_definition()->get_vardefn ();
		list<SgNode*> varRefExpList=NodeQuery::querySubTree(procFuncVec[0],V_SgVarRefExp);
		for (list<SgNode*>::iterator it=varRefExpList.begin();it!=varRefExpList.end();it++)
		{
			// check if the initialized name is in the list...
			SgVarRefExp * exp=isSgVarRefExp(*it);
			SgInitializedName * iniName=exp->get_symbol ()->get_declaration () ;
			if (gIniName==iniName)	
			{
				used=true;
				break;
			}
			
		}
		// and if not used->skip
		if (!used) continue;
		
		LowLevelRewrite::remove(isSgStatement(globalVarDeclVec[globalVarDeclVec.size()-1-i]));
		// is allwayzs main
		// add them in reverse order in case they depend on each other
		assert(procFuncVec.size()>0);
		assert(procFuncVec[0]->get_body ());
		procFuncVec[0]->get_body ()->prepend_statement (globalVarDeclVec[globalVarDeclVec.size()-1-i]);
		// and remove it from the old localtion
		
	}

	announceStep(4,7,"Replacing do-while and for-loops which contain model-targets with while-loops");
	//CI (4/19/2007): TODO
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
	{	
		list<SgNode*> loopsToReplace;
		list<SgNode*> tmpList;
		tmpList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgForStatement);
		loopsToReplace.insert(loopsToReplace.end(),tmpList.begin(),tmpList.end());
		
		tmpList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgDoWhileStmt);
		loopsToReplace.insert(loopsToReplace.end(),tmpList.begin(),tmpList.end());
		for (list<SgNode*>::iterator it=loopsToReplace.begin();it!=loopsToReplace.end();it++)
		{
			if (!toConvert(*it)) continue;
			//else
			if (isSgForStatement(*it)) forToWhileTransformation(isSgForStatement(*it));
			if (isSgDoWhileStmt(*it)) doWhileToWhileTransformation(isSgDoWhileStmt(*it));
		}
	}	

	// since the inline does not preserve ast-attributes, we need to regenerate them prom the "copied" pragmas
	announceStep(4,8,"Re-Identify modelchecking targets");
	PromelaMarker().traverse(project, preorder);
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step4_8.dot");
	
	// from this point on, only work on the function of procFuncVec is necessary,since all necessary data has been inlined
	
	announceStep(4,9,"Identify sideffecting-conditionals and move them out of the control-statement, if the statement is transformed to promela");
	// first update the modelchecking information
	PropagatePromelaTargetTraversal().traverse(project);
	list<SgNode*>  conditinalControlStmts;
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
	{
		list<SgNode*> tmpList;
		// IF
		tmpList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgIfStmt);
		conditinalControlStmts.insert(conditinalControlStmts.end(),tmpList.begin(),tmpList.end());
		// WHILE
		tmpList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgWhileStmt);
		conditinalControlStmts.insert(conditinalControlStmts.end(),tmpList.begin(),tmpList.end());
		// SWITCH
		tmpList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgSwitchStatement);
		conditinalControlStmts.insert(conditinalControlStmts.end(),tmpList.begin(),tmpList.end());

		
		//make loop userfriendly:
		
		for (list<SgNode*>::iterator it=conditinalControlStmts.begin();it!=conditinalControlStmts.end();it++)
		{
			bool isWhile=false;
			
			// if the statement is not suppoesed to be unparsed to promela -> skip
			if (!toConvert(*it)) continue;

			SgStatement * conditional=NULL;
			if (isSgIfStmt(*it))
			{
				conditional=isSgIfStmt(*it)->get_conditional ();
			}
			else if (isSgWhileStmt(*it))
			{
				conditional=isSgWhileStmt(*it)->get_condition ();
				isWhile=true;
			}
			else if (isSgSwitchStatement(*it))
			{
				conditional=isSgSwitchStatement(*it)->get_item_selector ();
			}
			// now that we have the SgStatement
			if (isSideEffektingStmt(conditional))
			{
				cout <<"\t\t*need to move >"<<conditional->unparseToString()<<"< outside the control-structure"<<endl;
				if (isWhile)
				{
					// if the loop contains a continue, substitute those with the end-labl and a goto there,
					list<SgNode*> continueStmtList=	NodeQuery::querySubTree(*it,V_SgContinueStmt);
					for (list<SgNode*>::iterator continueIt=continueStmtList.begin();
						continueIt!=continueStmtList.end();
						continueIt++)
						{
							// traverse from this one up to the next loop-parent
							SgNode * tmp=*continueIt;
							while(!isSgWhileStmt(tmp) &&
										!isSgDoWhileStmt(tmp)&&
										!isSgForStatement(tmp)) tmp=tmp->get_parent();
							// if the continue belongs to this while-loop
							if (tmp==*it)
								removeContinues(isSgWhileStmt(*it));
						}
				}
				
				// generate a VariableDeclaration
				SgVariableDeclaration * tempVarDecl=new SgVariableDeclaration(
					Sg_File_Info::generateDefaultFileInfoForTransformationNode(),
					SgName("spinBoolTmp"), new SgTypeBool());
				// get the expression form the statement
				assert(isSgExprStatement(conditional)!=NULL);
				SgExpression * condExpr=isSgExprStatement(conditional)->get_expression ();
				// generate a initial assignment using the existing stmt
				SgInitializer * initializer=new SgAssignInitializer(
					Sg_File_Info::generateDefaultFileInfoForTransformationNode(),condExpr);
				// attach initializer
				tempVarDecl->get_definition()->get_vardefn()->set_initializer (initializer);
				// create a sgvarRefExpr
				SgVarRefExp * ref=new  SgVarRefExp (Sg_File_Info::generateDefaultFileInfoForTransformationNode(),
				new SgVariableSymbol (tempVarDecl->get_definition()->get_vardefn ()));
				// replace the original statement with a SgVarRefExpr
				isSgExprStatement(conditional)->set_expression(ref);
				ref->set_parent(conditional);
				// get the parent scope and set it for the variable
				SgNode * tmp=*it;
				while(!isSgScopeStatement(tmp)) tmp=tmp->get_parent();
				tempVarDecl->get_definition()->get_vardefn()->set_scope(isSgScopeStatement(tmp)->get_scope());
				// and prepend the declaration before the conditional
				LowLevelRewrite::insert(isSgStatement(*it),tempVarDecl,true);
				// and append it to the while-body, which will work together with the inliner..
				if (isWhile)
				{
					
					ref=new  SgVarRefExp (Sg_File_Info::generateDefaultFileInfoForTransformationNode(),
						new SgVariableSymbol (tempVarDecl->get_definition()->get_vardefn ()));
					// copy the other expression
					SgExpression *rhs=isSgExpression(SgTreeCopy().copyAst(condExpr));					
					SgAssignOp * assgnExpr=new SgAssignOp(Sg_File_Info::generateDefaultFileInfoForTransformationNode(),ref,rhs);
					//append at the end of the loop, too
					isSgWhileStmt(*it)->get_body ()->append_statement (
						new		SgExprStatement (Sg_File_Info::generateDefaultFileInfoForTransformationNode(),assgnExpr)
						);
//					assgnExpr->set_parent(isSgWhileStmt(*it)->get_body ());
				}				
			}
			// else do nothing
		}
	}	


	// * 3.3: find all variables in the function,give them a unique name and move them to the bgeinning of the function, this is allowed because this is for C only!!!. This would not work for classes which must be constructed
	announceStep(4,8,"find all variables assign unique name and transform them to \n\tmatch promelas 2-scope-convention");
	string procName;
	vector<SgClassType *>classTypeList;
	// first rename all variables to have unique names...
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
	{
		flattenScopes(isSgFunctionDefinition(procFuncVec[procNr]));
	}
	// output a marked ast
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.reduced.dot");		

	
	
	announceStep(4,9,"final propagation of promela-targets");
	project->unparse();
	PropagatePromelaTargetTraversal().traverse(project);
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.transformations.dot");
	
	cout <<"-------------------------------------------------------------------------------"<<endl
             <<"\tFrom here on the C-Ast will be modified into a Promela/C-AST"<<endl
             <<"-------------------------------------------------------------------------------"<<endl;

	announceStep(6,1,"using the initial promela targets mark the ast");
	// using the sdg traverse the project to unparse to promela
	// the important step is to identify staements which can not be transformed to
	// promela because of PROMELA restrictions and therfore must be kept in C
	// since we have done slicing this is only done for functioncalls and such stuff
	// find the model-intersting nodes`
	sdg=new SystemDependenceGraph();
	sdg->parseProject(project);
	vector<SpinPStructContainer*> pStructContainerArray;
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
	{
		//	list<SgNode*> stmtList=NodeQuery::querySubTree(project,V_SgStatement);
		list<SgNode*> stmtList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgStatement);
		list<SgNode*> markedNodes;
		// find all nodes which have beem tagged for promela-transformation
		for (list<SgNode*>::iterator stmtIt=stmtList.begin();stmtIt!=stmtList.end();stmtIt++)
		{
			if (toConvert(*stmtIt))
			{
				markedNodes.push_back(*stmtIt);
			}
		}
		// once these statements have been identified, track their dependencys
		cout <<"processing stmt's"<<endl;
		for (list<SgNode*>::iterator it=markedNodes.begin();it!=markedNodes.end();it++)
		{
			cout <<"*stmt marked: "<<(*it)->unparseToString()<<endl;
			if (isSgFunctionDefinition(*it)) continue;
			cout <<"  control dependencys:"<<endl;
			DependenceNode* currDepNode=sdg->getNode(*it);
			set <SimpleDirectedGraphNode *> preds=currDepNode->getPredecessors();
			//
			cout <<(*it)->unparseToString()<<" has "<<preds.size()<<" predecessors"<<endl;
			// process all predecessors...
			for (set < SimpleDirectedGraphNode * >::iterator i = preds.begin();i != preds.end(); i++)
			{
				DependenceNode *pred = dynamic_cast < DependenceNode * >(*i);
				// ok this node is what dependency?
				set < DependenceGraph::EdgeType > connectingSet=sdg->edgeType(pred,currDepNode);
				SgNode * predNode=getStatement(pred->getSgNode());
				SgNode * parentPredNode=NULL;
				// since controlstatements like if and while have a statement as an expression in rose and since the expression has all the control dependencys track those, but mark the parent statement,too
				if (isSgWhileStmt(predNode->get_parent())) parentPredNode=predNode->get_parent();
				else if (isSgIfStmt(predNode->get_parent())) parentPredNode=predNode->get_parent();
				// if control, add to the transformation set
				if (connectingSet.count(DependenceGraph::CONTROL))
				{
					cout <<"\tcontrol dependency"<<endl;
					if (toConvert(predNode))
					{
						cout <<"\t>"<<predNode->unparseToString()<<"<already marked for conversion"<<endl;
					}
					else
					{
						markedNodes.push_back(pred->getSgNode());
						cout <<"\tmark >"<<predNode->unparseToString()<<"< for conversion"<<endl;
						markForPromelaTransformation(predNode);
						if (parentPredNode!=NULL)
							markForPromelaTransformation(parentPredNode);
					}
				}
				else if (connectingSet.count(DependenceGraph::DATA))
				{
					cout <<"data dependency presen, but not resolved!"<<endl;
					// this will be done by checkin all controll dependeny nodes and adding those to the promela state vector...
				}
				else
				{
					cout <<"ILLIGAL DEPENDENCY FOUND. Previouse transformations should have removed those!!!"<<endl;
				}
			}
		}
	}
	// now the ast is in its final marked for
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step6_1.dot");

	announceStep(6,2,"Creating PStruct");
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
	{

		/* create astruct that contains the data that is stored in the state vector...*/
		SpinPStructContainer * pStruct=
			new SpinPStructContainer(
				procFuncVec[procNr]->get_declaration()->get_name().getString()
			);
		// add the struct to the AST-for fun->it will be hidden in the promela output pass	
		LowLevelRewrite::insert(
			isSgStatement(procFuncVec[procNr]->get_parent()),
			pStruct->getStructSubTree(),
			true
		);
		
		// put the struct in the vector for later use
		pStructContainerArray.push_back(pStruct);
		// register class type
		classTypeList.push_back(new SgClassType(pStruct->getStructSubTree()));
	}
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step6_2.dot");
	
	announceStep(5,0,"transform MPI-calls to SPIN-M-calls");
	MPISpinReplacement MPIreplacer;
	for (int i=0;i<procFuncVec.size();i++)
	{
//old:	MPIreplacer.replaceIn(procFuncVec[i],pStructContainerArray[i]->getPStructVarDeclaration());
		MPIreplacer.replaceIn(procFuncVec[i],pStructContainerArray[i]);
	}
	project->unparse();
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step5.dot");
	
	announceStep(6,3,"Identifying variables and putting them in the state-vector");
	for (int procNr=0;procNr<procFuncVec.size();procNr++)
	{
		// traverse over each promela-procedure and track wich variables are use.
		//later add those to the state vector. the variables that need to be in 
		// the state vector will be stored in an ast attribute attached to the 
		// function-definition...

		
		// Create the container that will contain the variables for the "promela-export"
		CStateASTAttrib * c_stateAttr=new CStateASTAttrib();
		
		// find all VariableDeclarations
		list<SgNode*> variableDeclarationList=NodeQuery::querySubTree(procFuncVec[procNr],V_SgVariableDeclaration);
		// this set will contain a variable declarations
		set<SgNode*> iniNameList;
		set<SgInitializedName *>cStateVariables;
	
	
		// the list in markedNodes contains all control nodes,
		// now traverse again and check variables
		for (list<SgNode*>::iterator it=
			variableDeclarationList.begin();
			it!=variableDeclarationList.end();
			it++)
		{
			// get the paren scope...
			SgNode * parentScopeTmp=*it;
			// get parents until we find the first scope
			while(!isSgScopeStatement(parentScopeTmp))
			{
				parentScopeTmp=parentScopeTmp->get_parent();
			}
			
			// tmp is now the next scope
			if (toConvert(parentScopeTmp))
			{
				// parent scope will be transforemd to promela -> block might be split up 
				// in mutliple c_blocks, and since varDecls don't carry accross c-blocks->statevec
				SgVariableDeclaration * decl=isSgVariableDeclaration(*it);

				// if the variable is promela-compatible and the parent scope is the scope form the procFuncVec -> no explicit state vector needed, can be keept in promela...
//				if (isPromelaCompatibleVariableType(decl))
//				{
					// ok, mark the variable as unparsable to promela...
//				}
//				else
//				{
					// add it the the state=ast-trribute
					cStateVariables.insert(decl->get_definition()->get_vardefn ());
					cout <<"converting "<<decl->get_definition()->get_vardefn ()->get_name ().getString()<<endl;
					markAsPromelaStateVar(decl);
					c_stateAttr->add(decl->get_definition()->get_vardefn () );
					cout <<"\t\t*added "<< decl->get_definition()->get_vardefn ()->get_name ().getString()<<" to the state-vector"<<endl;
					// remove the old variable-declaration
					LowLevelRewrite::remove(isSgStatement(decl));
					pStructContainerArray[procNr]->addVariable(decl);
//				}				
			}
			else
			{
				// the block is PURE c-> no promelastate will pass across its borders
				// therefore all variable-declaration within can be keept as is...
			}
				

		
			/*CI (4/19/2007) not all variable-uses need to be inc-block style, determine that later
			c_stateAttr->add(isSgInitializedName(*setIt));
			setStateVecVarAttrib(*setIt,new StateVecVarASTAttrib(true));*/
			// now force all nodes that contain a variable that is declared using the c_state stmt to be converted to c!!!!
			markStatementsWithCStateVariables(procFuncVec[procNr],cStateVariables);
			
		}
		// attach the c-state-attribute to the function-defintion
		setCStateAttrib(procFuncVec[procNr],c_stateAttr);
	}
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step6_3.dot");
	
	

	announceStep(6,4,"inserting promela proctype variable to the proc-functions");
	// * 3.4: insert the promela proctype variable to the proc-functions
	for (int i=0;i<procFuncVec.size();i++)
	{
	/*
		// create instance
		SgType * instanceType=classTypeList[i];
		
		Sg_File_Info * instanceFI=Sg_File_Info::generateDefaultFileInfoForTransformationNode();
		SgName instanceName=string("P")+(procFuncVec[i])->get_declaration()->get_name().getString()+"Instance";
		SgStatement * instanceVarDecl=new SgVariableDeclaration(instanceFI,instanceName,instanceType);
		procFuncVec[i]->get_body()->prepend_statement (instanceVarDecl);
		*/
		
		procFuncVec[i]->get_body()->prepend_statement (
			pStructContainerArray[i]->getPStructVarDeclaration()
			);
		// fix scope
		pStructContainerArray[i]->getPStructVarDeclaration()->get_definition()->get_vardefn ()->set_scope(procFuncVec[i]->get_body()->get_scope());

			
		procFuncVec[i]->get_body()->prepend_statement (
			pStructContainerArray[i]->getPStructVarInstanziationDeclaration()
			);
		pStructContainerArray[i]->getPStructVarInstanziationDeclaration()->get_definition()->get_vardefn ()->set_scope(procFuncVec[i]->get_body()->get_scope());
			
/*

		// creat ptr variable
		Sg_File_Info * initializerFI=Sg_File_Info::generateDefaultFileInfoForTransformationNode();
		SgVarRefExp * varRef=new  SgVarRefExp (
		Sg_File_Info::generateDefaultFileInfoForTransformationNode(),new SgVariableSymbol (isSgVariableDeclaration(instanceVarDecl)->get_definition()->get_vardefn ()));
		
		SgAddressOfOp *aof=new SgAddressOfOp (Sg_File_Info::generateDefaultFileInfoForTransformationNode(),isSgExpression(varRef),instanceType);
		SgInitializer * ptrInitializer= new	SgAssignInitializer(initializerFI,aof);
		*/
		/*
		Sg_File_Info * ptrFI=Sg_File_Info::generateDefaultFileInfoForTransformationNode();
//		ptrFI->setCompilerGenerated();
	//	ptrFI->unsetOutputInCodeGeneration ();
		SgType * pointerType=new SgPointerType (instanceType);
		SgName ptrName=string("P")+(procFuncVec[i])->get_declaration()->get_name().getString();
		SgStatement * ptrVarDecl=new SgVariableDeclaration(ptrFI,ptrName,pointerType);
		//SgStatement * ptrVarDecl=new SgVariableDeclaration(ptrFI,ptrName,pointerType,ptrInitializer);
		
		procFuncVec[i]->get_body()->prepend_statement (ptrVarDecl);
		procVariableList.push_back(isSgVariableDeclaration(ptrVarDecl));*/
//		procVariableList.push_back(pStructContainerArray[i]->getPStructVarDeclaration());
	}


	announceStep(6,5,"transform the use of variables in c_code-blocks to PROEMALs-callingconvetion");
	for (int i=0;i<procFuncVec.size();i++)
	{
		refactorSgVarRefExpInCBlocks(procFuncVec[i],pStructContainerArray[i]->getPStructVarDeclaration());
	}
	// since mpi-commands within promela will be transformned in by the promela-mpi-iunclude-> keep the in spin for the moment..., but a direct approach is also thinkable...
	{
	list<SgNode*> stmtList=NodeQuery::querySubTree(procFuncVec[0],V_SgStatement);
	// find all nodes which have beem tagged for promela-transformation
	for (list<SgNode*>::iterator stmtIt=stmtList.begin();stmtIt!=stmtList.end();stmtIt++)
	{
		if (isNodeMPI(*stmtIt) && !toConvert(*stmtIt))
		{
			markForPromelaTransformation(*stmtIt);
		}
	}
	}
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.Step6_5.dot");

	// *3.x finally remove return statements in all promela functions and replace them with a goto to the end of that function body
	announceStep(6,6,"remove all return-statements and replace with goto-statenents");
	for (int i=0;i<procFuncVec.size();i++)
	{
		removeReturnStmts(procFuncVec[i]);
	}

	// 4.x mark AST for unparse, adding astattributes
	announceStep(6,7,"final PROMELA-attribute propagation");
	MarkAST4Unparse finalMarker;
	finalMarker.traverse(project);
	
	// add mpi include and pp-directives
	if (MPIreplacer.getNrOfMPICalls()>0)
	{
		announceStep(6,8,"MPI-touchup. Add the SPIN-M #include mpi-spin.prom directive adn the active MPI_PROC");	
		cout <<"\t\t*found "<<MPIreplacer.getNrOfMPICalls()<<" MPI-calls"<<endl;

		SgGlobal * globalNode=NULL;
		SgNode * tmp=procFuncVec[0];
		while(!isSgGlobal(tmp)) tmp=tmp->get_parent();
		globalNode=isSgGlobal(tmp);

		if (globalNode->get_attachedPreprocessingInfoPtr ()==NULL)
			globalNode->set_attachedPreprocessingInfoPtr(new AttachedPreprocessingInfoType());

		PreprocessingInfo  * spinInclude=new PreprocessingInfo(PreprocessingInfo::CpreprocessorIncludeDeclaration,string("#include \"mpi-spin.prom\""),"user-generated",0,0,0,PreprocessingInfo::before,false,false);
		globalNode->addToAttachedPreprocessingInfo(spinInclude);


		PreprocessingInfo  * activeMPI_PROC=new PreprocessingInfo(PreprocessingInfo::CpreprocessorIncludeDeclaration,string("active MPI_PROC"),"user-generated",0,0,0,PreprocessingInfo::after,false,false);
		globalNode->addToAttachedPreprocessingInfo(activeMPI_PROC);
	}

	cout <<"*--------------------------------*\n\tstep 7->unparse\n*--------------------------------*"<<endl;	
	announceStep(7,0,"unparsing mixed ast");
	// output the dot-grpah
	AstDOTGeneration dotgen;
	dotgen.generateInputFiles(project,AstDOTGeneration::PREORDER);
	// set4: assert that the promela-part is valid
	// Step4: unparse project to C/Promela
//	Unparser_Opt options;
//	ofstream * out=new ofstream("main.pml");
//	CToProMeLaUnparser unparser(out,string("main.pml"),options,0);
//	SgUnparse_Info info;
//	cout <<" Test of unparser. Filename is "<<unparser.getFileName()<<endl;
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.1.dot");
	
	cout <<"unparing to C"<<endl;
	project->unparse();
	for (int i=0;i<procFuncVec.size();i++)
		pStructContainerArray[i]->hideShugar();
	cout << "unparsing to Promela"<<endl;
	unparsePromelaProject(project,NULL,NULL);

//unnparser.
//	unparser.run_unparser();
//	unparseProject(project);
//	unparser.unparseProject(project,info);
	
	return 0;
}
Ejemplo n.º 21
0
int
main (int argc, char *argv[])
{
  vector<string> argvList(argv, argv+argc);
  //Processing debugging and annotation options
  //  autopar_command_processing(argvList);
  argvList = commandline_processing (argvList);
  // enable parsing user-defined pragma if enable_diff is true
  // -rose:openmp:parse_only
  if (enable_diff)
    argvList.push_back("-rose:openmp:parse_only");
  SgProject *project = frontend (argvList);
  ROSE_ASSERT (project != NULL);

  // register midend signal handling function
  if (KEEP_GOING_CAUGHT_MIDEND_SIGNAL)
  {
    std::cout
      << "[WARN] "
      << "Configured to keep going after catching a "
      << "signal in AutoPar"
      << std::endl;
    Rose::KeepGoing::setMidendErrorCode (project, 100);
    goto label_end;
  }   

  // create a block to avoid jump crosses initialization of candidateFuncDefs etc.
  {                             
    std::vector<SgFunctionDefinition* > candidateFuncDefs; 
    findCandidateFunctionDefinitions (project, candidateFuncDefs);
    normalizeLoops (candidateFuncDefs);

    //Prepare liveness analysis etc.
    //Too much output for analysis debugging info.
    //initialize_analysis (project,enable_debug);   
    initialize_analysis (project, false);   

    // This is a bit redundant with findCandidateFunctionDefinitions ()
    // But we do need the per file control to decide if omp.h is needed for each file
    //
    // For each source file in the project
    SgFilePtrList & ptr_list = project->get_fileList();
    for (SgFilePtrList::iterator iter = ptr_list.begin(); iter!=ptr_list.end();
        iter++)
    {
      SgFile* sageFile = (*iter);
      SgSourceFile * sfile = isSgSourceFile(sageFile);
      ROSE_ASSERT(sfile);
      SgGlobal *root = sfile->get_globalScope();

      Rose_STL_Container<SgNode*> defList = NodeQuery::querySubTree(sfile, V_SgFunctionDefinition); 
      bool hasOpenMP= false; // flag to indicate if omp.h is needed in this file

      //For each function body in the scope
      //for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) 
      for (Rose_STL_Container<SgNode*>::iterator p = defList.begin(); p != defList.end(); ++p) 
      {

        //      cout<<"\t loop at:"<< cur_loop->get_file_info()->get_line() <<endl;

        SgFunctionDefinition *defn = isSgFunctionDefinition(*p);
        ROSE_ASSERT (defn != NULL);

        SgFunctionDeclaration *func = defn->get_declaration();
        ROSE_ASSERT (func != NULL);

        //ignore functions in system headers, Can keep them to test robustness
        if (defn->get_file_info()->get_filename()!=sageFile->get_file_info()->get_filename())
        {
          continue;
        }

        SgBasicBlock *body = defn->get_body();  
        // For each loop 
        Rose_STL_Container<SgNode*> loops = NodeQuery::querySubTree(defn,V_SgForStatement); 
        if (loops.size()==0) 
        {
          if (enable_debug)
            cout<<"\t skipped since no for loops are found in this function"<<endl;
          continue;
        }

#if 0 // Moved to be executed before running liveness analysis.
        // normalize C99 style for (int i= x, ...) to C89 style: int i;  (i=x, ...)
        // Liao, 10/22/2009. Thank Jeff Keasler for spotting this bug
        for (Rose_STL_Container<SgNode*>::iterator iter = loops.begin();
            iter!= loops.end(); iter++ )
        {
          SgForStatement* cur_loop = isSgForStatement(*iter);
          ROSE_ASSERT(cur_loop);
          SageInterface::normalizeForLoopInitDeclaration(cur_loop);
        }
#endif
        // X. Replace operators with their equivalent counterparts defined 
        // in "inline" annotations
        AstInterfaceImpl faImpl_1(body);
        CPPAstInterface fa_body(&faImpl_1);
        OperatorInlineRewrite()( fa_body, AstNodePtrImpl(body));

        // Pass annotations to arrayInterface and use them to collect 
        // alias info. function info etc.  
        ArrayAnnotation* annot = ArrayAnnotation::get_inst(); 
        ArrayInterface array_interface(*annot);
        array_interface.initialize(fa_body, AstNodePtrImpl(defn));
        array_interface.observe(fa_body);

        //FR(06/07/2011): aliasinfo was not set which caused segfault
        LoopTransformInterface::set_aliasInfo(&array_interface);

        for (Rose_STL_Container<SgNode*>::iterator iter = loops.begin(); 
            iter!= loops.end(); iter++ ) 
        {
          SgNode* current_loop = *iter;

          if (enable_debug)
          {
            SgForStatement * fl = isSgForStatement(current_loop);
            cout<<"\t\t Considering loop at "<< fl->get_file_info()->get_line()<<endl;
          }
          //X. Parallelize loop one by one
          // getLoopInvariant() will actually check if the loop has canonical forms 
          // which can be handled by dependence analysis
          SgInitializedName* invarname = getLoopInvariant(current_loop);
          if (invarname != NULL)
          {
            bool ret = ParallelizeOutermostLoop(current_loop, &array_interface, annot);
            if (ret) // if at least one loop is parallelized, we set hasOpenMP to be true for the entire file.
              hasOpenMP = true;  
          }
          else // cannot grab loop index from a non-conforming loop, skip parallelization
          {
            if (enable_debug)
              cout<<"Skipping a non-canonical loop at line:"<<current_loop->get_file_info()->get_line()<<"..."<<endl;
            // We should not reset it to false. The last loop may not be parallelizable. But a previous one may be.  
            //hasOpenMP = false;
          }
        }// end for loops
      } // end for-loop for declarations

      // insert omp.h if needed
      if (hasOpenMP && !enable_diff)
      {
        SageInterface::insertHeader("omp.h",PreprocessingInfo::after,false,root);
        if (enable_patch)
          generatePatchFile(sfile); 
      }
      // compare user-defined and compiler-generated OmpAttributes
      if (enable_diff)
        diffUserDefinedAndCompilerGeneratedOpenMP(sfile); 
    } //end for-loop of files

#if 1
    // undo loop normalization
    std::map <SgForStatement* , bool >::iterator iter = trans_records.forLoopInitNormalizationTable.begin();
    for (; iter!= trans_records.forLoopInitNormalizationTable.end(); iter ++) 
    {
      SgForStatement* for_loop = (*iter).first; 
      unnormalizeForLoopInitDeclaration (for_loop);
    }
#endif
    // Qing's loop normalization is not robust enough to pass all tests
    //AstTests::runAllTests(project);


    // clean up resources for analyses
    release_analysis();
  }

label_end: 
  // Report errors
  if (keep_going)
  {
    std::vector<std::string> orig_rose_cmdline(argv, argv+argc);
    Rose::KeepGoing::generate_reports (project, orig_rose_cmdline);
  }

  //project->unparse();
  return backend (project);
}
Ejemplo n.º 22
0
// schroder3 (2016-07-12): Returns the mangled stable/portable scope of the given statement.
//  FIXME: There are some places (see comment below) in the rose mangling which add the address
//  of the AST node to the mangled name. Due to this, this function currently does not return
//  a stable/portable mangled scope in all cases.
string getScopeAsMangledStableString(SgLocatedNode* stmt) {
  SgNode* parent = stmt;
  // Go up in the AST and look for the closest scope of the given statement:
  while((parent = parent->get_parent())) {
    SgStatement* declScope = 0;
    // Look for a FunctionParameterList or a ScopeStatement:
    if(SgFunctionParameterList* functionParams = isSgFunctionParameterList(parent)) {
      // Special case: Function parameter: The scope is
      //  the corresponding function definition/declaration:
      //  Function declaration is enough, because we only need the function
      //  name and types to create the mangled scope.
      declScope = isSgFunctionDeclaration(functionParams->get_parent());
      ROSE_ASSERT(declScope);
    }
    else if(SgScopeStatement* scope = isSgScopeStatement(parent)) {
      declScope = scope;
    }

    if(declScope) {
      // Found the scope of the given statement.

      // In theory it should work by using
      //   return mangleQualifiersToString(declScope);
      //  but there are the following problems in functions that get called by mangleQualifiersToString(...):
      //   1) SgFunctionDeclaration::get_mangled_name() mangles every function with the name "main" (even
      //      those that are not in the global scope) as
      //       main_<address of the AST node>
      //      .
      //   2) SgTemplateArgument::get_mangled_name(...) adds the address of a AST node to the mangled
      //      name if the template argument is a type and it's parent is a SgTemplateInstantiationDecl.
      //  Especially because of the address we can not use this as a portable scope representation.
      //
      // Workaround for 1): Replace the name of every function definition/declaration that has the name "main" and that
      //  is a direct or indirect scope parent of declScope by a temporary name that is different from "main".
      //  Then use mangleQualifiersToString(...) to mangle the scope. Finally, replace occurrences of the
      //  temporary name in the mangled-scope by "main".
      //
      // Workaround for 2): Currently none.

      // Workaround for 1):
      string tempName = string("(]"); // Something that does not appear in a function or operator name.
      SgName tempSgName = SgName(tempName);
      SgName mainSgName = SgName("main");
      vector<SgFunctionDeclaration*> main_func_decls;
      SgStatement* scopeParent = declScope;
      // Collect all functions that have "main" as their name and replace their name
      //  by the temporary name:
      while((scopeParent = scopeParent->get_scope()) && !isSgGlobal(scopeParent)) {
        SgFunctionDefinition* funcDef = isSgFunctionDefinition(scopeParent);
        if(SgFunctionDeclaration* funcDecl = funcDef ? funcDef->get_declaration() :0) {
          if(funcDecl->get_name() == tempSgName) {
            // There is a function whose name contains tempName. The mangled scope
            //  will probably be wrong:
            throw SPRAY::Exception("Found function whose name contains the reserved text \"" + tempName + "\". "
                                   "Mangling of scope is not possible.");
          }
          else if(funcDecl->get_name() == mainSgName) {
            main_func_decls.push_back(funcDecl);
            funcDecl->set_name(tempSgName);
          }
        }
      }

      // Create the mangled-scope:
      string mangled_scope;
      if(SgFunctionDeclaration* fundDecl = isSgFunctionDeclaration(declScope)) {
        // Special case: A function decl node is not a scope statement:
        mangled_scope = fundDecl->get_mangled_name();
      }
      else if(SgScopeStatement* scope = isSgScopeStatement(declScope)) {
        mangled_scope = mangleQualifiersToString(scope);
      }
      else {
        ROSE_ASSERT(false);
      }

      // Replace occurrences of the temporary name in the mangled-scope
      //  by "main" and restore the previous name ("main") of the functions:
      for(vector<SgFunctionDeclaration*>::const_iterator i = main_func_decls.begin();
          i != main_func_decls.end(); ++i
      ) {
          (*i)->set_name(mainSgName);
          size_t start = mangled_scope.find(tempName);
          // TODO: Functions and local classes (and more?) are mangled as L0R, L1R, ... and not with their
          //  scope. Because of that, there is no corresponding temporary name in
          //  the mangled-scope sometimes:
          if(start != string::npos) {
            mangled_scope.replace(start, tempName.length(), string("main"));
          }
      }
      if(mangled_scope.find(tempName) != string::npos) {
        // There is a function whose name contains tempName. Because we abort above if there is such a function
        //  this should not happen.
        ROSE_ASSERT(false);
      }
      return mangled_scope;
    }
  }
  return string("");
}
Ejemplo n.º 23
0
int main(int argc, char * argv[]) 
{       
        // Build the AST used by ROSE
        project = frontend(argc,argv);
        
        /*convertToOMPNormalForm(project, project);
        
        // Run internal consistancy tests on AST
        AstTests::runAllTests(project); 
        
        Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
        for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) {
                SgFunctionDefinition* func = isSgFunctionDefinition(*i);
                ROSE_ASSERT(func);
        
                printf("func = %s\n", func->unparseToString().c_str());
                
                // output the CFG to a file
                ofstream fileCFG;
                fileCFG.open((func->get_declaration()->get_name().getString()+"_cfg.dot").c_str());
                cout << "    writing to file "<<(func->get_declaration()->get_name().getString()+"_cfg.dot")<<"\n";
                cfgToDot(fileCFG, func->get_declaration()->get_name(), func->cfgForBeginning());
                fileCFG.close();
        }
        
        backend(project);*/
        
        //generatePDF ( *project );
        
        // find a declaration for foo()
        Rose_STL_Container<SgNode*> funcDecls = NodeQuery::querySubTree(project, V_SgFunctionDeclaration);      
        for(Rose_STL_Container<SgNode*>::iterator it = funcDecls.begin(); it!=funcDecls.end(); it++)
        {
                SgFunctionDeclaration* decl = isSgFunctionDeclaration(*it); ROSE_ASSERT(decl);
                if(decl->get_name().getString() == "foo")
                {
                        fooDecl = decl;
                        break;
                }
        }
        if(!fooDecl) { printf("ERROR: could not find declaration of function foo()!\n"); numFails++; }
        
        testParsing();
                
        convertToOMPNormalForm(project, project);
        
        testOMPForSensitiveInsertion();
        
        AstTests::runAllTests(project);
        
        insertTopBottomOmpDirectives(project, ompUtils::omp_critical, true, &fooCallStmtCreate);
        insertTopBottomOmpDirectives(project, ompUtils::omp_single, false, &fooCallStmtCreate);
        
        // Run internal consistancy tests on AST
        //
        
        // Generate the CFGs of all the functions to ensure that all CFG data is good
        Rose_STL_Container<SgNode*> functions = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
        for (Rose_STL_Container<SgNode*>::const_iterator i = functions.begin(); i != functions.end(); ++i) {
                SgFunctionDefinition* func = isSgFunctionDefinition(*i);
                ROSE_ASSERT(func);
        
                printf("func = %s\n", func->unparseToString().c_str());
                
                // output the CFG to a file
                ofstream fileCFG;
                fileCFG.open((func->get_declaration()->get_name().getString()+"_cfg.dot").c_str());
                cout << "    writing to file "<<(func->get_declaration()->get_name().getString()+"_cfg.dot")<<"\n";
                cfgToDot(fileCFG, func->get_declaration()->get_name(), func->cfgForBeginning());
                fileCFG.close();
        }
        
        backend(project);
        system("diff rose_test_example.c test_example.valid_rose_output.c > selfTest.out");
        struct stat file;
   stat("selfTest.out",&file);
        if(file.st_size!=0)
        {
                printf("Error: found differences between rose_test_example.c and the canonical test_example.valid_rose_output.c! Details in selfTest.out.\n");
                numFails++;
        }
        
        if(numFails==0) 
                cout << "PASSED\n";
        else
                cout << "FAILED!\n";
}
Ejemplo n.º 24
0
void testOneFunction( std::string funcParamName,
		      vector<string> argvList,
		      bool debug, int nrOfNodes,
		      multimap <int, vector<string> >  resultsIn,
		      multimap <int, vector<string> > resultsOut) {
  cout << " \n\n------------------------------------------\nrunning (variable)... " << argvList[1] << endl;

  // Build the AST used by ROSE
  SgProject* project = frontend(argvList);
  // Call the Def-Use Analysis
  DFAnalysis* defuse = new DefUseAnalysis(project);
  int val = defuse->run(debug);
  if (debug)
    std::cerr << ">Analysis run is : " << (val ?  "failure" : "success" ) << " " << val << std::endl;
  if (val==1) exit(1);

  if (debug==false)
    defuse->dfaToDOT();


  LivenessAnalysis* liv = new LivenessAnalysis(debug,(DefUseAnalysis*)defuse);

  std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions;
  NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
  NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
  bool abortme=false;
  int hitIn=0;
  int hitOut=0;
  for (; i!=vars.end();++i) {
    SgFunctionDefinition* func = isSgFunctionDefinition(*i);
    std::string name = func->class_name();
    string funcName = func->get_declaration()->get_qualified_name().str();
    if (debug)
      cerr << " .. running live analysis for func : " << funcName << endl;
    FilteredCFGNode <IsDFAFilter> rem_source = liv->run(func,abortme);
    if (abortme)
      break;
    if (funcName!=funcParamName) {
      if (debug)
        cerr << "    .. skipping live analysis check for func : " << funcName << endl;
      continue;
    }
    if (rem_source.getNode()!=NULL)
      dfaFunctions.push_back(rem_source);

    NodeQuerySynthesizedAttributeType nodes = NodeQuery::querySubTree(func, V_SgNode);

    // Edg3 mistakenly adds SgType nodes to the AST; Edg4 adds some also, but fewer.  So we just remove them all. They
    // make no difference in the variable-liveness analysis anyway.
    nodes.erase(std::remove_if(nodes.begin(), nodes.end(), is_type_node), nodes.end());

    SgFunctionDeclaration* decl = isSgFunctionDeclaration(func->get_declaration());
    ROSE_ASSERT(decl);
    Rose_STL_Container<SgInitializedName*> args = decl->get_parameterList()->get_args();
    if (debug)
      cerr <<"Found args : " << args.size() << endl;
    Rose_STL_Container<SgInitializedName*>::const_iterator it = args.begin();
    for (;it!=args.end();++it) {
      nodes.push_back(*it);
    }
    if((int)nodes.size()-1!=nrOfNodes) {
      cerr << "Error :: Number of nodes = " << nodes.size()-1 << "  should be : " << nrOfNodes << endl;
      exit(1);
    } else {
      if (debug)
    	cerr << "Investigating nodes : " << nodes.size() << endl;
    }
    NodeQuerySynthesizedAttributeType::const_iterator nodesIt = nodes.begin();
    for (; nodesIt!=nodes.end();++nodesIt) {
      SgNode* node = *nodesIt;
      ROSE_ASSERT(node);
      int tableNr = defuse->getIntForSgNode(node);
      std::vector<SgInitializedName*> in = liv->getIn(node);
      std::vector<SgInitializedName*> out = liv->getOut(node);

      std::vector<string> inName;
      std::vector<string> outName;
      std::vector<SgInitializedName*>::const_iterator itv = in.begin();
      for (;itv!=in.end();++itv) {
	SgInitializedName* init = *itv;
	string name = init->get_name();
	inName.push_back(name);
      }
      itv = out.begin();
      for (;itv!=out.end();++itv) {
	SgInitializedName* init = *itv;
	string name = init->get_name();
	outName.push_back(name);
      }
      std::sort(inName.begin(), inName.end());
      std::sort(outName.begin(), outName.end());

      multimap <int, vector<string> >::const_iterator k =resultsIn.begin();
      for (;k!=resultsIn.end();++k) {
	int resNr = k->first;
	vector<string> results = k->second;
	if (debug)
      	  cerr << "   ... containing nodes : " << results.size() << " node: " << node->class_name()
               << "   tableNr : " << tableNr
               << "  resNr : " << resNr << endl;
	if (tableNr==resNr) {
	  std::sort(results.begin(), results.end());
	  if (results==inName) {
	    if (debug)
	      cerr <<"Contents in IN vector is correct! " << endl;
	  } else {
	    if (debug) {
	      cerr << " >>>>>>>>>> Problem with contents for IN ! " << endl;
	      cerr << " >>>>>>>>>> RESULT ... " << endl;
	    }
	    std::vector<string>::const_iterator itv = inName.begin();
	    for (;itv!=inName.end();++itv) {
	      string name = *itv;
	      if (debug)		cerr << name << " " ;
	    }
	    if (debug) {
	      cerr << endl;
	      cerr << " >>>>>>>>>> USER ... " << endl;
	    }
	    itv = results.begin();
	    for (;itv!=results.end();++itv) {
	      string name = *itv;
	      if (debug)	cerr << name << " " ;
	    }
	    if (debug) {
	      cerr << endl;
	    }
	    exit(1);
	  }
	  if (results.size()==in.size()) {
	    hitIn++;
	  }
	  if (debug)
	    cout << " nodeNr: " << tableNr << ".  ResultSize IN should be:" << results.size()
                 << " -  resultSize is: " << in.size()
                 << "  foundMatches == : " << hitIn << "/" << resultsIn.size() << endl;
        }
      }
      k =resultsOut.begin();
      for (;k!=resultsOut.end();++k) {
	int resNr = k->first;
	vector<string> results = k->second;
	//    	  cerr << "   ... containing nodes : " << results.size() << "   tableNr : " << tableNr <<
	//			  "  resNr : " << resNr << endl;
	if (tableNr==resNr) {
	  std::sort(results.begin(), results.end());
	  if (results==outName) {
	    if (debug)
	      cerr <<"Contents in OUT vector is correct! " << endl;
	  } 	     else {
	    if (debug) {
	      cerr << " >>>>>>>>>> Problem with contents for OUT ! " << endl;
	      cerr << " >>>>>>>>>> RESULT ... " << endl;
	    }
	    std::vector<string>::const_iterator itv = outName.begin();
	    for (;itv!=outName.end();++itv) {
	      string name = *itv;
	      if (debug)		cerr << name << " " ;
	    }
	    if (debug) {
	      cerr << endl;
	      cerr << " >>>>>>>>>> USER ... " << endl;
	    }
	    itv = results.begin();
	    for (;itv!=results.end();++itv) {
	      string name = *itv;
	      if (debug)					
		cerr << name << " " ;
	    }
	    if (debug)
	      cerr << endl;
	    exit(1);
	  }

	  if (results.size()==out.size()) {
	    hitOut++;
	  }
	  if (debug)
	    cout << " nodeNr: " << tableNr << ".  ResultSize OUT should be:" << results.size()
                 << " -  resultSize is: " << out.size()
                 << "  foundMatches == : " << hitOut << "/" << resultsOut.size() << endl;
        }
      }
      if (hitIn==0 && hitOut==0) {
	if (debug)
	  cout << " nodeNr: " << tableNr << " IN: " << hitIn << "/" << resultsIn.size() <<
	    "        Out:" << hitOut << "/" << resultsOut.size() << endl;
      }
    }
    if (hitIn!=(int)resultsIn.size() || hitOut!=(int)resultsOut.size()) {
      cout << " Error: No hit! ... DFA values of node " << nrOfNodes << " are not correct! " << endl;
      exit(1);
    }

  }
  if (debug)
    cerr << "Writing out to var.dot... " << endl;
  std::ofstream f2("var.dot");
  dfaToDot(f2, string("var"), dfaFunctions,
           (DefUseAnalysis*)defuse, liv);
  f2.close();

  if (abortme) {
    cerr<<"ABORTING ." << endl;
    ROSE_ASSERT(false);
    //    exit(1);
  }

  // iterate again and write second var.dot file
  i = vars.begin();
  abortme=false;
  std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions2;
  for (; i!=vars.end();++i) {
    SgFunctionDefinition* func = isSgFunctionDefinition(*i);
    std::string name = func->class_name();
    string funcName = func->get_declaration()->get_qualified_name().str();
    if (debug)
      cerr << " .. running live analysis for func (fixupStatementsINOUT): " << funcName << endl;
    FilteredCFGNode <IsDFAFilter> rem_source = liv->run(func,abortme);
    liv->fixupStatementsINOUT(func);
    if (rem_source.getNode()!=NULL)
      dfaFunctions2.push_back(rem_source);

  }
  if (debug)
    cerr << "Writing out to varFix.dot... " << endl;
  std::ofstream f3("varFix.dot");
  dfaToDot(f3, string("varFix"), dfaFunctions2,
           (DefUseAnalysis*)defuse, liv);
  f3.close();

  if (debug)
    std::cout << "Analysis test is success." << std::endl;
}
Ejemplo n.º 25
0
int main( int argc, char * argv[] )
   {
  // Build the AST used by ROSE
     SgProject* project = frontend(argc,argv);
     ROSE_ASSERT(project != NULL);

  // Build a list of functions within the AST and find all access functions 
  // (function name starts with "get_" or "set_")

  // Build list using a query of the whole AST
     Rose_STL_Container<SgNode*> functionDefinitionList = NodeQuery::querySubTree (project,V_SgFunctionDefinition);

  // Build list using nested Queries (operating on return result of previous query)
  //   Rose_STL_Container<SgNode*> accessFunctionsList;
  //   accessFunctionsList = NodeQuery::queryNodeList (functionDeclarationList,&querySolverAccessFunctions);
  //   printFunctionDeclarationList(accessFunctionsList);

  // Alternative form of same query building the list using a query of the whole AST
   //  accessFunctionsList = NodeQuery::querySubTree (project,&querySolverAccessFunctions);
   //  printFunctionDeclarationList(accessFunctionsList);
int counter = 0;
for (Rose_STL_Container<SgNode*>::iterator i = functionDefinitionList.begin(); i != functionDefinitionList.end(); i++) {
   SgFunctionDefinition* fnc = isSgFunctionDefinition(*i);
  stringstream ss; 
  SgFunctionDeclaration* functionDeclaration = fnc->get_declaration();
  string fileName= functionDeclaration->get_name().str();//StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
    string dotFileName1;
ss << fileName << "." << counter << ".dot";
    counter++;
    dotFileName1 = ss.str();
    //SgFunctionDefinition* fnc = functionDeclaration->get_definition();
    if (fnc != NULL) {
    StaticCFG::CFG* cfg = new StaticCFG::CFG(fnc);
    SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();
     visitorTraversal* vis = new visitorTraversal();
    g = cfg->getGraph();
    myGraph* mg = new myGraph();
    mg = instantiateGraph(g, (*cfg));
    vis->tltnodes = 0;
    vis->paths = 0;
 std::cout << dotFileName1 << std::endl;
 cfgToDot(fnc,dotFileName1);
    //vis->firstPrepGraph(constcfg);
    //t1 = getCPUTime();
    vis->constructPathAnalyzer(mg, true, 0, 0, true);
    
    //t2 = getCPUTim
    std::cout << "function: " << fileName << std::endl;
    std::cout << "paths: " << vis->paths << std::endl;
    delete vis;
    delete cfg;
    delete g;
    delete mg;
    //std::cout << "took: " << timeDifference(t2, t1) << std::endl;
    }
    }
   SgProject* proj = project; 
   SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);
   if (mainDefDecl != NULL) {
  SgFunctionDefinition* mainDef = mainDefDecl->get_definition();
   visitorTraversal* vis = new visitorTraversal();
    StaticCFG::CFG cfg(mainDef);
   //cfg.buildFullCFG();
    stringstream ss;
    string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
    string dotFileName1=fileName+"."+ mainDef->get_declaration()->get_name() +".dot";

    cfgToDot(mainDef,dotFileName1);
    //cfg->buildFullCFG();
    SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();
    g = cfg.getGraph();
    myGraph* mg = new myGraph();
    mg = instantiateGraph(g, cfg);
    vis->tltnodes = 0;
    vis->paths = 0;
    //vis->firstPrepGraph(constcfg);
    vis->constructPathAnalyzer(mg, true, 0, 0, true);
    //std::cout << "took: " << timeDifference(t2, t1) << std::endl;
    //cfg.clearNodesAndEdges();
    std::cout << "finished" << std::endl;
    std::cout << "tltnodes: " << vis->tltnodes << " paths: " << vis->paths << std::endl;
    //std::cout << "ipaths: " << ipaths << std::endl;
    delete vis;

    }

// Another way to query for collections of IR nodes
     VariantVector vv1 = V_SgClassDefinition;
     std::cout << "Number of class definitions in the memory pool is: " << NodeQuery::queryMemoryPool(vv1).size() << std::endl;

  // Another way to query for collections of multiple IR nodes.
  // VariantVector(V_SgType) is internally expanded to all IR nodes derived from SgType.
     VariantVector vv2 = VariantVector(V_SgClassDefinition) + VariantVector(V_SgType);
     std::cout << "Number of class definitions AND types in the memory pool is: " << NodeQuery::queryMemoryPool(vv2).size() << std::endl;

  // Note: Show composition of AST queries

     return 0;
   }
Ejemplo n.º 26
0
int main(int argc, char *argv[]) {
  ss << "#include \"SgGraphTemplate.h\"\n";
  ss << "#include \"graphProcessing.h\"\n";
  ss << "#include \"staticCFG.h\"\n";
  ss << "using namespace std;\n";
  ss << "using namespace boost;\n";






  //ss << "set<vector<string> >  sssv;\n";
  //ss << "vector<string> sss;\n";
  ss << "typedef myGraph CFGforT;\n";

  
  SgProject* proj = frontend(argc,argv);
  ROSE_ASSERT (proj != NULL);

  SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);

  SgFunctionDefinition* mainDef = mainDefDecl->get_definition();
   visitorTraversal* vis = new visitorTraversal();
    StaticCFG::CFG cfg(mainDef);


//    stringstream ss;
    string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());
    string Cfilename = fileName+"."+ mainDef->get_declaration()->get_name() +"test.C";
    
   // cfgToDot(mainDef,dotFileName1);
    //cfg->buildFullCFG();
    SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();
    g = cfg.getGraph();
    myGraph* mg = new myGraph();
    mg = instantiateGraph(g, cfg);
    //vis->constructPathAnalyzer(mg, true, 0, 0, true);

   // std::cout << "took: " << timeDifference(t2, t1) << std::endl;
    //cfg.clearNodesAndEdges();
    //std::cout << "finished" << std::endl;
 //   std::cout << "tltnodes: " << vis->tltnodes << " paths: " << vis->paths << std::endl;
 //   delete vis;
//}


ss << "class visitorTraversal : public SgGraphTraversal<CFGforT>\n";
ss << "  {\n";
ss << "     public:\n";
ss << "     vector<string> sss;\n";
ss << "     set<vector<string> > sssv;\n";
//vis->constructPathAnalyzer(mg, true, 0, 0, true);
ss << "         void analyzePath(std::vector<VertexID>& pth);\n";
ss << "         SgIncidenceDirectedGraph* g;\n";
ss << "          myGraph* orig;\n";
ss << "          StaticCFG::CFG* cfg;\n";
ss << "          std::vector<std::vector<string> > paths;\n";
ss << "   };\n";

ss << "void visitorTraversal::analyzePath(std::vector<VertexID>& pathR) {\n";
ss << "    std::vector<string> path;\n";
ss << "   for (unsigned int j = 0; j < pathR.size(); j++) {\n";
ss << "       SgGraphNode* R = getGraphNode[pathR[j]];\n";
ss << "      CFGNode cf = cfg->toCFGNode(R);\n";
ss << "       string str = cf.toString();";
ss << "str.erase(std::remove(str.begin(), str.end(), '\\n'), str.end());\n";

ss << "       path.push_back(str);\n";
ss << "    }\n";
ss << "    paths.push_back(path);\n";
ss << "   // ROSE_ASSERT(sssv.find(path) != sssv.end());\n";

ss << "}\n";

//ss << "set<vector<string> > sssv;\n";

ss << "int main(int argc, char *argv[]) {\n";
ss << "SgProject* proj = frontend(argc,argv);\n";
ss << "ROSE_ASSERT (proj != NULL);\n";
ss << "SgFunctionDeclaration* mainDefDecl = SageInterface::findMain(proj);\n";
ss << "SgFunctionDefinition* mainDef = mainDefDecl->get_definition();\n";
ss << "visitorTraversal* vis = new visitorTraversal();\n";
ss << "StaticCFG::CFG cfg(mainDef);\n";
ss << "stringstream ss;\n";
ss << "string fileName= StringUtility::stripPathFromFileName(mainDef->get_file_info()->get_filenameString());\n";
ss << "string dotFileName1=fileName+\".\"+ mainDef->get_declaration()->get_name() +\".dot\";\n";
ss << "cfgToDot(mainDef,dotFileName1);\n";
ss << "SgIncidenceDirectedGraph* g = new SgIncidenceDirectedGraph();\n";
ss << "g = cfg.getGraph();\n";
ss << "myGraph* mg = new myGraph();\n";
ss << "mg = instantiateGraph(g, cfg);\n";
//ss << "vis->tltnodes = 0;\n";
//ss << "vis->paths = 0;\n";
ss << "std::set<std::vector<string> > sssv;\n";
ss << "std::vector<string> sss;\n";
vis->constructPathAnalyzer(mg, true, 0, 0, true);
ss << "vis->sssv = sssv;\n";
ss << "vis->constructPathAnalyzer(mg, true, 0, 0, true);\n";
ss << "ROSE_ASSERT(vis->sssv.size() == vis->paths.size());\n";
ss << "std::cout << \"finished\" << std::endl;\n";
ss << "std::cout << \" paths: \" << vis->paths.size() << std::endl;\n";
ss << "delete vis;\n";
ss << "}\n";
string sst = ss.str();
ofstream myfile;
myfile.open(Cfilename.c_str());
myfile << sst;
myfile.close();
delete vis;
return 0;
}
Ejemplo n.º 27
0
Archivo: traceCPU.C Proyecto: 8l/rose
int main (int argc, char *argv[])
{
   /* indicate whether include files need to be added */
   bool loopTransformApplied = false ;

   /* more bools at top of file... */
   bool withPAPI = false ;
   bool showStats = false ;
   bool enablePostProcessing = false ;

   /***********************************************/
   /* Process command line options                */
   /***********************************************/

   Rose_STL_Container<string> cmdLineArgs =
     CommandlineProcessing::generateArgListFromArgcArgv(argc,argv) ;

   if ( CommandlineProcessing::isOption(
           cmdLineArgs, "-et:", "(s|stats)", true) )
   {
     showStats = true ;
   }
   if ( CommandlineProcessing::isOption(
           cmdLineArgs, "-et:", "(p|papi)", true) )
   {
     withPAPI = true ;
   }
   if ( CommandlineProcessing::isOption(
           cmdLineArgs, "-et:", "(l|loops)", true) )
   {
     emitSeqSeg = false ;
   }
   if ( CommandlineProcessing::isOption(
           cmdLineArgs, "-et:", "noiter", true) )
   {
     countIters = false ;
   }
   if ( CommandlineProcessing::isOption(
           cmdLineArgs, "-et:", "fast", true) )
   {
     fullLoopStat = false ;
     emitSeqSeg   = false ;
     countIters   = false ;
     withPAPI     = false ;
     enablePostProcessing = true ;
   }

   dumpFunc = (showStats ? "ET_LogStats" : "ET_Dump") ;

   /***********************************************/
   /*               Invoke ROSE                   */
   /***********************************************/

   /* build AST */
   SgProject* project = frontend(argc, argv);
   ROSE_ASSERT(project);

   if (project->get_fileList().empty() == false) {

     /* make sure AST is well formed */
     AstTests::runAllTests(project);

     /* set up some needed typedefs for runtime support */

     SgGlobal *globalScope = SageInterface::getFirstGlobalScope(project) ;
     ETtype = buildTypedefDeclaration("ET_Idx_t", buildShortType(), globalScope)->get_type() ;

     /* insert probes into each function in this file */

     Rose_STL_Container<SgNode*> funcDefs =
         NodeQuery::querySubTree(project, V_SgFunctionDefinition) ;

     for (Rose_STL_Container<SgNode*>::iterator f_itr = funcDefs.begin();
                f_itr != funcDefs.end(); ++f_itr)
     {
        SgFunctionDefinition *funcDef = isSgFunctionDefinition(*f_itr) ;
        ROSE_ASSERT(funcDef);

#ifdef ET_DEBUG 
        printf("--- %s ---\n", funcDef->get_qualified_name().str()) ;
#endif

        SgBasicBlock *funcBody = funcDef->get_body() ;
        if (funcBody == NULL)
           continue ;  /* should be impossible to get here... */

        SgFunctionDeclaration *funcDecl = funcDef->get_declaration() ;
        ROSE_ASSERT(funcDecl);

        /* don't transform header file code  */
        if (strstr(funcDecl->get_name().str(), "operator"))
           continue ;

#ifdef ET_DEBUG
        printf("--- %s ---\n", funcDecl->get_name().str()) ;
#endif

        int loopCount = 0 ;  /* used to create local variable names */
        int segCount = 0 ;

        TransformFunction(funcDecl, funcBody, funcBody, &loopCount, &segCount) ;

        if (loopCount != 0)
        {
           loopTransformApplied = true ;
        }
     }

     SgFunctionDeclaration *mainFunc = SageInterface::findMain(project) ;
     if (countIters == false && (loopTransformApplied || mainFunc != NULL)) {
        SageInterface::attachArbitraryText(globalScope,
           std::string("#define ET_NO_COUNT_ITERS 1\n")) ;
     }

     /* files containing at least one loop require run-time support */

     if (loopTransformApplied)
     {
        SageInterface::attachArbitraryText(globalScope,
           std::string("#include \"ETrt.h\"\n")) ;
     }

     /* fold run-time support code into file containing main() */

     if (mainFunc != NULL)
     {

        SgFunctionDefinition *mainFuncDef = mainFunc->get_definition() ;

        /* include ETrt.c just before main() in this file */
        if (!fullLoopStat) {
          SageInterface::attachArbitraryText(globalScope,
             std::string("#define ET_SIMPLE_LOOP_STATS 1\n") );
        }
        if (enablePostProcessing) {
          SageInterface::attachArbitraryText(globalScope,
             std::string("#define ET_POST_PROCESS_SEQ_TO_LOOP 1\n") );
        }
        if (withPAPI) {
          SageInterface::attachArbitraryText(globalScope,
             std::string("#define ET_PAPI 1\n\n") );
        }
        SageInterface::attachArbitraryText(globalScope,
           std::string("#include \"ETrt.c\"\n") );

        if (withPAPI) {
           /* Insert PAPI initialization code at top of main */
           SgBasicBlock *mainBody = mainFuncDef->get_body() ;

           Rose_STL_Container<SgNode*> blockStmts =
               NodeQuery::querySubTree(mainBody, V_SgStatement,
                                       AstQueryNamespace::ChildrenOnly) ;

           for (Rose_STL_Container<SgNode*>::iterator s_itr = blockStmts.begin();
                   s_itr != blockStmts.end(); ++s_itr)
           {
              SgStatement *stmt = isSgStatement(*s_itr) ;
              ROSE_ASSERT(stmt);

              /* skip variable declarations */
              if (isSgDeclarationStatement(stmt))
                 continue ;

              SgExprStatement *initCall = buildFunctionCallStmt(
                 SgName("ET_Init"), buildVoidType(), buildExprListExp(),
                 mainFuncDef->get_body()) ;
              stmt->get_scope()->insert_statement(stmt, initCall) ;

              break ;
           }
        }

        /* insert finalization code at end of main() */
        Rose_STL_Container<SgNode*> retStmts =
            NodeQuery::querySubTree(mainFunc, V_SgReturnStmt) ;

        if (retStmts.size() > 0)
        {
           for (Rose_STL_Container<SgNode*>::iterator r_itr = retStmts.begin();
                   r_itr != retStmts.end(); ++r_itr)
           {
              SgReturnStmt *ret = isSgReturnStmt(*r_itr) ;
              ROSE_ASSERT(ret);

              SgExprStatement *sanityCall = buildFunctionCallStmt(
                 SgName("ET_SanityCheck"), buildVoidType(), buildExprListExp(),
                 mainFuncDef->get_body()) ;
              ret->get_scope()->insert_statement(ret, sanityCall) ;

              SgExprStatement *logStatCall = buildFunctionCallStmt(
                 SgName(dumpFunc), buildVoidType(), buildExprListExp(),
                 mainFuncDef->get_body()) ;
              ret->get_scope()->insert_statement(ret, logStatCall) ;
           }
        }
        else
        {
           SgExprStatement *sanityCall = buildFunctionCallStmt(
              SgName("ET_SanityCheck"), buildVoidType(), buildExprListExp(),
              mainFuncDef->get_body()) ;
           mainFuncDef->get_body()->append_statement(sanityCall) ;

           SgExprStatement *logStatCall = buildFunctionCallStmt(
              SgName(dumpFunc), buildVoidType(), buildExprListExp(),
              mainFuncDef->get_body()) ;
           mainFuncDef->get_body()->append_statement(logStatCall) ;
        }
     }
   }

   /* make sure AST is well formed */
   AstTests::runAllTests(project);

   // generateDOT (*project);

   return backend(project);
}
Ejemplo n.º 28
0
void testOneFunction( std::string funcParamName, 
		      vector<string> argvList,
		      bool debug, int nrOfNodes, 
		      multimap <string, int> results,
		      multimap <string, int> useresults) {
  if (debug)
    cout <<"\n\n------------------------------------------\ntesting ... " << argvList[1] << endl;
  // Build the AST used by ROSE
  SgProject* project = frontend(argvList);
  // Call the Def-Use Analysis
  DFAnalysis* defuse = new DefUseAnalysis(project);
  int val = defuse->run(debug);
  if (debug)
    std::cout << "Analysis run is : " << (val ?  "failure" : "success" ) << " " << val << std::endl;
  if (val==1) exit(1);

  if (debug==false)
    defuse->dfaToDOT();

  //std::list<SgNode*> vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
  //std::list<SgNode*>::const_iterator i = vars.begin();
  NodeQuerySynthesizedAttributeType vars = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
  NodeQuerySynthesizedAttributeType::const_iterator i = vars.begin();
  for (; i!=vars.end();++i) {
    SgFunctionDefinition* func = isSgFunctionDefinition(*i);
    std::string name = func->class_name();
    string funcName = func->get_declaration()->get_qualified_name().str();
    int maxNodes = defuse->getDefSize();
    int nodeNr = defuse->getIntForSgNode(func);
    if (nodeNr == -1)
      continue;
    //cout << " checking function : " << funcName << endl;
    if (funcName!=funcParamName)
      continue;

    if (debug)
      cout << "\n------------------------\nchecking for " << name << " -- " << funcName << " -- " << nodeNr << endl;
    if (maxNodes!=nrOfNodes) {
	cerr << " Error: Test should have " << nrOfNodes << " nodes. found: " << maxNodes << endl;
      abort();
    }
    if (debug)
      cout << " Test has nodes:  " << nrOfNodes <<  endl;
    if (debug)
      cout <<"\nChecking all definitions ... " << endl;
    // check nodes in multimap
    std::vector <std::pair < SgInitializedName*, SgNode*> > map = defuse->getDefMultiMapFor(func);
    if (map.size()>0) {
      std::vector < std::pair <SgInitializedName*, SgNode*> >::const_iterator j = map.begin();
      unsigned int hit=0;
      SgNode* node = NULL;
      string name="";
      for (;j!=map.end();++j) {
	SgInitializedName* in_node = j->first;
	node = j->second;
	name= in_node->get_qualified_name().str();
	if (debug)
	  cout << " ... checking :  " << name << endl;
	multimap <string, int>::const_iterator k =results.begin();
	for (;k!=results.end();++k) {
	  string resName = k->first;
	  int resNr = k->second;
	  int tableNr = defuse->getIntForSgNode(node);
	  if (name==resName)
	    if (debug)
	      cout << " ... defNr: " << resNr << "  inTable: " << tableNr <<  endl; 
	  if (name==resName && tableNr==resNr) {
	    hit++;
	    if (debug)
	      cout << " Hit " << hit << "/" << results.size() << " - (" << name << "," << resNr << ")" << endl;
	  }
	}

      }
      if (hit!=results.size()) {
	cerr << " Error: No hit! ... DFA values of node " << nodeNr << " are not correct! " << endl;
	exit(1);
      }
    } else {
      if (results.size()!=0) {
	cerr << " Error: Test node " << defuse->getIntForSgNode(func) << " should have a multimap. " << endl;
	exit(1);
      }
    }
  
    if (debug)
      cout <<"\nChecking all uses ... " << endl;
    // check nodes in multimap
    map = defuse->getUseMultiMapFor(func);
    if (map.size()>0) {
      std::vector <std::pair <SgInitializedName*, SgNode*> >::const_iterator j = map.begin();
      size_t hit=0;
      for (;j!=map.end();++j) {
	SgInitializedName* in_node = j->first;
	SgNode* node = j->second;
	string name= in_node->get_qualified_name().str();
	if (debug)
	  cout << " ... checking :  " << name << endl;
	multimap <string, int>::const_iterator k =useresults.begin();
	for (;k!=useresults.end();++k) {
	  string resName = k->first;
	  int resNr = k->second;
	  int tableNr = defuse->getIntForSgNode(node);
	  if (name==resName)
	    if (debug)
	      cout << " ... defNr: " << resNr << "  inTable: " << tableNr <<  endl; 
	  if (name==resName && tableNr==resNr) {
	    hit++;
	    if (debug)
	      cout << " Hit " << hit << "/" << useresults.size() << " - (" << name << "," << resNr << ")" << endl;
	  }
	}

      }
      if (hit!=useresults.size()) {
	cerr << " Error: No hit! ... DFA values of node " << nrOfNodes << " are not correct! " << endl;
	exit(1);
      }
    } // if
  }
  if (debug)
    std::cout << "Analysis test is success." << std::endl;
}