diff --git a/artiq/compiler/types.py b/artiq/compiler/types.py index 25a8e9699..f5adf79e5 100644 --- a/artiq/compiler/types.py +++ b/artiq/compiler/types.py @@ -610,8 +610,13 @@ def is_function(typ): def is_rpc_function(typ): return isinstance(typ.find(), TRPCFunction) -def is_c_function(typ): - return isinstance(typ.find(), TCFunction) +def is_c_function(typ, name=None): + typ = typ.find() + if name is None: + return isinstance(typ, TCFunction) + else: + return isinstance(typ, TCFunction) and \ + typ.name == name def is_builtin(typ, name=None): typ = typ.find() diff --git a/artiq/compiler/validators/escape.py b/artiq/compiler/validators/escape.py index 346f0c130..857fcd02a 100644 --- a/artiq/compiler/validators/escape.py +++ b/artiq/compiler/validators/escape.py @@ -87,7 +87,13 @@ class RegionOf(algorithm.Visitor): return None visit_BinOpT = visit_sometimes_allocating - visit_CallT = visit_sometimes_allocating + + def visit_CallT(self, node): + if types.is_c_function(node.func.type, "cache_get"): + # The cache is borrow checked dynamically + return None + else: + self.visit_sometimes_allocating(node) # Value lives as long as the object/container, if it's mutable, # or else forever