mirror of https://github.com/m-labs/artiq.git
Make compiler.ir.BasicBlock.predecessors much faster.
This commit is contained in:
parent
47cbadb564
commit
224a93fde3
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue