diff options
Diffstat (limited to 'llvm/lib/CodeGen/PeepholeOptimizer.cpp')
-rw-r--r-- | llvm/lib/CodeGen/PeepholeOptimizer.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp index f413ca5..09ae268 100644 --- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp +++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp @@ -1445,7 +1445,9 @@ bool PeepholeOptimizer::foldRedundantCopy( } MachineInstr *PrevCopy = CopyMIs.find(SrcPair)->second; - if (!LocalMIs.count(PrevCopy)) + // A COPY instruction can be deleted or changed by other optimizations. + // Check if the previous COPY instruction is existing and still a COPY. + if (!LocalMIs.count(PrevCopy) || !PrevCopy->isCopy()) return false; assert(SrcSubReg == PrevCopy->getOperand(1).getSubReg() && |