Skip to content

Commit

Permalink
Another way to fix all the things in numba#5673
Browse files Browse the repository at this point in the history
But less involved.
  • Loading branch information
stuartarchibald committed May 5, 2020
1 parent 86e600d commit 94f6bb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
26 changes: 17 additions & 9 deletions numba/core/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ def run_frontend(func, inline_closures=False, emit_dels=False):
inline_pass = InlineClosureCallPass(func_ir, cpu.ParallelOptions(False),
{}, False)
inline_pass.run()
from numba.core.untyped_passes import GenericRewrites
sd = StateDict()
sd['func_ir'] = func_ir
sd['func_id'] = func_id
sd['status'] = _CompileStatus(False, True)
sd['typemap'] = {}
sd['calltypes'] = {}
GenericRewrites().run_pass(sd)
post_proc = postproc.PostProcessor(func_ir)
post_proc.run(emit_dels)
return func_ir
Expand Down Expand Up @@ -445,6 +453,15 @@ def define_nopython_pipeline(state, name='nopython'):
pm.add_pass(TranslateByteCode, "analyzing bytecode")
pm.add_pass(FixupArgs, "fix up args")
pm.add_pass(IRProcessing, "processing IR")
pm.add_pass(InlineClosureLikes,
"inline calls to locally defined closures")
# inline functions that have been determined as inlinable and rerun
# branch pruning, this needs to be run after closures are inlined as
# the IR repr of a closure masks call sites if an inlinable is called
# inside a closure
pm.add_pass(InlineInlinables, "inline inlinable functions")
if not state.flags.no_rewrites:
pm.add_pass(DeadBranchPrune, "dead branch pruning")
pm.add_pass(WithLifting, "Handle with contexts")

# pre typing
Expand All @@ -453,18 +470,9 @@ def define_nopython_pipeline(state, name='nopython'):
pm.add_pass(DeadBranchPrune, "dead branch pruning")
pm.add_pass(GenericRewrites, "nopython rewrites")

pm.add_pass(InlineClosureLikes,
"inline calls to locally defined closures")
# convert any remaining closures into functions
pm.add_pass(MakeFunctionToJitFunction,
"convert make_function into JIT functions")
# inline functions that have been determined as inlinable and rerun
# branch pruning, this needs to be run after closures are inlined as
# the IR repr of a closure masks call sites if an inlinable is called
# inside a closure
pm.add_pass(InlineInlinables, "inline inlinable functions")
if not state.flags.no_rewrites:
pm.add_pass(DeadBranchPrune, "dead branch pruning")

pm.add_pass(FindLiterallyCalls, "find literally calls")
pm.add_pass(LiteralUnroll, "handles literal_unroll")
Expand Down
3 changes: 3 additions & 0 deletions numba/core/inline_closurecall.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def run(self):
_fix_nested_array(self.func_ir)

if modified:
cfg = compute_cfg_from_blocks(self.func_ir.blocks)
for dead in cfg.dead_nodes():
del self.func_ir.blocks[dead]
# run dead code elimination
dead_code_elimination(self.func_ir)
# do label renaming
Expand Down

0 comments on commit 94f6bb2

Please sign in to comment.