Ohh, another issue.
Having an input intermediate: #(#block 1 #(#push #ebp) #(#mov #esp #ebp)) #(#block 3 #(#mov #(#mem #(#add #ebp -4)) 't1') #(#mov #(#mem #(#add #ebp -8)) 't2')) #(#block 5 #(#mov #(#add 't1' 't2') 't3') #(#jmp #block4)) #(#block 4) #(#block 6 #(#mov 't3' #eax) #(#jmp #block2)) #(#block 2 #(#mov #ebp #esp) #(#pop #ebp) #(#ret))
after running LowLevelOptimizer and InstructionSelector i got:
#(#block 1 #(#push #ebp) #(#mov #esp #ebp)) #(#block 3 #(#mov #(-4 #ebp) 't1') #(#mov #(-8 #ebp) 't2')) #(#block 5 #(#mov 't2' 't4') #(#add 't1' 't4') #(#mov 't4' 't3') #(#jmp #block4)) #(#block 4) #(#block 6 #(#mov 't3' #eax) #(#jmp #block2)) #(#block 2 #(#mov #ebp #esp) #(#pop #ebp) #(#ret))
and then after coloring register allocator: #(#(#block 1 #(#push #ebp) #(#mov #esp #ebp)) #(#block 3 #(#mov #(-4 #ebp) #eax) #(#mov #(-8 #ebp) #eax)) #(#block 5 #(#add #ebx #eax) #(#jmp #block4)) #(#block 4) #(#block 6 #(#jmp #block2)) #(#block 2 #(#mov #ebp #esp) #(#pop #ebp) #(#ret)))
take a look at block3 , as you see it chooses #eax for replacing temporary registers in both instructions (which is wrong of course) and then in block5 , it seems thinks that there was #ebx used in one of them.