Commit 2b9cc393 authored by John Zhang's avatar John Zhang

fix: leave NULL constants as constants, rather than loading a NULL value from global cell.

parent 7cc45097
......@@ -168,7 +168,7 @@ class MuTyper:
assert mutype.mutypeOf(muv) == MuT
if isinstance(muv, mutype._muobject_reference):
if isinstance(muv, mutype._muobject_reference) and not muv._is_null():
GCl_T = mutype.MuGlobalCell(MuT)
if id(muv) in self._objrefid2gcl_dic:
gcl = self._objrefid2gcl_dic[id(muv)]
......@@ -328,3 +328,18 @@ def test_pass_heap_obj_in_link_arg():
op = blk.operations[-2] # load from global cell in second last
assert op.opname == 'mu_load'
assert isinstance(op.args[0].concretetype, mutype.MuGlobalCell)
def test_NULL_const():
from rpython.rtyper.lltypesystem.rstr import STR
def f():
return lltype.nullptr(STR)
t = Translation(f, [], backend='mu')
g = graph_of(f, t)
assert len(g.startblock.operations) == 1
assert g.startblock.operations[0].opname == 'mu_branch'
arg = g.startblock.operations[0].args[0].value.args[0]
assert isinstance(arg, Constant)
assert arg.value._is_null()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment