MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / inline_block

Method inline_block

crates/rustc_codegen_spirv/src/linker/inline.rs:552–777  ·  view source on GitHub ↗
(&mut self, caller: &mut Function, block_idx: usize)

Source from the content-addressed store, hash-verified

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

Callers 1

inline_fnMethod · 0.80

Calls 14

should_inlineFunction · 0.85
apply_rewrite_rulesFunction · 0.85
insert_opvariablesFunction · 0.85
rewrite_phi_sourcesFunction · 0.85
iterMethod · 0.80
is_debuginfoMethod · 0.80
idMethod · 0.80
get_inlined_blocksMethod · 0.80
add_clone_id_rulesMethod · 0.80
ptr_tyMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected