63 : removed_phi(0), updated_ssa_uses(
false), number(_number), loop_id(0), hpl(0), true_edge(0), false_edge(0)
80 called_function_id = 0;
83 const auto ce = GetPointerS<const call_expr>(
GET_NODE(ga->
op1));
84 if(
GET_NODE(ce->fn)->get_kind() == addr_expr_K)
86 const auto fn = GetPointerS<const addr_expr>(
GET_CONST_NODE(ce->fn))->op;
87 if(
GET_NODE(fn)->get_kind() == function_decl_K)
96 const auto gc = GetPointerS<gimple_call>(
GET_NODE(statement));
97 if(
GET_NODE(gc->fn)->get_kind() == addr_expr_K)
99 const auto fn = GetPointerS<const addr_expr>(
GET_CONST_NODE(gc->fn))->op;
100 if(
GET_NODE(fn)->get_kind() == function_decl_K)
116 current_uses.insert(gp->res);
118 std::list<tree_nodeRef> list_of_postponed_stmt;
122 if(
GET_NODE(*pos)->get_kind() == gimple_assign_K)
124 auto ga = GetPointer<gimple_assign>(
GET_NODE(*pos));
125 if(
GET_NODE(ga->op0)->get_kind() != ssa_name_K)
132 for(
const auto& u : uses)
134 if(current_uses.find(u.first) == current_uses.end())
137 auto ssa = GetPointer<ssa_name>(ssa_node);
138 if(ssa->virtual_flag || GetPointer<gimple_node>(
GET_NODE(ssa->CGetDefStmt()))->bb_index !=
number)
140 current_uses.insert(u.first);
151 if(not allDefinedP(*pos))
153 list_of_postponed_stmt.push_back(*pos);
154 const auto next_stmt = std::next(pos);
160 current_uses.insert(ga->op0);
161 const auto next_stmt = std::next(pos);
162 bool restart_postponed =
false;
165 restart_postponed =
false;
166 auto posPostponed = list_of_postponed_stmt.begin();
167 while(posPostponed != list_of_postponed_stmt.end())
169 if(allDefinedP(*posPostponed))
173 auto gaPostponed = GetPointer<gimple_assign>(
GET_NODE(*posPostponed));
174 current_uses.insert(gaPostponed->op0);
175 restart_postponed =
true;
180 list_of_postponed_stmt.erase(posPostponed);
188 }
while(restart_postponed);
201 const auto ga = GetPointer<gimple_assign>(
GET_NODE(statement));
202 if((ga && (
GET_NODE(ga->op1)->get_kind() == call_expr_K ||
GET_NODE(ga->op1)->get_kind() == aggr_init_expr_K)) ||
203 GET_NODE(statement)->get_kind() == gimple_call_K)
205 const auto cg_man = AppM->GetCallGraphManager();
208 unsigned int called_function_id;
212 if(cg_man->IsVertex(function_id))
231 const auto gn = GetPointer<gimple_node>(
GET_NODE(new_stmt));
238 GetPointerS<ssa_name>(
GET_NODE(gn->vdef))->SetDefStmt(new_stmt);
244 GetPointerS<ssa_name>(
GET_NODE(gn->memdef))->SetDefStmt(new_stmt);
247 if(
GET_NODE(new_stmt)->get_kind() == gimple_assign_K)
249 const auto ga = GetPointerS<gimple_assign>(
GET_NODE(new_stmt));
252 GetPointerS<ssa_name>(
GET_NODE(ga->op0))->SetDefStmt(new_stmt);
255 else if(
GET_NODE(new_stmt)->get_kind() == gimple_phi_K)
257 const auto gp = GetPointerS<gimple_phi>(
GET_NODE(new_stmt));
260 GetPointerS<ssa_name>(
GET_NODE(gp->res))->SetDefStmt(new_stmt);
267 for(
const auto& use : uses)
271 GetPointerS<ssa_name>(
GET_NODE(use.first))->AddUseStmt(new_stmt);
291 "Adding phi " + new_stmt->
ToString() +
" to statements list");
295 if((*pos)->index == existing_stmt->
index)
310 "Adding phi " + new_stmt->
ToString() +
" to statements list");
314 if((*pos)->index == existing_stmt->
index)
328 "Adding phi " + statement->
ToString() +
" to statements list");
344 "Adding phi " + statement->
ToString() +
" to statements list");
368 bool replaced =
false;
372 if((*temp_stmt)->index == old_stmt->
index)
377 const auto next_stmt = std::next(temp_stmt);
379 const auto old_ga = GetPointer<gimple_node>(
GET_NODE(old_stmt));
380 const auto new_ga = GetPointer<gimple_node>(
GET_NODE(new_stmt));
383 THROW_ASSERT(!old_ga->memdef || move_virtuals,
STR(old_stmt) +
" defines virtuals");
389 new_ga->memdef = old_ga->memdef;
394 new_ga->memuse = old_ga->memuse;
399 new_ga->vdef = old_ga->vdef;
401 if(old_ga->vuses.size())
403 new_ga->vuses.insert(old_ga->vuses.begin(), old_ga->vuses.end());
405 if(old_ga->vovers.size())
407 new_ga->vovers.insert(old_ga->vovers.begin(), old_ga->vovers.end());
426 const auto ga = GetPointer<gimple_assign>(
GET_NODE(statement));
427 if((ga && (
GET_NODE(ga->op1)->get_kind() == call_expr_K ||
GET_NODE(ga->op1)->get_kind() == aggr_init_expr_K)) ||
428 GET_NODE(statement)->get_kind() == gimple_call_K)
430 const auto cg_man = AppM->GetCallGraphManager();
432 unsigned int called_function_id;
437 const auto fun_cg_vertex = cg_man->GetVertex(fun_id);
438 const auto cg = cg_man->CGetCallGraph();
441 boost::tie(oei, oei_end) = boost::out_edges(fun_cg_vertex, *cg);
443 for(; oei != oei_end; oei++)
445 const auto& direct_calls = cg->CGetFunctionEdgeInfo(*oei)->direct_call_points;
446 auto call_it = direct_calls.find(call_id);
447 if(call_it != direct_calls.end())
449 to_remove.insert(*oei);
453 AppM->get_tree_manager(),
454 GetPointer<const function_decl>(AppM->get_tree_manager()->CGetTreeNode(
456 "Call to be removed not found in call graph " +
STR(call_id) +
" " +
STR(fun_id) +
" " +
457 STR(statement) +
" | " +
459 GetPointerS<function_decl>(
GET_NODE(
460 GetPointerS<gimple_node>(
GET_NODE(statement))->scpe))));
461 for(
const auto& e : to_remove)
463 cg_man->RemoveCallPoint(e, call_id);
472 if((*temp_stmt)->index == statement->
index)
478 GetPointerS<gimple_node>(
GET_NODE(statement))->bb_index = 0;
484 for(
const auto& use : uses)
488 GetPointerS<ssa_name>(
GET_NODE(use.first))->RemoveUse(statement);
513 if((*temp_phi)->index == phi->
index)
519 GetPointerS<gimple_node>(
GET_NODE(phi))->bb_index = 0;
525 for(
const auto& use : uses)
529 GetPointerS<ssa_name>(
GET_NODE(use.first))->RemoveUse(phi);
544 updated_ssa_uses =
true;
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
void PushBack(const tree_nodeRef statement, const application_managerRef AppM)
Add a statement as last non controlling statement.
virtual void visit(tree_node_visitor *const v) const
virtual function used to traverse the tree_node data structure.
boost::graph_traits< graph >::out_edge_iterator OutEdgeIterator
out_edge_iterator definition.
void PushBefore(const tree_nodeRef new_stmt, const tree_nodeRef existing_stmt, const application_managerRef AppM)
Add a statement before a specified one.
const unsigned int number
number is the index of the basic block.
std::string ToString() const
Print this node as string in gimple format.
tree_nodeRef op1
The second operand of the binary expression.
static bool LastStatement(const tree_nodeConstRef &statement)
Return true if statement must be the last of a basic block.
#define BB_EXIT
constant identifying the basic block node of type exit
Definition of the class representing a generic C application.
void update_new_stmt(const application_managerRef &AppM, const tree_nodeRef &new_stmt)
void Replace(const tree_nodeRef old_stmt, const tree_nodeRef new_stmt, const bool move_virtuals, const application_managerRef AppM)
Replace a statement with another one.
void PushFront(const tree_nodeRef statement, const application_managerRef AppM)
Add a statement in front of list of statements.
#define BUILTIN_WAIT_CALL
constant defining the builtin wait call intrinsic function
static const unsigned int EXIT_BLOCK_ID
constant identifying the exit basic block
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
bool updated_ssa_uses
consistency of ssa uses
static std::string print_function_name(const tree_managerConstRef &TM, const function_decl *fd)
Return the name of the function in a string.
const std::list< tree_nodeRef > & CGetPhiList() const
Return the list of phi.
void RemoveStmt(const tree_nodeRef statement, const application_managerRef AppM)
Remove a statement.
void manageCallGraph(const application_managerRef &AppM, const tree_nodeRef &statement)
Data structure describing a basic block at tree level.
void RemovePhi(const tree_nodeRef phi)
Remove a phi.
Abstract pure class for the tree structure.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
static void addCallPointAndExpand(CustomUnorderedSet< unsigned int > &AV, const application_managerRef AM, unsigned int caller_id, unsigned int called_id, unsigned int call_id, enum FunctionEdgeInfo::CallType call_type, int DL)
void UpdateTime(const unsigned int operation_index, bool update_cs=true)
Compute the starting and the ending time of a statement.
const std::list< tree_nodeRef > & CGetStmtList() const
Return the list of stmt.
This struct specifies the gimple_assign node (GCC 4.3 tree node).
Data structure used to store the schedule of the operations.
#define SEQ_VISIT_MEMBER(mask, seq, seqbasetype, method, visitor_type, visitor_obj)
macro used to traverse non empty sequences
void ReorderLUTs()
ReorderLUTs reorders the LUT statements to fix the def-use relations.
const unsigned int index
Represent the index read from the raw file and the index-1 of the vector of tree_node associated to t...
#define BB_ENTRY
constant identifying the basic block node of type entry
#define GET_CONST_NODE(t)
Classes specification of the tree_node data structures.
#define ALL_VISIT
constant used to allow member visit
This file collects some utility functions.
void AddPhi(const tree_nodeRef phi)
Add a value to list of phi node.
Class specification of the tree_reindex support class.
static const unsigned int ENTRY_BLOCK_ID
constant identifying the entry basic block
bool check_function_call(const tree_nodeRef &statement, gimple_assign *ga, unsigned int &called_function_id)
Data structures used in operations graph.
virtual ~bloc()
Destructor.
std::list< tree_nodeRef > list_of_phi
list_of_phi is a list of eventual phi node presents in the basic block.
unsigned counter[N_THREADS]
size_t removed_phi
Number of removed phi.
ScheduleRef schedule
The reference to the schedule.
#define GET_INDEX_CONST_NODE(t)
static void ComputeSsaUses(const tree_nodeRef &, TreeNodeMap< size_t > &uses)
recursively compute the references to the ssa_name variables used in a statement
CustomUnorderedSet< unsigned int > already_visited
Already visited tree node (used to avoid infinite recursion)
bloc(unsigned int _number)
constructor
std::list< tree_nodeRef > list_of_stmt
list_of_stmt is the list of statements stored in the basic block.
Class specification of the manager of the tree structures extracted from the raw file.
void SetSSAUsesComputed()
Set that uses of ssa have been computed.
A brief description of the C++ Header File.
size_t CGetNumberRemovedPhi() const
Return the number of removed phi.
void PushAfter(const tree_nodeRef new_stmt, const tree_nodeRef existing_stmt, const application_managerRef AppM)
Add a statement after a specified one.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...