transforms.llvm_ir_generator: ignore assignments of None (fixes #309).

This commit is contained in:
whitequark 2016-03-01 12:26:18 +00:00
parent c7d48a1765
commit 7e16da4a77
2 changed files with 10 additions and 1 deletions

View File

@ -655,8 +655,11 @@ class LLVMIRGenerator:
def process_SetLocal(self, insn): def process_SetLocal(self, insn):
env = insn.environment() env = insn.environment()
llptr = self.llptr_to_var(self.map(env), env.type, insn.var_name)
llvalue = self.map(insn.value()) 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): if isinstance(llvalue, ll.Block):
llvalue = ll.BlockAddress(self.llfunction, llvalue) llvalue = ll.BlockAddress(self.llfunction, llvalue)
if llptr.type.pointee != llvalue.type: if llptr.type.pointee != llvalue.type:

View File

@ -0,0 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.llvmgen %s
def f():
pass
def g():
a = f()