From 9bc62fa3d2de9964b1109c538f083aea93f2c51d Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 24 Nov 2015 00:46:26 +0800 Subject: [PATCH] transforms.iodelay_estimator: correctly handle functions with empty body. --- artiq/compiler/iodelay.py | 1 + artiq/compiler/transforms/iodelay_estimator.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/iodelay.py b/artiq/compiler/iodelay.py index bdf96b46a..3a3283199 100644 --- a/artiq/compiler/iodelay.py +++ b/artiq/compiler/iodelay.py @@ -208,6 +208,7 @@ class Max(Expr): def __init__(self, operands): assert isinstance(operands, list) assert all([isinstance(operand, Expr) for operand in operands]) + assert operands != [] self.operands = operands def __str__(self): diff --git a/artiq/compiler/transforms/iodelay_estimator.py b/artiq/compiler/transforms/iodelay_estimator.py index 21d2d9616..4170094c0 100644 --- a/artiq/compiler/transforms/iodelay_estimator.py +++ b/artiq/compiler/transforms/iodelay_estimator.py @@ -220,7 +220,8 @@ class IODelayEstimator(algorithm.Visitor): delays.append(self.current_delay) self.current_delay = old_delay - self.current_delay += iodelay.Max(delays) + if any(delays): + self.current_delay += iodelay.Max(delays) except _IndeterminateDelay as error: # Interleave failures inside `with` statements are hard failures, # since there's no chance that the code will never actually execute