Skip to content

Commit f2f1deb

Browse files
author
whitequark
committedJan 7, 2016
transforms.llvm_ir_generator: quote recrusive objects correctly (fixes #213).
1 parent 027d54c commit f2f1deb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

Diff for: ‎artiq/compiler/transforms/llvm_ir_generator.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1123,21 +1123,23 @@ def _quote(self, value, typ, path):
11231123
llty = self.llty_of_type(typ)
11241124

11251125
if types.is_constructor(typ) or types.is_instance(typ):
1126+
llglobal = None
11261127
llfields = []
11271128
for attr in typ.attributes:
11281129
if attr == "__objectid__":
11291130
objectid = self.object_map.store(value)
11301131
llfields.append(ll.Constant(lli32, objectid))
1131-
global_name = "object.{}".format(objectid)
1132+
1133+
assert llglobal is None
1134+
llglobal = ll.GlobalVariable(self.llmodule, llty.pointee,
1135+
name="object.{}".format(objectid))
1136+
self.llobject_map[value_id] = llglobal
11321137
else:
11331138
llfields.append(self._quote(getattr(value, attr), typ.attributes[attr],
11341139
lambda: path() + [attr]))
1135-
llconst = ll.Constant(llty.pointee, llfields)
11361140

1137-
llglobal = ll.GlobalVariable(self.llmodule, llconst.type, global_name)
1138-
llglobal.initializer = llconst
1141+
llglobal.initializer = ll.Constant(llty.pointee, llfields)
11391142
llglobal.linkage = "private"
1140-
self.llobject_map[value_id] = llglobal
11411143
return llglobal
11421144
elif builtins.is_none(typ):
11431145
assert value is None

0 commit comments

Comments
 (0)
Please sign in to comment.