[Refactor] Some cleaning up of OptPass2JMP and OptPass2MOV
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
These two patches, while not fixing any known bugs, aim to fix a couple of issues that might affect the maintainability and extensibility of the x86 Peephole Optimizer in the future. See Additional Information for more details.
Steps to reproduce:
Apply patches, verify that code has less 'smell' and is potentially safer, and confirm that the binaries of independent code built by the compiler haven't changed.
Additional information:
OptPass2JMP - this patch adds calls to 'AllocRegBetween' for the 'JMP -> MOV/RET' optimisation, so the registers referenced by the duplicated MOV instruction are properly tracked.
OptPass2MOV - honestly, I don't know what I was thinking here other than 'micro-optimisation'! I stripped out some code that does some trickery based on some assumptions about the upcoming instructions (which are generally rather sound) and the flow of the Peephole Optimizer... all to avoid calling OptPass2JMP on a jump that previous knowledge has determined will return False. The main thing is that if a future change is made so Pass 2 is called multiple times, or it jumps back to Pass 1, the trick would have potentially caused an infinite loop.
Mantis conversion info:
- Mantis ID: 36553
- OS: Microsoft Windows
- OS Build: 10 Professional
- Build: r43909
- Platform: i386 and x86_64
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 43919 (#2b70c64d)