def check(self, fn, signature, args, expected_result, must_be_removed=True, inline=None): remover = self.MallocRemover() t = TranslationContext() t.buildannotator().build_types(fn, signature) t.buildrtyper().specialize() graph = graphof(t, fn) if inline is not None: from rpython.translator.backendopt.inline import auto_inline_graphs auto_inline_graphs(t, t.graphs, inline) if option.view: t.view() # to detect broken intermediate graphs, # we do the loop ourselves instead of calling remove_simple_mallocs() while True: progress = remover.remove_mallocs_once(graph) simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks()), [graph]) if progress and option.view: t.view() if expected_result is not Ellipsis: interp = LLInterpreter(t.rtyper) res = interp.eval_graph(graph, args) assert res == expected_result if not progress: break if must_be_removed: self.check_malloc_removed(graph) return graph
def transform_dead_op_vars(ann, block_subset): # we redo the same simplification from simplify.py, # to kill dead (never-followed) links, # which can possibly remove more variables. from rpython.translator.simplify import transform_dead_op_vars_in_blocks transform_dead_op_vars_in_blocks(block_subset, ann.translator.graphs, ann.translator)
def transform_dead_op_vars(self, block_subset): # we redo the same simplification from simplify.py, # to kill dead (never-followed) links, # which can possibly remove more variables. from rpython.translator.simplify import transform_dead_op_vars_in_blocks transform_dead_op_vars_in_blocks(block_subset, self.translator.graphs)