This fixes https://bugs.llvm.org/show_bug.cgi?id=47041
%1:gprc_and_gprc_nor0 = LI 0 ------>DefMI %2:gprc = COPY %1:gprc_and_gprc_nor0 %3:gprc = ORI killed %2:gprc, 1 ------>MI
%3:gprc can be simplified to LI 1, so killed flag for %2:gprc should be hoisted up to other use or to def.
Because we set StartMI as DefMI which is through COPY like instructions before RA, so StartMI is %1:gprc_and_gprc_nor0 instead of %2:gprc, then when we fixup killed/dead flag for %2:gprc, we get %2:gprc redefine asserts.
This patch fixes this assertion, before RA, get real definition by calling getVRegDef instead of using StartMI.
Could you add more comment about the fact StartMI might be altered?