The primary fix here is to WinException.cpp: we need to exclude jump tables when computing the length of a function, or else we fail to correctly compute the length. (We can only compute the number of bytes consumed by certain assembler directives after the entire file is parsed. ".p2align" is one of those directives, and is used by jump table generation.)
The secondary fix, to MCWin64EH, is to make sure we don't silently miscompile if we hit a similar situation in the future.
It's possible we could extend ARM64EmitUnwindInfo to emit the length of the function using a relocation that would be resolved later in the assembler, instead of trying to resolve it immediately; this would make alignment directives work correctly. I haven't pursued that approach because I'm not sure how complicated it would be. (We would need to estimate the length somehow to implement unwind data splitting).
Hopefully fixes https://bugs.llvm.org/show_bug.cgi?id=41581 .