spv-in: fix classification of back edges

fix clippy

another fix
This commit is contained in:
Matúš Talčík
2021-03-15 16:04:32 +01:00
committed by Dzmitry Malyshau
parent 0945889dd7
commit 889e487b62

View File

@@ -81,6 +81,14 @@ impl FlowGraph {
continue_block_index,
ControlFlowEdgeType::ForwardContinue,
);
// Back edge
self.flow[continue_block_index].ty = Some(ControlFlowNodeType::Back);
self.flow.add_edge(
continue_block_index,
source_node_index,
ControlFlowEdgeType::Back,
);
}
}
@@ -90,11 +98,13 @@ impl FlowGraph {
Terminator::Branch { target_id } => {
let target_node_index = block_to_node[&target_id];
self.flow.add_edge(
source_node_index,
target_node_index,
ControlFlowEdgeType::Forward,
);
if self.flow[source_node_index].ty != Some(ControlFlowNodeType::Back) {
self.flow.add_edge(
source_node_index,
target_node_index,
ControlFlowEdgeType::Forward,
);
}
}
Terminator::BranchConditional {
true_id, false_id, ..
@@ -158,14 +168,6 @@ impl FlowGraph {
continue;
}
// Back
if self.flow[node_target_index].ty == Some(ControlFlowNodeType::Loop)
&& self.flow[node_source_index].id > self.flow[node_target_index].id
{
self.flow[node_source_index].ty = Some(ControlFlowNodeType::Back);
self.flow[edge_index] = ControlFlowEdgeType::Back;
}
let mut target_incoming_edges = self
.flow
.neighbors_directed(node_target_index, Direction::Incoming)