Before this patch, relaxInstruction takes three arguments, the first
argument refers to the instruction before relaxation and the third
argument is the output instruction after relaxation. There are two quite
strange things:
- The first argument's type is const MCInst &, the third argument's type is MCInst &, but they may be aliased to the same variable
- The backends of ARM, AMDGPU, RISC-V, Hexagon assume that the third argument is a fresh uninitialized MCInst even if relaxInstruction may be called like relaxInstruction(Relaxed, STI, Relaxed) in a loop.
In this patch, we drop the thrid argument, and let relaxInstruction
directly modify the given instruction. Also, this patch fixes the bug https://bugs.llvm.org/show_bug.cgi?id=45580, which is introduced by D77851, and
breaks the assumption of ARM, AMDGPU, RISC-V, Hexagon.
Inst = std::move(Res);