compiler: Handle None-returning function calls used as values

GitHub: Fixes #1493.
This commit is contained in:
David Nadlinger 2020-07-25 02:18:10 +01:00 committed by Sebastien Bourdeauducq
parent f4d331d05d
commit 5dc3b3b28c
2 changed files with 16 additions and 0 deletions

View File

@ -1462,6 +1462,11 @@ class LLVMIRGenerator:
else:
llcall = llresult = self.llbuilder.call(llfun, llargs, name=insn.name)
if isinstance(llresult.type, ll.VoidType):
# We have NoneType-returning functions return void, but None is
# {} elsewhere.
llresult = ll.Constant(llunit, [])
# Never add TBAA nowrite metadata to a functon with sret!
# This leads to miscompilations.
if types.is_c_function(functiontyp) and 'nowrite' in functiontyp.flags:

View File

@ -0,0 +1,11 @@
# RUN: %python -m artiq.compiler.testbench.llvmgen %s
def make_none():
return None
def take_arg(arg):
pass
def run():
retval = make_none()
take_arg(retval)