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
f4d331d05d
commit
5dc3b3b28c
|
@ -1462,6 +1462,11 @@ class LLVMIRGenerator:
|
||||||
else:
|
else:
|
||||||
llcall = llresult = self.llbuilder.call(llfun, llargs, name=insn.name)
|
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!
|
# Never add TBAA nowrite metadata to a functon with sret!
|
||||||
# This leads to miscompilations.
|
# This leads to miscompilations.
|
||||||
if types.is_c_function(functiontyp) and 'nowrite' in functiontyp.flags:
|
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