forked from M-Labs/artiq
1
0
Fork 0

compiler: don't crash when quoting builtin functions.

Fixes #1051.
This commit is contained in:
whitequark 2018-06-05 23:23:40 +00:00
parent c28fe47164
commit 38dac16041
3 changed files with 15 additions and 2 deletions

View File

@ -1546,8 +1546,8 @@ class LLVMIRGenerator:
lleltsptr = llglobal.bitcast(lleltsary.type.element.as_pointer())
llconst = ll.Constant(llty, [lleltsptr, ll.Constant(lli32, len(llelts))])
return llconst
elif types.is_rpc(typ) or types.is_c_function(typ):
# RPC and C functions have no runtime representation.
elif types.is_rpc(typ) or types.is_c_function(typ) or types.is_builtin_function(typ):
# RPC, C and builtin functions have no runtime representation.
return ll.Constant(llty, ll.Undefined)
elif types.is_function(typ):
try:

View File

@ -605,6 +605,14 @@ def is_builtin(typ, name=None):
return isinstance(typ, TBuiltin) and \
typ.name == name
def is_builtin_function(typ, name=None):
typ = typ.find()
if name is None:
return isinstance(typ, TBuiltinFunction)
else:
return isinstance(typ, TBuiltinFunction) and \
typ.name == name
def is_constructor(typ, name=None):
typ = typ.find()
if name is not None:

View File

@ -211,6 +211,10 @@ class _RPCCalls(EnvExperiment):
def numpy_full(self):
return numpy.full(10, 20)
@kernel
def numpy_nan(self):
return numpy.full(10, numpy.nan)
@kernel
def builtin(self):
sleep(1.0)
@ -229,6 +233,7 @@ class RPCCallsTest(ExperimentCase):
self.assertEqual(exp.numpy_things(),
(numpy.int32(10), numpy.int64(20), numpy.array([42,])))
self.assertTrue((exp.numpy_full() == numpy.full(10, 20)).all())
self.assertTrue(numpy.isnan(exp.numpy_nan()).all())
exp.builtin()