[MachineLICM][WinEH] Don't hoist register reloads out of funclets
authorKarl-Johan Johnsson <kalle@kjjohnsson.se>
Sun, 13 Aug 2023 20:55:31 +0000 (23:55 +0300)
committerTobias Hieta <tobias@hieta.se>
Fri, 25 Aug 2023 07:31:55 +0000 (09:31 +0200)
commit1856972dfe1d9871697af131759ab1e70402c847
tree58d30b3112d11bbc0d2958b063f6e08eab14e9ef
parenta4bf0d98670d3d7694ee8f065bed68de8d8f1f75
[MachineLICM][WinEH] Don't hoist register reloads out of funclets

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.

Reviewed By: rnk, arsenm

Differential Revision: https://reviews.llvm.org/D153337

(cherry picked from commit 917574d5d8beacbefab4d0e6469dac5b50117832)
llvm/lib/CodeGen/MachineLICM.cpp
llvm/test/CodeGen/X86/machine-licm-vs-wineh.mir [new file with mode: 0644]