Issue 107702
Summary MachineCopyPropagation remove copy instruction due to no live-out succ, but the def is indeed used.
Labels new issue
Assignees
Reporter zzk0
    Suppose we have the following scenario:

```
Before MachineCopyPropagation Pass:

bb.1: (no successors)
    B = COPY C
    early-clobber A = OP B (B is a sub-register of A, and B is not renamable.)

After MachineCopyPropagation Pass:

bb.1: (no successors)
 early-clobber A = OP B (B is a sub-register of A, and B is not renamable.)
```

Is this reasonable?



The following might be somewhat difficult to understand. If you feel confused, please let me know. According to the code, we encounter the following situation:

1. `B = COPY C` is added to MaybeDeadCopies.
2. The def register in the instruction `early-clobber A = OP B` is checked, and Tracker.clobberRegister is called to remove A's RegUnit (including B) from the CopyTracker map.
3. When reading the operand `early-clobber A = OP B`, ReadRegister is called for B. However, at this point, B has already been removed from the CopyTracker, so the copy instruction `B = COPY C`  is not removed from MaybeDeadCopies. 

As a result, B = COPY C is mistakenly deleted when there are no successors.


 Any suggestions would be appreciated.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to