AMDGPU: Fix infinite searches in SIFixSGPRCopies
authorAustin Kerbow <Austin.Kerbow@amd.com>
Tue, 15 Oct 2019 19:59:45 +0000 (19:59 +0000)
committerAustin Kerbow <Austin.Kerbow@amd.com>
Tue, 15 Oct 2019 19:59:45 +0000 (19:59 +0000)
commit527e9f9a3f939b2fdb296da9e0e7bbe79b8f4a44
tree924168cec9798309d15707085711ece42b997ce5
parentd498d606b98179f96b33683e296f8c09568028bd
AMDGPU: Fix infinite searches in SIFixSGPRCopies

Summary:
Two conditions could lead to infinite loops when processing PHI nodes in
SIFixSGPRCopies.

The first condition involves a REG_SEQUENCE that uses registers defined by both
a PHI and a COPY.

The second condition arises when a physical register is copied to a virtual
register which is then used in a PHI node. If the same virtual register is
copied to the same physical register, the result is an endless loop.

%0:sgpr_64 = COPY $sgpr0_sgpr1
%2 = PHI %0, %bb.0, %1, %bb.1
$sgpr0_sgpr1 = COPY %0

Reviewers: alex-t, rampitec, arsenm

Reviewed By: rampitec

Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68970

llvm-svn: 374944
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/test/CodeGen/AMDGPU/fix-sgpr-copies.mir