#pragma once #include "../Utils/SgUtils.h" #include "CFGraph.h" namespace LIVE_VARIABLES { /* Store information about live and dead variables after call operator */ /* (needed for interprocedural part of live variable analysis) */ class LiveDeadVarsForCall { private: bool tryInsert(std::set& dest, SAPFOR::BasicBlock* b); public: FuncInfo* func; std::map> live_after; std::set dead_after; std::map> commons_live_after; std::set commons_dead_after; std::vector params; SAPFOR::BasicBlock* block; LiveDeadVarsForCall(FuncInfo* f, SAPFOR::BasicBlock* b, const std::vector& p); void make_live(SAPFOR::Argument* arg, SAPFOR::BasicBlock* b); void make_dead(SAPFOR::Argument* arg); void updateFromOut(); }; } template void insertIfVar(IT begin, IT end, DEST& to) { for (auto it = begin; it != end; it++) if (*it && (*it)->getType() == SAPFOR::CFG_ARG_TYPE::VAR) to.insert(*it); } void getUseDefForInstruction(SAPFOR::BasicBlock* block, SAPFOR::Instruction* instr, std::set& use, std::set& def, std::vector& formal_parameters, std::vector& fcalls, std::vector& arg_stack, int& arg_stack_index, int& arg_stack_size, bool& last_stack_op, std::string& fName, const std::map& funcByName, bool interprocedural); void runLiveVariableAnalysis(const std::map>& CFGraph_for_project); void doDumpLive(const std::map>& CFGraph_for_project); bool joinGlobalsWithParameters(const std::vector& params, const std::map, std::set>>& params_and_globals, const std::string& func_name, std::set& result);