Commit ae18e9b4 authored by Jürg Billeter's avatar Jürg Billeter

Generate reverse postorder instead of preorder list in flow analyzer

parent 3a0e6b26
......@@ -40,6 +40,8 @@ public class Vala.BasicBlock {
Set<PhiFunction> phi_functions = new HashSet<PhiFunction> ();
public bool postorder_visited { get; set; }
public BasicBlock () {
}
......
......@@ -181,6 +181,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
check_variables (entry_block);
}
// generates reverse postorder list
List<BasicBlock> get_depth_first_list (BasicBlock entry_block) {
var list = new ArrayList<BasicBlock> ();
depth_first_traverse (entry_block, list);
......@@ -188,13 +189,14 @@ public class Vala.FlowAnalyzer : CodeVisitor {
}
void depth_first_traverse (BasicBlock current, List<BasicBlock> list) {
if (current in list) {
if (current.postorder_visited) {
return;
}
list.add (current);
current.postorder_visited = true;
foreach (BasicBlock succ in current.get_successors ()) {
depth_first_traverse (succ, list);
}
list.insert (0, current);
}
void build_dominator_tree (List<BasicBlock> block_list, BasicBlock entry_block) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment