Make code that tests for specific opcode families more consistent.

This commit is contained in:
Dan Gohman
2018-03-23 03:46:42 -07:00
parent 9602b78320
commit aa73de8ca1
2 changed files with 17 additions and 17 deletions

View File

@@ -56,19 +56,19 @@ pub fn legalize_function(func: &mut ir::Function, cfg: &mut ControlFlowGraph, is
let opcode = pos.func.dfg[inst].opcode(); let opcode = pos.func.dfg[inst].opcode();
// Check for ABI boundaries that need to be converted to the legalized signature. // Check for ABI boundaries that need to be converted to the legalized signature.
if opcode.is_call() && boundary::handle_call_abi(inst, pos.func, cfg) { if opcode.is_call() {
if boundary::handle_call_abi(inst, pos.func, cfg) {
// Go back and legalize the inserted argument conversion instructions. // Go back and legalize the inserted argument conversion instructions.
pos.set_position(prev_pos); pos.set_position(prev_pos);
continue; continue;
} }
} else if opcode.is_return() {
if opcode.is_return() && boundary::handle_return_abi(inst, pos.func, cfg) { if boundary::handle_return_abi(inst, pos.func, cfg) {
// Go back and legalize the inserted return value conversion instructions. // Go back and legalize the inserted return value conversion instructions.
pos.set_position(prev_pos); pos.set_position(prev_pos);
continue; continue;
} }
} else if opcode.is_branch() {
if opcode.is_branch() {
split::simplify_branch_arguments(&mut pos.func.dfg, inst); split::simplify_branch_arguments(&mut pos.func.dfg, inst);
} }

View File

@@ -69,11 +69,11 @@ impl<'a> LocationVerifier<'a> {
let opcode = dfg[inst].opcode(); let opcode = dfg[inst].opcode();
if opcode.is_return() { if opcode.is_return() {
self.check_return_abi(inst, &divert)?; self.check_return_abi(inst, &divert)?;
} } else if opcode.is_branch() {
if !divert.is_empty() {
if opcode.is_branch() && !divert.is_empty() {
self.check_cfg_edges(inst, &divert)?; self.check_cfg_edges(inst, &divert)?;
} }
}
self.update_diversions(inst, &mut divert)?; self.update_diversions(inst, &mut divert)?;
} }