It is a proposed patch for the bug presented here: https://bugs.llvm.org/show_bug.cgi?id=49099
In LLVM debug information update guide, "Hoisting identical instructions which appear in several successor blocks into a predecessor block. In this case, there is no single merged instruction. The rule for dropping locations applies."
Here in the code, the hoisted instruction keeps the previous debug location. If there are multiple of the instructions hoisted, then a conservative approach is possibly dropping the debug location.
I also provide a test case here.
If the patch makes sense, can you help commit it? Thanks.
clang-format: please reformat the code