In function convertInstTo3Addr, after converting a two address instruction into three address instruction, only the last new instruction is inserted into DistanceMap. This is wrong, DistanceMap should track all instructions from the beginning of current MBB to the working instruction. When a two address instruction is converted to three address instruction, multiple instructions may be generated (usually an extra COPY is generated), all of them should be inserted into DistanceMap.
Similarly when unfolding memory operand in function tryInstructionTransform DistanceMap is not maintained correctly.
This does seem correct to me. The input in line 88 is
%10:gr16 = ADD16rr killed %3:gr16($di), killed %5:gr16, ...
But the output turns into add [[COPY4]]($esi)?