[TwoAddressInstruction] Fix ReplacedAllUntiedUses in processTiedPairs
authorJay Foad <jay.foad@amd.com>
Thu, 30 Sep 2021 15:35:44 +0000 (16:35 +0100)
committerJay Foad <jay.foad@amd.com>
Thu, 7 Oct 2021 09:10:11 +0000 (10:10 +0100)
commitdf2d4bc4cbc0626364bd4c5fc8203a00fabcd0d5
tree97b11e2718095b44213e325819283c376bf34a30
parent85abedd75074bf574e8b012883b5490674037093
[TwoAddressInstruction] Fix ReplacedAllUntiedUses in processTiedPairs

Fix the calculation of ReplacedAllUntiedUses when any of the tied defs
are early-clobber. The effect of this is to fix the placement of kill
flags on an instruction like this (from @f2 in
 test/CodeGen/SystemZ/asm-18.ll):

  INLINEASM &"stepb $1, $2" [attdialect], $0:[regdef-ec:GRH32Bit], def early-clobber %3:grh32bit, $1:[reguse tiedto:$0], killed %4:grh32bit(tied-def 3), $2:[reguse:GRH32Bit], %4:grh32bit

After TwoAddressInstruction without this patch:

  %3:grh32bit = COPY killed %4:grh32bit
  INLINEASM &"stepb $1, $2" [attdialect], $0:[regdef-ec:GRH32Bit], def early-clobber %3:grh32bit, $1:[reguse tiedto:$0], %3:grh32bit(tied-def 3), $2:[reguse:GRH32Bit], %4:grh32bit

Note that the COPY kills %4, even though there is a later use of %4 in
the INLINEASM. This fails machine verification if you force it to run
after TwoAddressInstruction (currently it is disabled for other
reasons).

After TwoAddressInstruction with this patch:

  %3:grh32bit = COPY %4:grh32bit
  INLINEASM &"stepb $1, $2" [attdialect], $0:[regdef-ec:GRH32Bit], def early-clobber %3:grh32bit, $1:[reguse tiedto:$0], %3:grh32bit(tied-def 3), $2:[reguse:GRH32Bit], %4:grh32bit

Differential Revision: https://reviews.llvm.org/D110848
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
llvm/test/CodeGen/SystemZ/twoaddr-kill.mir