mirror of https://github.com/m-labs/artiq.git
compiler: Handle None-returning function calls used as values
GitHub: Fixes #1493.
This commit is contained in:
parent
57e759a1ed
commit
1c72585c1b
|
@ -1481,6 +1481,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:
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue