Github issue: https://github.com/llvm/llvm-project/issues/54211
Example: https://godbolt.org/z/KrKPojnqE
When matching PHINodes when margining functions the IROutliner only checks that an incoming value exists in phi node in overall function. It doesn't check the length, the order, or that the incoming block also matches. In the given example, we see that both phi nodes have the same incoming values, but from different blocks.
The fix is to to enforce stricter a match of the incoming value, and the incoming block as well when matching the created phi nodes.
clang-format: please reformat the code