D144535 enabled machine copy propagation for RISC-V and added it to the pass pipeline in addPreEmitPass2 (after the MachineOutliner). Unfortunately, the MachineCopyPropagation pass is unable to correctly analyse outlined functions, and will delete copy instructions where a register is set that is intended to be live-out. RISCVInstrInfo::buildOutlinedFrame will directly insert a JALR, while a similar function going through the normal codegen path would have a PseudoRet with operands indicating registers that are live-out.
This patch does the simplest fix, which is to run MachineCopyPropagation before the MachineOutliner. I think it would make sense to land something like this quickly, but I'd also be interested in discussing thoughts on a "better" follow-up fix that might allow MCP to run later in the pipeline.