Close https://github.com/llvm/llvm-project/issues/57222
The previous deserialization code wouldn't try to merge lambdas since every lambda has a unique type before C++20. In C++20 and later, lambdas can have the same type under certain condition. See the issue link or the comment for example.
This is a workaround for the problem but the cost is the inefficiency. And if we want to fix the problem properly, it looks like we need to touch something very fundamentally and it may affect a lot of things beyond the C++20 modules or even modules.
See my inline comments for details.
The bug/defect has a strong impact. I feel like fixing bug is more important so I prefer to land this one first and file an issue for this to record it.
The comment tells why this is a workaround and what we need to do to fix the problem properly.