forked from M-Labs/artiq
1
0
Fork 0

Make compiler.ir.BasicBlock.predecessors much faster.

This commit is contained in:
whitequark 2015-07-18 20:48:11 +03:00
parent 47cbadb564
commit 224a93fde3
1 changed files with 1 additions and 5 deletions

View File

@ -303,8 +303,7 @@ class BasicBlock(NamedValue):
return self.terminator().successors() return self.terminator().successors()
def predecessors(self): def predecessors(self):
assert self.function is not None return [use.basic_block for use in self.uses if isinstance(use, Terminator)]
return self.function.predecessors_of(self)
def __str__(self): def __str__(self):
# Header # Header
@ -384,9 +383,6 @@ class Function:
basic_block._detach() basic_block._detach()
self.basic_blocks.remove(basic_block) 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): def __str__(self):
printer = types.TypePrinter() printer = types.TypePrinter()