[llvm] [Peephole] Check instructions from CopyMIs are still COPY (PR #69511)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 22:57:32 PDT 2023
================
@@ -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())
----------------
qcolombet wrote:
Here we already stretch the use of the `LocalMIs` structure to know if something has been changed and now i feel we abuse the `CopyMIs` structure since it can hold (stale) reference to non copy.
The patch itself is fine as a quick fix, but maybe we'll want to revisit to properly clean up `CopyMIs` (using the delegate mechanism for instance) and don't require any of these two checks here:
- What is in CopyMIs should not have been deleted or should not be a non-copy.
https://github.com/llvm/llvm-project/pull/69511
More information about the llvm-commits
mailing list