comparison python/transform.py @ 225:1c7364bd74c7

Fixed pointer deref
author Windel Bouwman
date Thu, 11 Jul 2013 07:42:30 +0200
parents 1fa3e0050b49
children ff40407c0240
comparison
equal deleted inserted replaced
224:5af52987f5bd 225:1c7364bd74c7
87 if len(bb.Instructions) == 1: 87 if len(bb.Instructions) == 1:
88 # This block is empty. 88 # This block is empty.
89 # find predecessors of this block and replace this block reference with the jumped reference. 89 # find predecessors of this block and replace this block reference with the jumped reference.
90 ins = bb.LastInstruction 90 ins = bb.LastInstruction
91 if type(ins) is Branch: 91 if type(ins) is Branch:
92 print('Removing block {}'.format(bb))
93 #print(ins, bb.Predecessors)
94 preds = bb.Predecessors 92 preds = bb.Predecessors
95 if bb in preds: 93 if bb in preds:
96 # Do not remove if preceeded by itself 94 # Do not remove if preceeded by itself
97 pass 95 pass
98 else: 96 else:
99 for pred in bb.Predecessors: 97 for pred in bb.Predecessors:
100 print('predecessor: {}'.format(pred))
101 pred.LastInstruction.changeTarget(bb, ins.target) 98 pred.LastInstruction.changeTarget(bb, ins.target)
102 f.removeBasicBlock(bb) 99 f.removeBasicBlock(bb)
103 100
104 class Mem2RegPromotor(FunctionPass): 101 class Mem2RegPromotor(FunctionPass):
105 def onFunction(self, f): 102 def onFunction(self, f):