This fixes https://github.com/llvm/llvm-project/issues/60766
With MSVC style exception-handling (funclets), no registers are alive when entering the funclet so they must be reloaded from the stack. MachineLICM can sometimes hoist such reloads out of the funclet which is not correct, the register will have been clobbered when entering the funclet. This can happen in any loop that contains a try-catch.
This has been tested on x86_64-pc-window-msvc. I'm not sure if funclets work the same on the other windows archs.
(This is my first patch to llvm, so please bear with me.)
We're moving towards reverse block liveness. Modern liveness queries start at the end of the block and walk backwards, but this is walking forward looking for defs. Can this pass switch to using LiveRegUnits and stepBackwards?