Skip to content

Commit 0a60d27

Browse files
committed
Remove MakeFunctionToJitFunction pass, which implicitly uses njit, not a use case we intend to support
1 parent c28b063 commit 0a60d27

File tree

2 files changed

+0
-73
lines changed

2 files changed

+0
-73
lines changed

numba_cuda/numba/cuda/compiler.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
WithLifting,
4949
InlineInlinables,
5050
FindLiterallyCalls,
51-
MakeFunctionToJitFunction,
5251
LiteralUnroll,
5352
ReconstructSSA,
5453
RewriteDynamicRaises,
@@ -225,11 +224,6 @@ def define_untyped_pipeline(state, name="untyped"):
225224

226225
pm.add_pass(RewriteDynamicRaises, "rewrite dynamic raises")
227226

228-
# convert any remaining closures into functions
229-
pm.add_pass(
230-
MakeFunctionToJitFunction,
231-
"convert make_function into JIT functions",
232-
)
233227
# inline functions that have been determined as inlinable and rerun
234228
# branch pruning, this needs to be run after closures are inlined as
235229
# the IR repr of a closure masks call sites if an inlinable is called

numba_cuda/numba/cuda/core/untyped_passes.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
resolve_func_from_module,
3636
simplify_CFG,
3737
GuardException,
38-
convert_code_obj_to_function,
3938
build_definitions,
4039
replace_var_names,
4140
get_name_var_table,
@@ -618,72 +617,6 @@ def run_pass(self, state):
618617
return False
619618

620619

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-
687620
@register_pass(mutates_CFG=True, analysis_only=False)
688621
class TransformLiteralUnrollConstListToTuple(FunctionPass):
689622
"""This pass spots a `literal_unroll([<constant values>])` and rewrites it

0 commit comments

Comments
 (0)