@@ -75,38 +75,48 @@ class call_grapht
75
75
call_edges_ranget out_edges (irep_idt const & caller) const ;
76
76
};
77
77
78
- /* *
79
- * For DAG call graphs it computes an inverted topological order of all
80
- * functions in the call graph. Otherwise, it computes only a partial
81
- * inverted topological order (all loops are broken at some (randomly)
82
- * chosen edge to get a DAG). The topolocical order is stored in the
83
- * 'output' vector.
84
- *
85
- * Since the algorithm is implemented using DFS, those 'breaks' are
86
- * implemented naturally by a set of processed (vidited) functions.
87
- *
88
- * The function actually performs only one DFS from a passed 'start_function'.
89
- * So, to get whole inverted (partial) topological order of all functions in
90
- * the call graph, this function has to be called for all functions in the
91
- * program.
92
- *
93
- * NOTE: The order is 'inverted'. It means that
94
- *
95
- * Typical usage:
96
- * // Let's assume there is 'goto_modelt GM' and 'call_grapht CG'
97
- * std::vector<irep_idt> result; // Here we will store the topological order.
98
- * {
99
- * std::unordered_set<irep_idt,dstring_hash> processed;
100
- * for (auto const& elem : GM.goto_functions.function_map)
101
- * partial_topological_order(CG,elem.first,processed,result);
102
- * // Now we reverse the result to get the classic (partial)
103
- * // topological order instead of the inverted one.
104
- * std::reverse(result.begin(),result.end());
105
- * }
106
- * std::cout << "A (partial) topological order of my call graph is: ";
107
- * for (irep_idt const& fn_name : result)
108
- * std::cout << fn_name << ", ";
109
- */
78
+ /* ******************************************************************\
79
+
80
+ Function: inverted_partial_topological_order
81
+
82
+ Inputs: See purpose
83
+
84
+ Outputs: See purpose
85
+
86
+ Purpose:
87
+
88
+ For DAG call graphs it computes an inverted topological order of all
89
+ functions in the call graph. Otherwise, it computes only a partial
90
+ inverted topological order (all loops are broken at some (randomly)
91
+ chosen edge to get a DAG). The topolocical order is stored in the
92
+ 'output' vector.
93
+
94
+ Since the algorithm is implemented using DFS, those 'breaks' are
95
+ implemented naturally by a set of processed (vidited) functions.
96
+
97
+ The function actually performs only one DFS from a passed 'start_function'.
98
+ So, to get whole inverted (partial) topological order of all functions in
99
+ the call graph, this function has to be called for all functions in the
100
+ program.
101
+
102
+ NOTE: The order is 'inverted'. It means that
103
+
104
+ Typical usage:
105
+ // Let's assume there is 'goto_modelt GM' and 'call_grapht CG'
106
+ std::vector<irep_idt> result; // Here we will store the topological order.
107
+ {
108
+ std::unordered_set<irep_idt,dstring_hash> processed;
109
+ for (auto const& elem : GM.goto_functions.function_map)
110
+ partial_topological_order(CG,elem.first,processed,result);
111
+ // Now we reverse the result to get the classic (partial)
112
+ // topological order instead of the inverted one.
113
+ std::reverse(result.begin(),result.end());
114
+ }
115
+ std::cout << "A (partial) topological order of my call graph is: ";
116
+ for (irep_idt const& fn_name : result)
117
+ std::cout << fn_name << ", ";
118
+
119
+ \*******************************************************************/
110
120
void inverted_partial_topological_order (
111
121
call_grapht const & call_graph,
112
122
irep_idt const & start_function,
0 commit comments