PR 36410 describes a problem where as a result of hoisting common code from "then" and "else" branches of a condition to before the "if", we get a llvm.dbg.value intrinsic with an invalid location. For those intrinsics, the scope indicated in the !dbg location must be identical with the scope of the variable tracked by the intrinsics, or else the module verifier will abort. This constraint can be violated by the current algorithm of getMergedLocation.
Following discussion in https://reviews.llvm.org/D43687, this patch attempts to implement a different approach to fixing this problem. Instead of attempting to merge the locations of two debug intrinsics, we now simply always keep all debug intrinsics from both sides of the "if" during HoistThenElseCodeToIf. This has the additional benefit that we no longer throw away still valid information to help generate better debug data.
If I'm following this correctly, you're hoisting all dbg.value intrinsics from both sides to the predecessor. So given code like the following:
You'll end up with two dbg.value intrinsics in the entry block for the variable "a", so the debugger will choose randomly (?) whether to print a=10 or a=20. That seems wrong.