Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inliners to run all passes on IR and clean up correctly. #5673

Merged
merged 4 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 57 additions & 22 deletions numba/core/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,68 @@ class DefaultPassBuilder(object):
- nopython
- objectmode
- interpreted
- typed
- untyped
- nopython lowering
"""
@staticmethod
def define_nopython_pipeline(state, name='nopython'):
"""Returns an nopython mode pipeline based PassManager
"""
# compose pipeline from untyped, typed and lowering parts
dpb = DefaultPassBuilder
pm = PassManager(name)
untyped_passes = dpb.define_untyped_pipeline(state)
pm.passes.extend(untyped_passes.passes)

typed_passes = dpb.define_typed_pipeline(state)
pm.passes.extend(typed_passes.passes)

lowering_passes = dpb.define_nopython_lowering_pipeline(state)
pm.passes.extend(lowering_passes.passes)

pm.finalize()
return pm

@staticmethod
def define_nopython_lowering_pipeline(state, name='nopython_lowering'):
pm = PassManager(name)
# legalise
pm.add_pass(IRLegalization,
"ensure IR is legal prior to lowering")

# lower
pm.add_pass(NoPythonBackend, "nopython mode backend")
pm.add_pass(DumpParforDiagnostics, "dump parfor diagnostics")
pm.finalize()
return pm

@staticmethod
def define_typed_pipeline(state, name="typed"):
"""Returns the typed part of the nopython pipeline"""
pm = PassManager(name)
# typing
pm.add_pass(NopythonTypeInference, "nopython frontend")
pm.add_pass(AnnotateTypes, "annotate types")

# strip phis
pm.add_pass(PreLowerStripPhis, "remove phis nodes")

# optimisation
pm.add_pass(InlineOverloads, "inline overloaded functions")
if state.flags.auto_parallel.enabled:
pm.add_pass(PreParforPass, "Preprocessing for parfors")
if not state.flags.no_rewrites:
pm.add_pass(NopythonRewrites, "nopython rewrites")
if state.flags.auto_parallel.enabled:
pm.add_pass(ParforPass, "convert to parfors")

pm.finalize()
return pm

@staticmethod
def define_untyped_pipeline(state, name='untyped'):
"""Returns an untyped part of the nopython pipeline"""
pm = PassManager(name)
if state.func_ir is None:
pm.add_pass(TranslateByteCode, "analyzing bytecode")
Expand Down Expand Up @@ -471,29 +528,7 @@ def define_nopython_pipeline(state, name='nopython'):

if state.flags.enable_ssa:
pm.add_pass(ReconstructSSA, "ssa")
# typing
pm.add_pass(NopythonTypeInference, "nopython frontend")
pm.add_pass(AnnotateTypes, "annotate types")

# strip phis
pm.add_pass(PreLowerStripPhis, "remove phis nodes")

# optimisation
pm.add_pass(InlineOverloads, "inline overloaded functions")
if state.flags.auto_parallel.enabled:
pm.add_pass(PreParforPass, "Preprocessing for parfors")
if not state.flags.no_rewrites:
pm.add_pass(NopythonRewrites, "nopython rewrites")
if state.flags.auto_parallel.enabled:
pm.add_pass(ParforPass, "convert to parfors")

# legalise
pm.add_pass(IRLegalization,
"ensure IR is legal prior to lowering")

# lower
pm.add_pass(NoPythonBackend, "nopython mode backend")
pm.add_pass(DumpParforDiagnostics, "dump parfor diagnostics")
pm.finalize()
return pm

Expand Down