(&mut self, vertex: BasicBlock, partition: &mut Vec<WtoComponent>)
| 211 | } |
| 212 | |
| 213 | fn visit(&mut self, vertex: BasicBlock, partition: &mut Vec<WtoComponent>) -> u32 { |
| 214 | self.push(vertex); |
| 215 | self.num += 1; |
| 216 | self.dfn.insert(vertex, self.num); |
| 217 | let mut head = self.num; |
| 218 | let mut is_loop = false; |
| 219 | |
| 220 | for succ in self.cfg.basic_blocks.successors(vertex) { |
| 221 | let min; |
| 222 | if self.dfn[&succ] == 0 { |
| 223 | min = self.visit(succ, partition); |
| 224 | } else { |
| 225 | min = self.dfn[&succ]; |
| 226 | } |
| 227 | if min <= head { |
| 228 | head = min; |
| 229 | is_loop = true; |
| 230 | } |
| 231 | } |
| 232 | if head == self.dfn[&vertex] { |
| 233 | self.dfn.insert(vertex, std::u32::MAX); |
| 234 | let mut element = self.pop().unwrap(); |
| 235 | if is_loop { |
| 236 | while element != vertex { |
| 237 | self.dfn.insert(element, 0); |
| 238 | element = self.pop().unwrap(); |
| 239 | } |
| 240 | self.loop_heads.push(vertex); |
| 241 | partition.push(WtoComponent::Circle(self.component(vertex))); |
| 242 | } else { |
| 243 | partition.push(WtoComponent::Vertex(WtoVertex::new(vertex))); |
| 244 | } |
| 245 | } |
| 246 | head |
| 247 | } |
| 248 | |
| 249 | fn push(&mut self, bb: BasicBlock) { |
| 250 | self.stack.push(bb); |
no test coverage detected