From ae999db8f6814c63eae563aca69276feb59d305d Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 30 Jul 2020 16:40:23 +0100 Subject: [PATCH] compiler: Revert function call lifetime tracking fix This reverts commits f8d15069227298492ce539d793cfedfd8a80874c and cf19c9512dd41831bb5643025b9f3349c0828d83. While the commit just fixes a clear typo in the implementation, it turns out the original algorithm isn't flexible enough to capture functions that transitively return references to long-lived data. For instance, while cache_get() is special-cased in the compiler to be recognised as returning a value of Global() lifetime, a function just forwarding to it (as seen in the embedding tests) isn't anymore. A separate issue is also that this makes implementing functions that take lists and return references to global data in user code impossible, which central parts of the Oxford codebase rely on. Just reverting for now to unblock master; a fix is easily designed, but needs testing. --- RELEASE_NOTES.rst | 3 --- artiq/compiler/validators/escape.py | 2 +- artiq/test/lit/escape/error_call.py | 14 -------------- 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 artiq/test/lit/escape/error_call.py diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index d1f88b15f..7b9899d71 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -24,9 +24,6 @@ Highlights: * Core device: ``panic_reset 1`` now correctly resets the kernel CPU as well if communication CPU panic occurs. * NumberValue accepts a ``type`` parameter specifying the output as ``int`` or ``float`` -* In kernels, lifetime of allocated values (e.g. lists) is now correctly tracked across - function calls (see #1497, #1394). Previous versions (since ARTIQ 1.0) would accept - illegal code that would result in silent memory corruption at runtime. Breaking changes: diff --git a/artiq/compiler/validators/escape.py b/artiq/compiler/validators/escape.py index 5aae58e51..000c3ee5b 100644 --- a/artiq/compiler/validators/escape.py +++ b/artiq/compiler/validators/escape.py @@ -103,7 +103,7 @@ class RegionOf(algorithm.Visitor): # The cache is borrow checked dynamically return Global() else: - return self.visit_sometimes_allocating(node) + self.visit_sometimes_allocating(node) # Value lives as long as the object/container, if it's mutable, # or else forever diff --git a/artiq/test/lit/escape/error_call.py b/artiq/test/lit/escape/error_call.py deleted file mode 100644 index 8bbc7992f..000000000 --- a/artiq/test/lit/escape/error_call.py +++ /dev/null @@ -1,14 +0,0 @@ -# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t -# RUN: OutputCheck %s --file-to-check=%t - -from artiq.experiment import * - -@kernel -def leak(a): - return a - -@kernel -def entrypoint(): - # CHECK-L: ${LINE:+2}: error: cannot return an allocated value that does not live forever - # CHECK-L: ${LINE:+1}: note: ... to this point - return leak([1, 2, 3])