|
35 | 35 | resolve_func_from_module, |
36 | 36 | simplify_CFG, |
37 | 37 | GuardException, |
38 | | - convert_code_obj_to_function, |
39 | 38 | build_definitions, |
40 | 39 | replace_var_names, |
41 | 40 | get_name_var_table, |
@@ -618,72 +617,6 @@ def run_pass(self, state): |
618 | 617 | return False |
619 | 618 |
|
620 | 619 |
|
621 | | -@register_pass(mutates_CFG=True, analysis_only=False) |
622 | | -class MakeFunctionToJitFunction(FunctionPass): |
623 | | - """ |
624 | | - This swaps an ir.Expr.op == "make_function" i.e. a closure, for a compiled |
625 | | - function containing the closure body and puts it in ir.Global. It's a 1:1 |
626 | | - statement value swap. `make_function` is already untyped |
627 | | - """ |
628 | | - |
629 | | - _name = "make_function_op_code_to_jit_function" |
630 | | - |
631 | | - def __init__(self): |
632 | | - FunctionPass.__init__(self) |
633 | | - |
634 | | - def run_pass(self, state): |
635 | | - from numba import njit |
636 | | - |
637 | | - func_ir = state.func_ir |
638 | | - mutated = False |
639 | | - for idx, blk in func_ir.blocks.items(): |
640 | | - for stmt in blk.body: |
641 | | - if isinstance(stmt, ir.Assign): |
642 | | - if isinstance(stmt.value, ir.Expr): |
643 | | - if stmt.value.op == "make_function": |
644 | | - node = stmt.value |
645 | | - getdef = func_ir.get_definition |
646 | | - kw_default = getdef(node.defaults) |
647 | | - ok = False |
648 | | - if kw_default is None or isinstance( |
649 | | - kw_default, ir.Const |
650 | | - ): |
651 | | - ok = True |
652 | | - elif isinstance(kw_default, tuple): |
653 | | - ok = all( |
654 | | - [ |
655 | | - isinstance(getdef(x), ir.Const) |
656 | | - for x in kw_default |
657 | | - ] |
658 | | - ) |
659 | | - elif isinstance(kw_default, ir.Expr): |
660 | | - if kw_default.op != "build_tuple": |
661 | | - continue |
662 | | - ok = all( |
663 | | - [ |
664 | | - isinstance(getdef(x), ir.Const) |
665 | | - for x in kw_default.items |
666 | | - ] |
667 | | - ) |
668 | | - if not ok: |
669 | | - continue |
670 | | - |
671 | | - pyfunc = convert_code_obj_to_function(node, func_ir) |
672 | | - func = njit()(pyfunc) |
673 | | - new_node = ir.Global( |
674 | | - node.code.co_name, func, stmt.loc |
675 | | - ) |
676 | | - stmt.value = new_node |
677 | | - mutated |= True |
678 | | - |
679 | | - # if a change was made the del ordering is probably wrong, patch up |
680 | | - if mutated: |
681 | | - post_proc = postproc.PostProcessor(func_ir) |
682 | | - post_proc.run() |
683 | | - |
684 | | - return mutated |
685 | | - |
686 | | - |
687 | 620 | @register_pass(mutates_CFG=True, analysis_only=False) |
688 | 621 | class TransformLiteralUnrollConstListToTuple(FunctionPass): |
689 | 622 | """This pass spots a `literal_unroll([<constant values>])` and rewrites it |
|
0 commit comments