diff options
| author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-11-08 15:29:48 +0000 |
|---|---|---|
| committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-11-08 15:29:48 +0000 |
| commit | 1993894c0300c2f900e53d38196b948f36d566ff (patch) | |
| tree | 460d06c80f954337fd91e2a54e2394bc2e358b35 /llvm/lib/Target | |
| parent | 4c4556186e1b0e0380c0af934982e4f21eb8040c (diff) | |
| download | bcm5719-llvm-1993894c0300c2f900e53d38196b948f36d566ff.tar.gz bcm5719-llvm-1993894c0300c2f900e53d38196b948f36d566ff.zip | |
[SystemZ] Bugfix in shouldCoalesce()
It was discovered in randomized testing that the SystemZ implementation of
shouldCoalesce() could be caused to crash when subreg liveness was
enabled. This was because an undef use of the virtual register was copied
outside current MBB at the point of shouldCoalesce() being called. For more
details, see https://bugs.llvm.org/show_bug.cgi?id=39276.
This patch changes the check for MBB locality from livein/liveout checks to
do checks for all instructions of both intervals being inside MBB. This
avoids the cases with dead defs / undef uses outside MBB, which are not
affecting liveness in/out of MBB.
The original test case included as a reduced .mir test case.
Review: Ulrich Weigand
https://reviews.llvm.org/D54197
llvm-svn: 346406
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp b/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp index 76ed6f80ba5..23338dfec35 100644 --- a/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp @@ -270,25 +270,30 @@ bool SystemZRegisterInfo::shouldCoalesce(MachineInstr *MI, // Check that the two virtual registers are local to MBB. MachineBasicBlock *MBB = MI->getParent(); - if (LIS.isLiveInToMBB(IntGR128, MBB) || LIS.isLiveOutOfMBB(IntGR128, MBB) || - LIS.isLiveInToMBB(IntGRNar, MBB) || LIS.isLiveOutOfMBB(IntGRNar, MBB)) + MachineInstr *FirstMI_GR128 = + LIS.getInstructionFromIndex(IntGR128.beginIndex()); + MachineInstr *FirstMI_GRNar = + LIS.getInstructionFromIndex(IntGRNar.beginIndex()); + MachineInstr *LastMI_GR128 = LIS.getInstructionFromIndex(IntGR128.endIndex()); + MachineInstr *LastMI_GRNar = LIS.getInstructionFromIndex(IntGRNar.endIndex()); + if ((!FirstMI_GR128 || FirstMI_GR128->getParent() != MBB) || + (!FirstMI_GRNar || FirstMI_GRNar->getParent() != MBB) || + (!LastMI_GR128 || LastMI_GR128->getParent() != MBB) || + (!LastMI_GRNar || LastMI_GRNar->getParent() != MBB)) return false; - // Find the first and last MIs of the registers. - MachineInstr *FirstMI = nullptr, *LastMI = nullptr; + MachineBasicBlock::iterator MII = nullptr, MEE = nullptr; if (WideOpNo == 1) { - FirstMI = LIS.getInstructionFromIndex(IntGR128.beginIndex()); - LastMI = LIS.getInstructionFromIndex(IntGRNar.endIndex()); + MII = FirstMI_GR128; + MEE = LastMI_GRNar; } else { - FirstMI = LIS.getInstructionFromIndex(IntGRNar.beginIndex()); - LastMI = LIS.getInstructionFromIndex(IntGR128.endIndex()); + MII = FirstMI_GRNar; + MEE = LastMI_GR128; } - assert (FirstMI && LastMI && "No instruction from index?"); // Check if coalescing seems safe by finding the set of clobbered physreg // pairs in the region. BitVector PhysClobbered(getNumRegs()); - MachineBasicBlock::iterator MII = FirstMI, MEE = LastMI; MEE++; for (; MII != MEE; ++MII) { for (const MachineOperand &MO : MII->operands()) |

