From 224a93fde32b0f66b4a538a3d95cd64dc87054ca Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 18 Jul 2015 20:48:11 +0300 Subject: [PATCH] Make compiler.ir.BasicBlock.predecessors much faster. --- artiq/compiler/ir.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/artiq/compiler/ir.py b/artiq/compiler/ir.py index cc8fda5cc..3b77db9b7 100644 --- a/artiq/compiler/ir.py +++ b/artiq/compiler/ir.py @@ -303,8 +303,7 @@ class BasicBlock(NamedValue): return self.terminator().successors() def predecessors(self): - assert self.function is not None - return self.function.predecessors_of(self) + return [use.basic_block for use in self.uses if isinstance(use, Terminator)] def __str__(self): # Header @@ -384,9 +383,6 @@ class Function: basic_block._detach() self.basic_blocks.remove(basic_block) - def predecessors_of(self, successor): - return [block for block in self.basic_blocks - if block.is_terminated() and successor in block.successors()] def __str__(self): printer = types.TypePrinter()