Skip to content

Commit f7b64db

Browse files
author
whitequark
committedAug 9, 2015
LLVMIRGenerator: fixup phis on expansion of ARTIQ instructions.
1 parent d4270cf commit f7b64db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self, engine, module_name, target):
1717
self.llmodule.data_layout = target.data_layout
1818
self.llfunction = None
1919
self.llmap = {}
20+
self.llblock_map = {}
2021
self.fixups = []
2122

2223
def llty_of_type(self, typ, bare=False, for_return=False):
@@ -229,6 +230,13 @@ def process_function(self, func):
229230
assert llinsn is not None
230231
self.llmap[insn] = llinsn
231232

233+
# There is no 1:1 correspondence between ARTIQ and LLVM
234+
# basic blocks, because sometimes we expand a single ARTIQ
235+
# instruction so that the result spans several LLVM basic
236+
# blocks. This only really matters for phis, which will
237+
# use a different map.
238+
self.llblock_map[block] = self.llbuilder.basic_block
239+
232240
# Fourth, fixup phis.
233241
for fixup in self.fixups:
234242
fixup()
@@ -241,7 +249,7 @@ def process_Phi(self, insn):
241249
llinsn = self.llbuilder.phi(self.llty_of_type(insn.type), name=insn.name)
242250
def fixup():
243251
for value, block in insn.incoming():
244-
llinsn.add_incoming(self.map(value), self.map(block))
252+
llinsn.add_incoming(self.map(value), self.llblock_map[block])
245253
self.fixups.append(fixup)
246254
return llinsn
247255

0 commit comments

Comments
 (0)
Please sign in to comment.