This patch fixes crashes (asserts) encountered in some cases while activating hotpatch using -fms-hotpatch, or clang-cl /HOTPATCH.
PatchableFunction pass emits a TargetOpcode::PATCHABLE_OP at the first LLVM-IR instruction that generates machine code. The search for that instruction was done with a local helper that hasn't been updated along with the addition of new LLVM-IR instructions.
Example crash: https://godbolt.org/z/8M9vGajs9
In this example, DBG_INSTR_REF is selected for TargetOpcode::PATCHABLE_OP; lowering that instruction asserts as the metadata-typed operands are unexpected.
Also, the search for the first instruction was assuming that one would be found, asserting otherwise.
Such case may happen in the case of an empty function that is unreachable ( in C/C++, a simple example is int f() {} )