From fec5c2ebf00b7bbf2619523ff45fe077265eb608 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 24 Nov 2015 02:52:41 +0800 Subject: [PATCH] transforms.interleaver: add a diagnostic for interleave inlining failure. --- artiq/compiler/transforms/interleaver.py | 10 ++++++++++ lit-test/test/interleaving/error_inlining.py | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lit-test/test/interleaving/error_inlining.py diff --git a/artiq/compiler/transforms/interleaver.py b/artiq/compiler/transforms/interleaver.py index 873e55eac..4aa3c327b 100644 --- a/artiq/compiler/transforms/interleaver.py +++ b/artiq/compiler/transforms/interleaver.py @@ -3,6 +3,8 @@ the timestamp would always monotonically nondecrease. """ +from pythonparser import diagnostic + from .. import types, builtins, ir, iodelay from ..analyses import domination from ..algorithms import inline @@ -127,6 +129,14 @@ class Interleaver: else: # It's a call. need_to_inline = len(source_blocks) > 1 if need_to_inline: + if old_decomp.static_target_function is None: + diag = diagnostic.Diagnostic("fatal", + "it is not possible to interleave this function call within " + "a 'with parallel:' statement because the compiler could not " + "prove that the same function would always be called", {}, + old_decomp.loc) + self.engine.process(diag) + inline(old_decomp) postdom_tree = domination.PostDominatorTree(func) continue diff --git a/lit-test/test/interleaving/error_inlining.py b/lit-test/test/interleaving/error_inlining.py new file mode 100644 index 000000000..c34959a51 --- /dev/null +++ b/lit-test/test/interleaving/error_inlining.py @@ -0,0 +1,16 @@ +# RUN: %python -m artiq.compiler.testbench.signature +diag %s >%t +# RUN: OutputCheck %s --file-to-check=%t + +def f(): + delay_mu(2) + +def g(): + delay_mu(2) + +x = f if True else g + +def h(): + with parallel: + f() + # CHECK-L: ${LINE:+1}: fatal: it is not possible to interleave this function call within a 'with parallel:' statement because the compiler could not prove that the same function would always be called + x()