Fix desired branch elision heuristic
This commit is contained in:
		
							parent
							
								
									5887efa841
								
							
						
					
					
						commit
						94b3bd529a
					
				| @ -10,22 +10,34 @@ struct Visit { | |||||||
| 	has_branch: bool, | 	has_branch: bool, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Visit { | ||||||
|  | 	fn set_branch(&mut self, br: &Br) { | ||||||
|  | 		if br.target() != 0 { | ||||||
|  | 			self.has_branch = true; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| impl Visitor for Visit { | impl Visitor for Visit { | ||||||
| 	fn visit_br(&mut self, _: &Br) { | 	fn visit_br(&mut self, stat: &Br) { | ||||||
| 		self.has_branch = true; | 		self.set_branch(stat); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	fn visit_br_if(&mut self, _: &BrIf) { | 	fn visit_br_if(&mut self, stat: &BrIf) { | ||||||
| 		self.has_branch = true; | 		self.set_branch(stat.target()); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	fn visit_br_table(&mut self, table: &BrTable) { | 	fn visit_br_table(&mut self, table: &BrTable) { | ||||||
| 		self.has_branch = true; | 		self.set_branch(table.default()); | ||||||
| 
 | 
 | ||||||
| 		if table.data().is_empty() { | 		if table.data().is_empty() { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		for target in table.data() { | ||||||
|  | 			self.set_branch(target); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		let id = table as *const _ as usize; | 		let id = table as *const _ as usize; | ||||||
| 		let len = self.br_map.len() + 1; | 		let len = self.br_map.len() + 1; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user