Skip to content

Commit

Permalink
transforms.llvm_ir_generator: ignore assignments of None (fixes #309).
Browse files Browse the repository at this point in the history
whitequark committed Mar 1, 2016
1 parent c7d48a1 commit 7e16da4
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -655,8 +655,11 @@ def process_GetConstructor(self, insn):

def process_SetLocal(self, insn):
env = insn.environment()
llptr = self.llptr_to_var(self.map(env), env.type, insn.var_name)
llvalue = self.map(insn.value())
if isinstance(llvalue.type, ll.VoidType):
# We store NoneType as {} but return it as void. So, bail out here.
return ll.Constant(ll.LiteralStructType([]), [])
llptr = self.llptr_to_var(self.map(env), env.type, insn.var_name)
if isinstance(llvalue, ll.Block):
llvalue = ll.BlockAddress(self.llfunction, llvalue)
if llptr.type.pointee != llvalue.type:
6 changes: 6 additions & 0 deletions artiq/test/lit/codegen/assign_none.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.llvmgen %s

def f():
pass
def g():
a = f()

0 comments on commit 7e16da4

Please sign in to comment.