[GlobalISel] Fix inserting copies in the right position for reg definitions
authorMarcello Maggioni <hayarms@gmail.com>
Fri, 26 Apr 2019 07:21:56 +0000 (07:21 +0000)
committerMarcello Maggioni <hayarms@gmail.com>
Fri, 26 Apr 2019 07:21:56 +0000 (07:21 +0000)
commitc596584f67075966720f0296e6995593a7a2945f
tree619996a3e49df4092bd841878381920ff817f839
parent05cfdb0eac37eb5571518e1ef2ade9f0397dbc80
[GlobalISel] Fix inserting copies in the right position for reg definitions

When constrainRegClass is called if the constraining happens on a use the COPY
needs to be inserted before the instruction that contains the MachineOperand,
but if we are constraining a definition it actually needs to be added
after the instruction. In addition, the COPY needs to have its operands
flipped (in the use case we are copying from the old unconstrained register
to the new constrained register, while in the definition case we are copying
from the new constrained register that the instruction defines to the old
unconstrained register).

llvm-svn: 359282
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/lib/CodeGen/GlobalISel/Utils.cpp