Skip to content

Commit

Permalink
compiler: skip functional values in attribute writeback.
Browse files Browse the repository at this point in the history
Fixes #1088.
  • Loading branch information
whitequark committed Aug 10, 2018
1 parent 052e400 commit fab6e5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
14 changes: 9 additions & 5 deletions artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,10 @@ def rpc_tag_error(typ):
print(typ)
assert False

if not (types.is_function(typ) or types.is_method(typ) or types.is_rpc(typ) or
name == "__objectid__"):
rpctag = b"Os" + self._rpc_tag(typ, error_handler=rpc_tag_error) + b":n"
else:
if name == "__objectid__":
rpctag = b""
else:
rpctag = b"Os" + self._rpc_tag(typ, error_handler=rpc_tag_error) + b":n"

llrpcattrinit = ll.Constant(llrpcattrty, [
ll.Constant(lli32, offset),
Expand Down Expand Up @@ -562,7 +561,10 @@ def rpc_tag_error(typ):
offset += alignment - (offset % alignment)

if types.is_instance(typ) and attr not in typ.constant_attributes:
llrpcattrs.append(llrpcattr_of_attr(offset, attr, attrtyp))
try:
llrpcattrs.append(llrpcattr_of_attr(offset, attr, attrtyp))
except ValueError:
continue

offset += size

Expand Down Expand Up @@ -1267,6 +1269,8 @@ def _rpc_tag(self, typ, error_handler):
elif ir.is_keyword(typ):
return b"k" + self._rpc_tag(typ.params["value"],
error_handler)
elif types.is_function(typ) or types.is_method(typ) or types.is_rpc(typ):
raise ValueError("RPC tag for functional value")
elif '__objectid__' in typ.attributes:
return b"O"
else:
Expand Down
15 changes: 15 additions & 0 deletions artiq/test/lit/embedding/fn_ptr_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# RUN: %python -m artiq.compiler.testbench.embedding %s

from artiq.language.core import *
from artiq.language.types import *

@kernel
def a():
pass

fns = [a, a]

@kernel
def entrypoint():
fns[0]()
fns[1]()

0 comments on commit fab6e5c

Please sign in to comment.