def __apply_copy_propagation(self, func): graph = func.graph for block in graph: block_id = block.get_id() before = CopyState() for pre in graph.get_predecessor_ids(block_id): before.join(self.__outs[pre]) # print(before.mapping) for instruction in block: before.apply_mapping(instruction) before.add_mapping(instruction)
def __compute_copy_states(self, func): graph = func.graph for block in graph: block_id = block.get_id() self.__outs[block_id] = CopyState() change = True while change: change = False for block in graph: block_id = block.get_id() new_out = CopyState() for pre in graph.get_predecessor_ids(block_id): new_out.join(self.__outs[pre]) for instruction in block: new_out.add_mapping(instruction) if not (self.__outs[block_id] == new_out): self.__outs[block_id] = new_out change = True