Lines Matching refs:func
61 for (func, _) in test_file.functions { in run()
62 let (orig_block_count, orig_inst_count) = (block_count(&func), inst_count(&func)); in run()
64 match reduce(isa, func, options.verbose) { in run()
65 Ok((func, crash_msg)) => { in run()
72 block_count(&func), in run()
73 inst_count(&func) in run()
98 fn mutate(&mut self, func: Function) -> Option<(Function, String, ProgressStatus)>; in mutate()
112 fn new(func: &Function) -> Self { in new()
113 let first_block = func.layout.entry_block().unwrap(); in new()
114 let first_inst = func.layout.first_inst(first_block).unwrap(); in new()
127 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
128 next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map(|(prev_block, prev_inst)| { in mutate()
129 func.layout.remove_inst(prev_inst); in mutate()
130 let msg = if func.layout.block_insts(prev_block).next().is_none() { in mutate()
132 func.layout.remove_block(prev_block); in mutate()
137 (func, msg, ProgressStatus::ExpandedOrShrinked) in mutate()
149 fn new(func: &Function) -> Self { in new()
150 let first_block = func.layout.entry_block().unwrap(); in new()
151 let first_inst = func.layout.first_inst(first_block).unwrap(); in new()
164 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
165 next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map( in mutate()
167 let num_results = func.dfg.inst_results(prev_inst).len(); in mutate()
169 let opcode = func.dfg.insts[prev_inst].opcode(); in mutate()
175 return (func, format!(""), ProgressStatus::Skip); in mutate()
181 let ret_ty = func.dfg.value_type(func.dfg.first_result(prev_inst)); in mutate()
184 let arg = func.dfg.inst_args(prev_inst)[0]; in mutate()
185 let arg_def = func.dfg.value_def(arg); in mutate()
188 .map(|inst| func.dfg.insts[inst].opcode() == ir::Opcode::Iconst) in mutate()
192 return (func, format!(""), ProgressStatus::Skip); in mutate()
198 let mut pos = FuncCursor::new(&mut func).at_inst(prev_inst); in mutate()
202 let results = pos.func.dfg.inst_results(prev_inst).to_vec(); in mutate()
205 pos.func.dfg.clear_results(prev_inst); in mutate()
223 func, in mutate()
239 fn new(func: &Function) -> Self { in new()
240 let first_block = func.layout.entry_block().unwrap(); in new()
241 let first_inst = func.layout.first_inst(first_block).unwrap(); in new()
254 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
255 next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map( in mutate()
257 let status = if func.dfg.insts[prev_inst].opcode() == ir::Opcode::Trap { in mutate()
260 func.dfg.replace(prev_inst).trap(TrapCode::unwrap_user(1)); in mutate()
263 (func, format!("Replace inst {prev_inst} with trap"), status) in mutate()
276 fn new(func: &Function) -> Self { in new()
277 let first_block = func.layout.entry_block().unwrap(); in new()
278 let first_inst = func.layout.first_inst(first_block).unwrap(); in new()
291 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
292 next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map(|(prev_block, prev_inst)| { in mutate()
295 let first_block = func.layout.entry_block().unwrap(); in mutate()
298 func, in mutate()
304 let last_inst_of_first_block = func.layout.last_inst(first_block).unwrap(); in mutate()
305 func.layout.remove_inst(prev_inst); in mutate()
306 func.layout.insert_inst(prev_inst, last_inst_of_first_block); in mutate()
309 func, in mutate()
323 fn new(func: &Function) -> Self { in new()
325 block: func.layout.entry_block().unwrap(), in new()
335 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
336 func.layout.next_block(self.block).map(|next_block| { in mutate()
338 while let Some(inst) = func.layout.last_inst(self.block) { in mutate()
339 func.layout.remove_inst(inst); in mutate()
341 func.layout.remove_block(self.block); in mutate()
343 func, in mutate()
358 fn new(func: &Function) -> Self { in new()
359 let first_block = func.layout.entry_block().unwrap(); in new()
362 params_remaining: func.dfg.num_block_params(first_block), in new()
372 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
374 self.block = func.layout.next_block(self.block)?; in mutate()
375 self.params_remaining = func.dfg.num_block_params(self.block); in mutate()
381 let param = func.dfg.block_params(self.block)[param_index]; in mutate()
382 func.dfg.remove_block_param(param); in mutate()
384 let first_inst = func.layout.first_inst(self.block).unwrap(); in mutate()
385 let mut pos = FuncCursor::new(&mut func).at_inst(first_inst); in mutate()
389 cfg.compute(&func); in mutate()
393 let dfg = &mut func.dfg; in mutate()
403 if Some(self.block) == func.layout.entry_block() { in mutate()
405 func.signature.params.remove(param_index); in mutate()
409 func, in mutate()
435 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
439 for block in func.layout.blocks() { in mutate()
440 for inst in func.layout.block_insts(block) { in mutate()
441 match func.dfg.insts[inst] { in mutate()
457 for (func_ref, ext_func_data) in func.dfg.ext_funcs.clone().into_iter() { in mutate()
461 match func.dfg.insts[inst] { in mutate()
477 func.dfg.ext_funcs = ext_funcs; in mutate()
489 for block in func.layout.blocks() { in mutate()
490 for inst in func.layout.block_insts(block) { in mutate()
492 if let InstructionData::CallIndirect { sig_ref, .. } = func.dfg.insts[inst] in mutate()
501 for (func_ref, ext_func_data) in func.dfg.ext_funcs.iter() { in mutate()
510 for (sig_ref, sig_data) in func.dfg.signatures.clone().into_iter() { in mutate()
515 SigRefUser::Instruction(inst) => match func.dfg.insts[inst] { in mutate()
525 func.dfg.ext_funcs[func_ref].signature = new_sig_ref; in mutate()
532 func.dfg.signatures = signatures; in mutate()
538 for block in func.layout.blocks() { in mutate()
539 for inst in func.layout.block_insts(block) { in mutate()
540 match func.dfg.insts[inst] { in mutate()
557 for (stack_slot, stack_slot_data) in func.sized_stack_slots.clone().iter() { in mutate()
561 match &mut func.dfg.insts[inst] { in mutate()
573 func.sized_stack_slots = stack_slots; in mutate()
579 for block in func.layout.blocks() { in mutate()
580 for inst in func.layout.block_insts(block) { in mutate()
583 func.dfg.insts[inst] in mutate()
593 for (_global_value, global_value_data) in func.global_values.iter() { in mutate()
607 for (global_value, global_value_data) in func.global_values.clone().into_iter() { in mutate()
611 match &mut func.dfg.insts[inst] { in mutate()
622 func.global_values = global_values; in mutate()
629 Some((func, name.to_owned(), ProgressStatus::Changed)) in mutate()
639 fn new(func: &Function) -> Self { in new()
641 block: func.layout.entry_block().unwrap(), in new()
652 fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> { in mutate()
653 let block = match func.layout.next_block(self.block) { in mutate()
661 cfg.compute(&func); in mutate()
665 func, in mutate()
675 let branch_dests = func.dfg.insts[pred.inst] in mutate()
676 .branch_destination(&func.dfg.jump_tables, &func.dfg.exception_tables); in mutate()
679 func, in mutate()
686 .args(&func.dfg.value_lists) in mutate()
690 let block_params = func in mutate()
693 .as_slice(&func.dfg.value_lists) in mutate()
703 func.dfg.change_to_alias(block_param, arg); in mutate()
709 func.layout.remove_inst(pred.inst); in mutate()
712 while let Some(inst) = func.layout.first_inst(block) { in mutate()
713 func.layout.remove_inst(inst); in mutate()
714 func.layout.append_inst(inst, pred.block); in mutate()
718 func.layout.remove_block(block); in mutate()
725 func, in mutate()
737 let ty = pos.func.dfg.value_type(param); in replace_with_const()
746 let zero_handle = pos.func.dfg.constants.insert(zero_data); in replace_with_const()
761 func: &Function, in next_inst_ret_prev()
766 if let Some(next_inst) = func.layout.next_inst(*inst) { in next_inst_ret_prev()
770 if let Some(next_block) = func.layout.next_block(*block) { in next_inst_ret_prev()
772 *inst = func.layout.first_inst(*block).expect("no inst"); in next_inst_ret_prev()
778 fn block_count(func: &Function) -> usize { in block_count()
779 func.layout.blocks().count() in block_count()
782 fn inst_count(func: &Function) -> usize { in inst_count()
783 func.layout in inst_count()
785 .map(|block| func.layout.block_insts(block).count()) in inst_count()
790 fn try_resolve_aliases(context: &mut CrashCheckContext, func: &mut Function) { in try_resolve_aliases()
791 let mut func_with_resolved_aliases = func.clone(); in try_resolve_aliases()
794 *func = func_with_resolved_aliases; in try_resolve_aliases()
799 fn try_remove_srclocs(context: &mut CrashCheckContext, func: &mut Function) { in try_remove_srclocs()
800 let mut func_with_removed_sourcelocs = func.clone(); in try_remove_srclocs()
803 *func = func_with_removed_sourcelocs; in try_remove_srclocs()
807 fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Function, String)> { in reduce()
810 if let CheckResult::Succeed = context.check_for_crash(&func) { in reduce()
814 try_resolve_aliases(&mut context, &mut func); in reduce()
815 try_remove_srclocs(&mut context, &mut func); in reduce()
823 0 => Box::new(RemoveInst::new(&func)), in reduce()
824 1 => Box::new(ReplaceInstWithConst::new(&func)), in reduce()
825 2 => Box::new(ReplaceInstWithTrap::new(&func)), in reduce()
826 3 => Box::new(MoveInstToEntryBlock::new(&func)), in reduce()
827 4 => Box::new(RemoveBlock::new(&func)), in reduce()
828 5 => Box::new(ReplaceBlockParamWithConst::new(&func)), in reduce()
830 7 => Box::new(MergeBlocks::new(&func)), in reduce()
837 let (mutated_func, msg, mutation_kind) = match mutator.mutate(func.clone()) { in reduce()
857 func = mutated_func; in reduce()
883 inst_count(&func), in reduce()
884 block_count(&func), in reduce()
899 try_resolve_aliases(&mut context, &mut func); in reduce()
901 let crash_msg = match context.check_for_crash(&func) { in reduce()
906 Ok((func, crash_msg)) in reduce()
946 fn check_for_crash(&mut self, func: &Function) -> CheckResult { in check_for_crash()
949 self.context.func = func.clone(); in check_for_crash()
955 cranelift_codegen::verifier::verify_function(&func, self.isa).err() in check_for_crash()
969 let contains_call = func.layout.blocks().any(|block| { in check_for_crash()
970 func.layout in check_for_crash()
972 .any(|inst| match func.dfg.insts[inst] { in check_for_crash()
1011 for (func, _) in test_file.functions { in run_test()
1013 reduce(isa, func, false).expect("Couldn't reduce test case"); in run_test()