diff options
| author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2019-01-23 07:42:26 +0000 |
|---|---|---|
| committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2019-01-23 07:42:26 +0000 |
| commit | 961c47ec9833ae15ad4cbf71ecfb1403baed465c (patch) | |
| tree | ed39d3cdd914f4bf3fc6b21d0c01aaf0cfe51ee2 /llvm/lib | |
| parent | b5a505570417169218263bb0ed6d84a815a6e2c5 (diff) | |
| download | bcm5719-llvm-961c47ec9833ae15ad4cbf71ecfb1403baed465c.tar.gz bcm5719-llvm-961c47ec9833ae15ad4cbf71ecfb1403baed465c.zip | |
[SystemZ] Handle DBG_VALUE instructions in two places in backend.
Two backend optimizations failed to handle cases when compiled with -g, due
to failing to consider DBG_VALUE instructions. This was in
SystemZTargetLowering::emitSelect() and
SystemZElimCompare::getRegReferences().
This patch makes sure that DBG_VALUEs are recognized so that they do not
affect these optimizations.
Tests for branch-on-count, load-and-trap and consecutive selects.
Review: Ulrich Weigand
https://reviews.llvm.org/D57048
llvm-svn: 351928
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZElimCompare.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 13 |
2 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp b/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp index 0028ae7eb6f..4c13cd6bfca 100644 --- a/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp +++ b/llvm/lib/Target/SystemZ/SystemZElimCompare.cpp @@ -146,6 +146,9 @@ static bool resultTests(MachineInstr &MI, unsigned Reg) { // Describe the references to Reg or any of its aliases in MI. Reference SystemZElimCompare::getRegReferences(MachineInstr &MI, unsigned Reg) { Reference Ref; + if (MI.isDebugInstr()) + return Ref; + for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I) { const MachineOperand &MO = MI.getOperand(I); if (MO.isReg()) { diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp index 0b814ccac3a..0c41f38554f 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -6212,7 +6212,8 @@ static void createPHIsForSelects(MachineBasicBlock::iterator MIItBegin, // destination registers, and the registers that went into the PHI. DenseMap<unsigned, std::pair<unsigned, unsigned>> RegRewriteTable; - for (MachineBasicBlock::iterator MIIt = MIItBegin; MIIt != MIItEnd; ++MIIt) { + for (MachineBasicBlock::iterator MIIt = MIItBegin; MIIt != MIItEnd; + MIIt = skipDebugInstructionsForward(++MIIt, MIItEnd)) { unsigned DestReg = MIIt->getOperand(0).getReg(); unsigned TrueReg = MIIt->getOperand(1).getReg(); unsigned FalseReg = MIIt->getOperand(2).getReg(); @@ -6253,8 +6254,8 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI, // same condition code value, we want to expand all of them into // a single pair of basic blocks using the same condition. MachineInstr *LastMI = &MI; - MachineBasicBlock::iterator NextMIIt = - std::next(MachineBasicBlock::iterator(MI)); + MachineBasicBlock::iterator NextMIIt = skipDebugInstructionsForward( + std::next(MachineBasicBlock::iterator(MI)), MBB->end()); if (isSelectPseudo(MI)) while (NextMIIt != MBB->end() && isSelectPseudo(*NextMIIt) && @@ -6262,7 +6263,7 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI, (NextMIIt->getOperand(4).getImm() == CCMask || NextMIIt->getOperand(4).getImm() == (CCValid ^ CCMask))) { LastMI = &*NextMIIt; - ++NextMIIt; + NextMIIt = skipDebugInstructionsForward(++NextMIIt, MBB->end()); } MachineBasicBlock *StartMBB = MBB; @@ -6295,8 +6296,8 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI, // ... MBB = JoinMBB; MachineBasicBlock::iterator MIItBegin = MachineBasicBlock::iterator(MI); - MachineBasicBlock::iterator MIItEnd = - std::next(MachineBasicBlock::iterator(LastMI)); + MachineBasicBlock::iterator MIItEnd = skipDebugInstructionsForward( + std::next(MachineBasicBlock::iterator(LastMI)), MBB->end()); createPHIsForSelects(MIItBegin, MIItEnd, StartMBB, FalseMBB, MBB); StartMBB->erase(MIItBegin, MIItEnd); |

