PR47468: Fix findPHICopyInsertPoint, so that copies aren't incorrectly inserted after...
authorJames Y Knight <jyknight@google.com>
Thu, 17 Sep 2020 22:10:19 +0000 (18:10 -0400)
committerJames Y Knight <jyknight@google.com>
Fri, 18 Sep 2020 18:14:04 +0000 (14:14 -0400)
commitf7a53d82c0902147909f28a9295a9d00b4b27d38
tree07b7219c8825dbcf460ff25a6debc16c63a72f15
parentecba9d793e205ac857196abbd00cd67777e6f51a
PR47468: Fix findPHICopyInsertPoint, so that copies aren't incorrectly inserted after an INLINEASM_BR.

findPHICopyInsertPoint special cases placement in a block with a
callbr or invoke in it. In that case, we must ensure that the copy is
placed before the INLINEASM_BR or call instruction, if the register is
defined prior to that instruction, because it may jump out of the
block.

Previously, the code placed it immediately after the last def _or
use_. This is wrong, if the use is the instruction which may jump.  We
could correctly place it immediately after the last def (ignoring
uses), but that is non-optimal for register pressure.

Instead, place the copy after the last def, or before the
call/inlineasm_br, whichever is later.

Differential Revision: https://reviews.llvm.org/D87865
llvm/lib/CodeGen/PHIEliminationUtils.cpp
llvm/test/CodeGen/X86/callbr-asm-phi-placement.ll [new file with mode: 0644]