[llvm] [CloneFunction] Optimize PHI incoming value removal using reverse iteration (NFC) (PR #171955)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 02:49:50 PST 2025


int-zjt wrote:

> This case is a bit more iffy, but should probably also use removeIncomingValueIf()? It may modify the incoming value in case it's not removed, but I believe that should be safe.

Thanks for the suggestion regarding `removeIncomingValueIf`.

I considered using it, but I noticed that I need to move the values to `NewPN` before removing them. If I use `removeIncomingValueIf`, I would have to perform the `NewPN->addIncoming(...)` action inside the predicate lambda.

This introduces side effects into the predicate, which feels a bit unusual and might obscure the logic that we are actually moving values between PHI nodes. Do you think using `removeIncomingValueIf` with side effects is acceptable here, or would the explicit loop be clearer in this specific case?



https://github.com/llvm/llvm-project/pull/171955


More information about the llvm-commits mailing list