|
1 | 1 | from __future__ import print_function, division, absolute_import |
2 | 2 | import types as pytypes # avoid confusion with numba.types |
3 | | - |
| 3 | +import collections |
4 | 4 | import numba |
5 | 5 | from numba import ir, config, ir_utils, types |
6 | 6 | from numba import compiler as numba_compiler |
@@ -78,6 +78,7 @@ def run(self): |
78 | 78 | self.typemap, self.return_type, self.calltypes = numba_compiler.type_inference_stage( |
79 | 79 | self.typingctx, self.func_ir, self.args, None) |
80 | 80 | self.fix_series_filter(self.func_ir.blocks) |
| 81 | + self.func_ir._definitions = _get_definitions(self.func_ir.blocks) |
81 | 82 | dprint_func_ir(self.func_ir, "after hiframes") |
82 | 83 | if config.DEBUG_ARRAY_OPT==1: |
83 | 84 | print("df_vars: ", self.df_vars) |
@@ -535,3 +536,11 @@ def include_new_blocks(blocks, new_blocks, label, new_body): |
535 | 536 | inner_blocks[inner_last_label].body.append(ir.Jump(label, loc)) |
536 | 537 | #new_body.clear() |
537 | 538 | return label |
| 539 | + |
| 540 | +def _get_definitions(blocks): |
| 541 | + definitions = collections.defaultdict(list) |
| 542 | + for block in blocks.values(): |
| 543 | + for inst in block.body: |
| 544 | + if isinstance(inst, ir.Assign): |
| 545 | + definitions[inst.target.name].append(inst.value) |
| 546 | + return definitions |
0 commit comments