(&mut self, caller: &mut Function, block_idx: usize)
| 550 | } |
| 551 | |
| 552 | fn inline_block(&mut self, caller: &mut Function, block_idx: usize) -> bool { |
| 553 | // Find the first inlined OpFunctionCall |
| 554 | let call = caller.blocks[block_idx] |
| 555 | .instructions |
| 556 | .iter() |
| 557 | .enumerate() |
| 558 | .filter(|(_, inst)| inst.class.opcode == Op::FunctionCall) |
| 559 | .map(|(index, inst)| { |
| 560 | ( |
| 561 | index, |
| 562 | inst, |
| 563 | self.functions |
| 564 | .get(&inst.operands[0].id_ref_any().unwrap()) |
| 565 | .unwrap(), |
| 566 | ) |
| 567 | }) |
| 568 | .find(|(_, inst, f)| { |
| 569 | let call_site = CallSite { |
| 570 | caller, |
| 571 | call_inst: inst, |
| 572 | }; |
| 573 | match should_inline( |
| 574 | self.legal_globals, |
| 575 | self.functions_that_may_abort, |
| 576 | f, |
| 577 | Some(call_site), |
| 578 | ) { |
| 579 | Ok(inline) => inline, |
| 580 | Err(MustInlineToLegalize) => true, |
| 581 | } |
| 582 | }); |
| 583 | let (call_index, call_inst, callee) = match call { |
| 584 | None => return false, |
| 585 | Some(call) => call, |
| 586 | }; |
| 587 | let call_result_type = { |
| 588 | let ty = call_inst.result_type.unwrap(); |
| 589 | if ty == self.op_type_void_id { |
| 590 | None |
| 591 | } else { |
| 592 | Some(ty) |
| 593 | } |
| 594 | }; |
| 595 | let call_result_id = call_inst.result_id.unwrap(); |
| 596 | |
| 597 | // Get the debuginfo instructions that apply to the call. |
| 598 | let custom_ext_inst_set_import = self.custom_ext_inst_set_import; |
| 599 | let call_debug_insts = caller.blocks[block_idx].instructions[..call_index] |
| 600 | .iter() |
| 601 | .filter(|inst| match inst.class.opcode { |
| 602 | Op::Line | Op::NoLine => true, |
| 603 | Op::ExtInst if inst.operands[0].unwrap_id_ref() == custom_ext_inst_set_import => { |
| 604 | CustomOp::decode_from_ext_inst(inst).is_debuginfo() |
| 605 | } |
| 606 | _ => false, |
| 607 | }); |
| 608 | |
| 609 | // Rewrite parameters to arguments |
no test coverage detected